Run terraform in a container!
This file should just be in your path and your terraform codebase located in a folder called terraform. Then just run it like this:
terraformw init
terraformw plan -out plan.tfplan
terraformw apply plan.tfplan
Note that your AWS credentials should be in $HOME/.aws/credentials
, but I guess they already are :-)
The script will ensure that the whole terraform codebase is mounted inside the container, under /app
.
It will then change the working directory in the container, to be the current host directory relative to
the first occurence of a folder called terraform. See expected code structure below.
/code/project-foo/terraform <- folder
/code/project-foo/terraform/common <- example of module used
/code/project-foo/terraform/awesome-stack <- configuration of instances
The from within awesome-stack
you can run terraformw
, and the container will have /code/project-foo/terraform
mounted
on /app
and then change working directory to be /app/awesome-stack
and run terraform from there.