This repo contains material to conduct a Terraform Workshop.
We run all of our terraform commands though docker.
- Install docker
- Run
docker pull hashicorp/terraformto download terraform - Create an AWS account, instuctions available here
All terraform commands can be run through docker using
docker run --rm -ti -v "$PWD:/app" -w "/app" hashicorp/terraform
Try running the below command to get help,
docker run --rm -ti -v "$PWD:/app" -w "/app" hashicorp/terraform --help
Alternatively, to make your life in a shell easier you can alias the command to terraform
alias terraform='docker run --rm -ti -v $PWD:/app -w /app hashicorp/terraform'
You can set this alias in your profile file to automatically run everytime you log into a shell.
Now run,
terraform --help
This is the typical execution cycle of an application managed by terraform
+-----------+ +----------+
| Plan | -------> | Apply |
+-----------+ +----------+
| |
| \------------\ +-----+
| | | * |
V V V |
+-----------+ +--------------+ +---------------+
| Create | -------> | Upgrade | ---------> | Destroy |
+-----------+ +--------------+ +---------------+
terraform plan and terraform apply commands are used to mange the application infrastructure on the cloud.
- Ssh into public instance
ssh -i ~/.ssh/[.pem file] ubuntu@[instance ip] - Scp a file into an instance
scp -i ~/.ssh/[.pem file] ./file(src) ubuntu@[instance ip]:/tmp/(dest) - Scp a file from an instance
scp -i ~/.ssh/[.pem file] ubuntu@[instance ip]:/tmp/(src) ./file(dest)