Skip to content

Instantly share code, notes, and snippets.

@soerenmartius
Created May 5, 2022 12:24
Show Gist options
  • Save soerenmartius/d65d4cf323bf4d4b7369c7961c08ac98 to your computer and use it in GitHub Desktop.
Save soerenmartius/d65d4cf323bf4d4b7369c7961c08ac98 to your computer and use it in GitHub Desktop.
This example shows some advanced features of Terramate.
# file: stacks/config.tm
globals {
# define a bucket name that is used when generating backend.tf defined below
gcs_bucket_name = "my-state-bucket"
# the following will calculate the path name of each stack
# but remove the / prefix as gcs does not handle this well
gcs_bucket_prefix = tm_substr(terramate.path, 1, -1)
}
# The block label specifies the name of the file to create in stacks
# This file will be generated in all stacks reachable from this configuration
generate_hcl "backend.tf" {
content {
terraform {
backend "gcs" {
bucket = global.gcs_bucket_name
prefix = global.gcs_bucket_prefix
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment