Home

Awesome

Heroku Common Runtime microservices with a unified gateway using Terraform

Each microservice is exposed to the internet through a Kong service & route, secured via Heroku's built-in SSL/TLS certificates.

The Common Runtime allows public access to web apps by default. To ensure the gateway provides exclusive access to the microservices, the microservices must restrict access using a pre-shared API key (generated by Terraform) set in the "X-Internal-API-Key" HTTP header.

A single Terraform config embodies the complete system, enabling high-level collaboration, repeatability, test-ability, and change management.

Diagram: Terraform a complete multi-app architecture with a Kong gateway

▶ See also: Heroku Enterprise / Private Spaces version of this architecture

Primary components

Challenges & Caveats

Requirements

Usage

Ensure the requirements are met, then,

  1. Clone this repo:

    git clone git@github.com:heroku-examples/terraform-heroku-common-kong-microservices.git
    cd terraform-heroku-common-kong-microservices/
    
  2. Install terraform-provider-kong 1.9.1

    • download the .zip asset for your computer's architecture
    • unzip it into terraform.d/plugins/$ARCH/
    • where $ARCH is the computer's architecture, like darwin_amd64
  3. Set Heroku API key

    1. heroku authorizations:create -d terraform-heroku-common-kong-microservices
    2. export HEROKU_API_KEY=<"Token" value from the authorization>
  4. terraform init

  5. Then, apply the config with your own top-level config values:

    terraform apply -var name=kong-micro -var heroku_team=my-team
    
  6. Visit the output URLs in a web browser to demonstrate the secure backend & public gateway:

    • terraform output wasabi_backend_url not directly accessible
    • terraform output wasabi_public_url

🔬 This is a community proof-of-concept, MIT license, provided "as is", without warranty of any kind.