TechKnowday Terraform workshop files
-
Download Terraform from terroform.io
For Mac,
wget https://releases.hashicorp.com/terraform/0.11.11/terraform_0.11.11_darwin_amd64.zip -O /tmp/terraform.zip
For Linux,
wget https://releases.hashicorp.com/terraform/0.11.11/terraform_0.11.11_linux_amd64.zip -O /tmp/terraform.zip
-
Extract to a directory
mkdir -p mkdir -p ${HOME}/terraform unzip /tmp/terraform.zip -d ${HOME}/terraform/
-
Set Classpath
echo 'export PATH=${HOME}/terraform:${PATH}' >> ~/.bashrc source ~/.bashrc
Make sure to configure AWS credentials so that terraform can create/manage AWS resources.
Create/Open ~/.aws/credentials
file and make sure it has access key and secret access key
[demo]
region = us-west-2
output = json
aws_access_key_id = <YOUR AWS ACCESS KEY ID>
aws_secret_access_key = <YOUR AWS SECRET ACCESS KEY ID>
Running these(Terraform) examples may incur charge in AWS account.
- Navigate to code directory (let's say
demo2/
) - Put one
tfvars
file underenv
directory for each environment. (Referexample.tfvars
file) - Run
terraform init
to initialize terraform - Run
terraform plan -var-file=env/demo.tfvars
to see the plan (Let's saydemo.tfvars
is fordemo
environment) - If happy with the plan, run
terraform apply -var-file=env/demo.tfvars
- If want to cleanup(or destroy all resources created by this example terraform code), run
terraform destroy -var-file=env/demo.tfvars