User Tools

Site Tools


start_a_new_script

Start a New Script

Aug 2017

|


As Terraform is a very small file (by todays standards) I generally create a new folder, and put the Terraform.exe executable in to that folder. I then keep Terraform and my script in that folder, creating a new folder containing a copy of Terraform for each script.

This is useful as Terraform creates other files to do with your scripts, and having lots of these in a single folder can be quite frustrating.

For this example, please do the following:

  1. Create a new folder
  2. Copy the Terraform.exe in to your new folder
  3. Create a new file in your preferred text editor and save it as “my_instance.tf”





Paste the following text in to your “my_instance.tf” file and save it.

<sxh> provider “aws” {

      access_key = "XXXXXXXXXXXXXXXX"
      secret_key = "XXXXXXXXXXXXXXXXXXXXXX"
      region = "xxxxxxxx"

}

resource “aws_instance” “simple_example” {

      ami = "ami-xxxxxxxx"
      instance_type = "xxxxxxxx"
      key_name = "xxxxxxxx"
      security_groups= ["xxxxxxxx"]
      tags {
       Name = "terraform-instance"
      }

} </sxh>
As you go through each section of this guide, enter the relevant details in this script and save it each time. At the end of the guide you will have a finished script that you can test.

start_a_new_script.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1