Skip to content

Commit

Permalink
Upgrade to official Terraform 0.12.0 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars authored Jun 3, 2019
1 parent 6fdc0ff commit f9cb7fb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
Binary file not shown.
Binary file not shown.
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Terraforming 🌱 Heroku app
===========================

[Terraform](https://www.terraform.io/) [0.12 Beta 1](https://www.hashicorp.com/blog/announcing-terraform-0-1-2-beta1) as a [Heroku](https://www.heroku.com/) app.

Includes a [0.12 dev snapshot](http://terraform-0.12.0-dev-snapshots.s3-website-us-west-2.amazonaws.com/terraform-provider-heroku/) of [Heroku Provider version 1.8.0](https://www.terraform.io/docs/providers/heroku/index.html).
[Terraform](https://www.terraform.io/) [0.12](https://www.hashicorp.com/blog/announcing-terraform-0-12) as a [Heroku](https://www.heroku.com/) app.

Run Terraform CLI in the cloud:

Expand All @@ -13,7 +11,7 @@ heroku run terraform apply

🔬🚧 This is a community proof-of-concept, [MIT license](LICENSE), provided "as is", without warranty of any kind.

🌲🔥 To enable the [Postgres backend](https://github.com/mars/terraform/blob/postgres-backend/website/docs/backends/types/pg.html.md) for Terraform, this app uses the [`terraform` 0.12 Beta binary](https://releases.hashicorp.com/terraform/0.12.0-beta1/), which includes this new feature (see: [hashicorp/terraform #19070](https://github.com/hashicorp/terraform/pull/19070)).
⭐️💁‍♀️ To use the [Terraform Postgres backend](https://www.terraform.io/docs/backends/types/pg.html), this app requires [Terraform 0.12](https://www.hashicorp.com/blog/announcing-terraform-0-12).

Set-up
------
Expand Down Expand Up @@ -172,10 +170,8 @@ cd terraforming-app/
heroku create $APP_NAME --buildpack mars/terraforming
heroku addons:create heroku-postgresql

# Use 0.12 Beta of Terraform that supports Postgres backend
# https://github.com/hashicorp/terraform/pull/19070
#
heroku config:set TERRAFORM_BIN_URL=https://releases.hashicorp.com/terraform/0.12.0-beta1/terraform_0.12.0-beta1_linux_amd64.zip
# Use Terraform 0.12 to support Postgres backend
heroku config:set TERRAFORM_BIN_URL=https://releases.hashicorp.com/terraform/0.12.0/terraform_0.12.0_linux_amd64.zip

# Set credentials for the Terraform Heroku provider
heroku config:set HEROKU_API_KEY=xxxxx [email protected]
Expand All @@ -188,16 +184,31 @@ git push heroku master

### Run Terraform locally w/ Heroku Postgres backend

🌲🔥 Requires using [Terraform 0.12 Beta](https://www.hashicorp.com/blog/announcing-terraform-0-1-2-beta1).

```bash
# First-time for each terminal
export DATABASE_URL=`heroku config:get DATABASE_URL`

# First-time for each project
terraform init -backend-config="conn_str=$DATABASE_URL"

# Then, apply & destroy as you like.
terraform apply
terraform destroy
```

### Run Terraform locally w/ local Postgres backend

```bash
# Create the local database using Postgres Client tool
createdb terraform_backend

# First-time for each terminal
export DATABASE_URL='postgres://localhost/terraform_backend?sslmode=disable'

# First-time for each project
terraform init -backend-config="conn_str=$DATABASE_URL"
# …or use a local database with SSL disabled
terraform init -backend-config="conn_str=postgres://localhost/terraform_backend?sslmode=disable"

# Continue using Terraform with the Heroku app's Postgres backend
terraform plan
# Then, apply & destroy as you like.
terraform apply
terraform destroy
```
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"env": {
"TERRAFORM_BIN_URL": {
"description": "The source URL for the terraform binary (preset for Postgres backend support)",
"value": "https://releases.hashicorp.com/terraform/0.12.0-beta1/terraform_0.12.0-beta1_linux_amd64.zip",
"value": "https://releases.hashicorp.com/terraform/0.12.0/terraform_0.12.0_linux_amd64.zip",
"required": false
},
"HEROKU_API_KEY": {
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ terraform {
}

provider "heroku" {
version = "~> 2.0"
}

variable "example_app_name" {
Expand Down

0 comments on commit f9cb7fb

Please sign in to comment.