Skip to the content.

Terraform Exploration

Terraform allows you to write infrastructure as code. This is my exploration of terraform. Follow this getting started guide for AWS.

  1. Follow instructions on Sage jumpcloud to access the aws cli. Must set up a profile in ~/.aws/credentials.
  2. Initialize terraform

     terraform init
    
  3. Terraform has an auto formatter that will automatically format the code and you can validate the structure as well.

     terraform fmt
     terraform validate
    
  4. Create instance

     cd learn-terraform-aws-instance
     terrafrom apply
    

    Terraform stores the state either locally or remotely. By default, it is stored locally in a file but the state can actually be stored in terraform cloud or terraform enterprise.

  5. Remove instance

     terraform destroy
    
  6. Terraform configuration can be split into different files

    • main.tf: Houses the resources to spin up
    • provider.tf: Determines what provider to use (GCP, AWS…)
    • backend.tf: Determines what backend to use (local, remote)
    • variable.tf: Resources can take variables
    • outputs.tf: Resources can have outputs

Terraform cloud

Followed instructions here to get started.