|
2 years ago | |
---|---|---|
.. | ||
.gitignore | 2 years ago | |
README.md | 2 years ago | |
main.tf | 2 years ago |
brew install terraform
Make sure you have AWS CLI setup.
touch main.tf
atom main.tf
Paste in the following code to create a simple EC2 Instance (replace with correct ami):
resource "aws_instance" "example" {
ami = "ami-95f8d2f3"
instance_type = "t2.micro"
tags {
Name = "terraform-hello-world"
}
}
Terraform plan allows you to see what Terraform would do before actually running the file:
terraform plan
If asked, the AWS region used for Decode project is eu-west-1
.
To actually run the file:
terraform apply
To pass Terraform a variable via command line
terraform plan -var server_port="8080"