No Description 877B

Terraform Spike

Setup Terraform on your machine

brew install terraform

Make sure you have AWS CLI setup.

Hello world example


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"