Easy Terraform wrapper
Avoid repeating of terraform code across environments, put all common (across environments) resources in
common
directory, put differentiating variables and resources to environment specific directories (eg. stage
or prod
)
Unlike terragrunt, idea here is NOT to split infrastructure to as many states as possible, this allows easier consumption of resource outputs within a single apply / plan
It's bash, how much easier can it get? :)
This is optional to use this, in terraeasy.sh
terraeasy.sh
will clone / pull given git repository on every run. Idea behind this is that when there is a repository
with multiple custom terraform modules, we clone/pull it once (effectively cache) and refer to module source by relative
path (prefixed with ../.terraform-modules/
)
terraeasy.sh
has built in help, so just run it without any arguments for help
When you run terraeasy.sh
for a given environment (eg. stage) it will:
- Create working directory (
tf-working-dir
by default) - Create symbolic links for
*tf*
files (so eg. .tf, .tfvars) fromcommon
andstage
(in this example) totf-working-dir
- Will run
terraform init -reconfigure
with-chdir tf-working-dir
- Will run your command (eg. plan or apply) with
-chdir tf-working-dir
and will includestate.tfvars
fromstage
directory