Run Terraform CLI in the cloud:
heroku run terraform apply
🔬🚧 This is a community proof-of-concept, MIT license, provided "as is", without warranty of any kind.
🌲🔥 To enable Heroku Postgres as the Terraform backend, this app uses the terraform
binary built from an unmerged pull request to Terraform (see: hashicorp/terraform #19070).
Terraform works best with Heroku when contained by a team.
Terraform uses an authorization token (secret key) access the Heroku API.
Terraform's access can be isolated from your main user account by creating a separate Heroku account & authorization token, and inviting the new account to the team.
terraforming-app
. Note the generated Authorization token.
Create a new app for Terraform by clicking the "Deploy" button below. On the form that appears, set:
- App name to something like
teamname-terraform
- App owner to the team name created above
- HEROKU_API_KEY to the Authorization token generated above
- HEROKU_EMAIL to the email of the separate account created above
Create a local working copy of the Heroku app, to begin committing & applying Terraform configurations.
✏️ Replace $APP_NAME
with the value of the App name created above, like teamname-terraform
git clone https://github.com/mars/terraforming-app.git $APP_NAME
cd $APP_NAME
heroku git:remote --app $APP_NAME
Once set-up is complete, you can begin using Terraform!
Use the Heroku provider and others to build-up configuration in *.tf
files.
The included main.tf
is required to deploy successfully. The buildpack will not work without main.tf
. You can replace its content as needed.
git add .
git commit -m 'Initial configuration'
git push heroku master
⏳ Wait for the push to complete.
Use interactively in one-off dynos:
heroku run terraform plan
heroku run terraform apply
export APP_NAME=my-app
git clone https://github.com/mars/terraforming-app
cd terraforming-app/
heroku create $APP_NAME --buildpack mars/terraforming
heroku addons:create heroku-postgresql
# Use our fork of Terraform that supports Postgres backend
# https://github.com/hashicorp/terraform/pull/19070
#
heroku config:set TERRAFORM_BIN_URL=https://terraforming-buildpack.s3.amazonaws.com/terraform_0.11.9-pg.02_linux_amd64.zip
# Set credentials for the Terraform Heroku provider
heroku config:set HEROKU_API_KEY=xxxxx HEROKU_EMAIL=x@example.com
# Set Terraform input variables
heroku config:set TF_VAR_example_app_name=$APP_NAME-example
git push heroku master
🌲🔥 Requires local terraform
binary built from the Postgres backend PR (hashicorp/terraform #19070).
# First-time for each terminal
export DATABASE_URL=`heroku config:get DATABASE_URL`
$GOPATH/src/github.com/hashicorp/terraform/pkg/darwin_amd64/terraform init -backend-config="conn_str=$DATABASE_URL"
# Continue using Terraform with the Heroku app's Postgres backend
$GOPATH/src/github.com/hashicorp/terraform/pkg/darwin_amd64/terraform plan
$GOPATH/src/github.com/hashicorp/terraform/pkg/darwin_amd64/terraform apply