This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
globals { | |
dns_record_sets = [ | |
"google.com", | |
"facebook.com", | |
] | |
} | |
generate_hcl "terramate_data.tf" { | |
content { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
globals { | |
generate_data_source_google_ip = true | |
} | |
generate_hcl "terramate_data.tf" { | |
lets { | |
condition = tm_try(global.generate_data_source_google_ip, true) | |
} | |
content { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform state list | grep -v '^data\.' | grep -v '^null_resource\.' | wc -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Example on how to generate a more specific provider such as Kubernetes | |
# The deployment trigger is used to deferr the data source at plan time if it's not available quick is a commonly known workaround in Terraform | |
# In TF 1.9 this will most likely be fixes by finally allowing plan time with values that are not yet available natively https://github.com/hashicorp/terraform/releases/tag/v1.9.0-alpha20240404 | |
globals "terraform" "providers" "kubernetes" { | |
source = "hashicorp/kubernetes" | |
version = "~> 2.16" | |
postpone_init_to_apply = true | |
enabled = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File: /projects/locals.tm.hcl | |
# Export env and project_id to be referenced as local.project_id and local.env | |
# in main.tf and other Terraform files in each stack. | |
generate_hcl "_terramate_generated_locals" { | |
content { | |
locals { | |
env = global.env | |
project_id = global.project_id | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
projects/ | |
├── provider.tm.hcl | |
├── backend.tm.hcl | |
├── my-project-prod/ | |
│ ├── project.tm.hcl | |
│ ├── stack-1/ | |
│ │ ├── main.tf | |
│ │ ├── stack.tm.hcl | |
│ │ ├── _terramate_generated_provider.tf | |
│ │ └── _terramate_generated_backend.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File: /projects/backend.tm.hcl | |
# The file is prefixed with _terramate_generated here to make the generated nature | |
# of it more visible | |
generate_hcl "_terramate_generated_backend.tf" { | |
content { | |
terraform { | |
backend "gcs" { | |
bucket = "tf-state-${global.project_id}" | |
prefix = terramate.stack.path.absolute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File: /projects/my-project-prod/project.tm.hcl | |
globals { | |
env = "prod" | |
project_id = "my-project-${global.env}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File: /projects/my-project-staging/project.tm.hcl | |
globals { | |
env = "staging" | |
project_id = "my-project-${global.env}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File: /projects/providers.tm.hcl | |
globals { | |
# The default project_id to configure the provider with. | |
# The provider_id can be set at any level in the hierarchy. | |
# If no project_id the provider fallbacks are used. | |
terraform_google_provider_project = tm_try(global.project_id, null) | |
# The default region to configure | |
terraform_google_provider_region = "europe-north1" |
NewerOlder