-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterragrunt.hcl
59 lines (52 loc) · 1.72 KB
/
terragrunt.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# terraform.hcl
locals {
# Automatically load subscription variables
subscription_vars = read_terragrunt_config(find_in_parent_folders("subscription.hcl"))
# Automatically load region-level variables
region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
# Automatically load environment-level variables
environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
location = local.region_vars.locals.location
environment = local.environment_vars.locals.environment
subscription_id = local.subscription_vars.locals.subscription_id
}
# Generate Azure providers
generate "versions" {
path = "versions_override.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "2.95.0"
}
}
}
provider "azurerm" {
features {}
subscription_id = "${local.subscription_id}"
}
EOF
}
remote_state {
backend = "azurerm"
config = {
subscription_id = "${local.subscription_id}"
key = "${path_relative_to_include()}/terraform.tfstate"
resource_group_name = "cloudshellstorage"
storage_account_name = "chrillecloudstorage"
container_name = "terragrunt"
}
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
}
}
# Configure root level variables that all resources can inherit. This is especially helpful with multi-subscription configs
# where terraform_remote_state data sources are placed directly into the modules.
inputs = merge(
local.subscription_vars.locals,
local.region_vars.locals,
local.environment_vars.locals
)