Skip to content

Step 3. Prepare your GCP environment

Todo

GCP is not yet supported by MACH composer.
We are happy to accept contributions to add this! And think with you if you plan to work on it. Feel free to reach out to us via opensource@labdigital.nl.

What needs to happen to support GCP?

Luckily, adding GCP should not be a lot of work. Most of the implementation boils down to adding the right terraform code in MACH composer, to generate the necessary resources. This is primarily about setting up an API gateway that ties together many services, through GCP's Terraform support.

  • Decide on what services to use
  • Add support in MACH yaml to support GCP cloud
  • Add terraform templates to MACH composer, to support GCP resources
  • Add support for storing terraform state remotely in GCP
  • Ideally: extend component bootstrapper and component cookiecutter to include Google Cloud setup
  • Expand documentation with GCP

Infra decisions

For the following solutions we have in place for AWS and Azure, we need to decide on the service we want to use in Google Cloud:

  • Terraform state
  • HTTP routing / API gateway
  • Custom domains / DNS

For reference implementations of components:

  • Secrets management
  • Serverless functions

Note

For all services, we need to take into account that it should be deployed through terraform completely.
Though solutions exist when there is no 'full-blown' terraform support, in which case you could fall back to a CLI. We recently did this to implement Apollo Studio support.

Terraform state backend

Use Google Cloud Storage as documented by Terraform.

HTTP routing / API gateway

Use API Gateway.

Custom domains

Custom domain names are not supported by API Gateway. For custom domains, we need to create a load balancer and direct requests to the gateway.dev domain of the deployed API.

Custom domains / DNS

Google Cloud DNS

Secrets management

GCP secrets manager.

Serverless function

  • Serverless functions: Google Cloud Functions
    • Example for commercetools api extensions
    • Example for commercetools subscriptions
    • Example for generic API
  • Serverless Docker containers: Google CloudRun
    • Example for generic API

Interesting read: https://dev.to/didil/gcp-api-gateway-demo-with-terraform-go-cloud-run-3o9e

Multi tenancy

We need to determine what 'project structure' will be used in GCP. In other clouds we use multiple resource groups (Azure) and accounts (AWS) to provide multi-tenancy/platform partitioning between sites. The same should be achieved with GCP.