This repository provides a Makefile to give you a simple interface for Terraform.
- Simplify your CLI terraform runs
- Don't Repeat Yourself while typing terraform commands
- Easier adoption for people that are not used to Terraform
- Document common usage
- Unique entrypoint script for credentials management (only for AWS, Azure, DigitalOcean, Google and Scaleway for now)
- either passing ENV variables. E.g.
<PROVIDER>_<ENV>_SECRET
will be mapped toDIGITALOCEAN_TOKEN
ifprovider=do
is provided as variable - either using
pass
as local secret manager. E.g. passwordterraform/<provider>/<env>/secret
will be mapped toDIGITALOCEAN_TOKEN
ifprovider=do
is provided as variable - either using
vault
as distributed secret manager (Only for AWS credentials for now). E.g. by usingVAULT_ADDR
and eitherVAULT_ROLE_ID
+VAULT_SECRET_ID
or directly aVAULT_TOKEN
your credentials will automatically be fetched into your vault.
- either passing ENV variables. E.g.
(for now packages are only published in Github releases)
wget https://github.com/paulRbr/terraform-makefile/releases/download/<version>/tf-make_<version>_amd64.deb
dpkg -i tf-make_<version>.deb
Simply download the Makefile
and the terraform.sh
files in safe place.
mkdir -p /opt/terraform
cd /opt/terraform
wget -N https://raw.githubusercontent.com/paulRbr/terraform-makefile/master/{Makefile,terraform.sh}
Then you will need to add the tf-make
binary (it's a simple bash script) in your $PATH. WARNING: you'll need to change the Makefile path in the tf-make
file.
This makefile assumes your terraform configuration files are stored as such:
providers/
├── aws
│ ├── prod
│ │ └── empty.tf
│ └── test
│ └── empty.tf
├── do
│ └── prod
│ └── empty.tf
├── google
│ ├── prod
│ │ └── empty.tf
│ └── test
│ └── empty.tf
└── scaleway
└── prod
└── empty.tf
I.e. providers/<provider>/<env>/*.tf
List of commands made available
> make
Terraform-makefile v0.11.11
console Console infra resources
destroy Destroy resources
dry-run Dry run resources changes
import Import infra resources
install Install terraform and dependencies
lint Rewrites config to canonical format
refresh Refresh infra resources
run Execute resources changes
show List infra resources
state Inspect or change the remote state of your resources
taint Taint infra resources
validate Basic syntax check
workspace Workspace infra resources
Details of the variables that can be passed to commands:
Name | Default | Values | Description | Example |
---|---|---|---|---|
provider |
- | aws azure do google scaleway |
Name of the cloud provider to target | With your terraform file in provider/aws/production/production.tf you will be able to make dry-run provider=aws env=production |
env |
- | String |
Name of the environment you want to use | With a terraform file in provider/google/production/production.tf you will be able to make dry-run provider=google env=production |
args |
- | String |
Add terraform understandable arguments | make dry-run args='-no-color' |