diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/locals.tf b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/locals.tf index 1f3af0b6..a9f1bf25 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/locals.tf +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/locals.tf @@ -1,10 +1,10 @@ locals { - bootstrap = var.bootstrap + bootstrap = yamldecode(file("${path.module}/../../config/accounts/bootstrap.yaml")) - config_account_name = coalesce(var.account_name, try(local.bootstrap.account_name, null)) - config_region = coalesce(var.region, try(local.bootstrap.region, null)) - config_role_name = coalesce(var.role_name, try(local.bootstrap.iam.role_name, null)) - config_terraform_user = coalesce(var.terraform_user_name, try(local.bootstrap.iam.terraform_user_name, null)) + config_account_name = coalesce(var.account_name, local.bootstrap.account_name) + config_region = coalesce(var.region, local.bootstrap.region) + config_role_name = coalesce(var.role_name, local.bootstrap.iam.role_name) + config_terraform_user = coalesce(var.terraform_user_name, local.bootstrap.iam.terraform_user_name) environment = coalesce(try(local.bootstrap.environment, null), try(local.bootstrap.iam.environment, null), "bootstrap") extra_tags = try(local.bootstrap.tags, {}) @@ -15,8 +15,9 @@ locals { } locals { - account = length(var.account) > 0 ? var.account : { - account_id = try(local.bootstrap.account_id, null) + account_file_path = "${path.module}/../../../config/accounts/${local.config_account_name}.yaml" + account = fileexists(local.account_file_path) ? yamldecode(file(local.account_file_path)) : { + account_id = local.bootstrap.account_id environment = local.environment tags = local.extra_tags } diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/terragrunt.hcl b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/terragrunt.hcl index 329a27cd..22a292a6 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/terragrunt.hcl +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/terragrunt.hcl @@ -2,47 +2,10 @@ include "root" { path = find_in_parent_folders() } -locals { - root_config = read_terragrunt_config(find_in_parent_folders()) - bootstrap_config = local.root_config.locals.bootstrap_config - account_file = find_in_parent_folders("config/accounts/${local.bootstrap_config.account_name}.yaml", "") - account_config = fileexists(local.account_file) ? yamldecode(file(local.account_file)) : { - account_id = local.bootstrap_config.account_id - environment = try(local.bootstrap_config.environment, "bootstrap") - tags = try(local.bootstrap_config.tags, {}) - } -} - -dependency "state" { - config_path = "../state" - - mock_outputs = { - bucket_name = local.bootstrap_config.state.bucket_name - region = local.bootstrap_config.region - } - - mock_outputs_allowed_terraform_commands = ["plan", "validate"] -} - -dependency "lock" { - config_path = "../lock" - - mock_outputs = { - dynamodb_table_name = local.bootstrap_config.state.dynamodb_table_name - region = local.bootstrap_config.region - } - - mock_outputs_allowed_terraform_commands = ["plan", "validate"] +dependencies { + paths = ["../state", "../lock"] } terraform { - source = "./" -} - -inputs = { - region = dependency.state.outputs.region - state_bucket_name = dependency.state.outputs.bucket_name - state_lock_table_name = dependency.lock.outputs.dynamodb_table_name - bootstrap = local.bootstrap_config - account = local.account_config + source = "${get_parent_terragrunt_dir()}/..//bootstrap/identity" } diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/variables.tf b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/variables.tf index 549afd82..bcfc31ba 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/variables.tf +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/identity/variables.tf @@ -73,15 +73,3 @@ variable "state_lock_table_name" { type = string default = null } - -variable "bootstrap" { - description = "Bootstrap configuration provided by Terragrunt" - type = map(any) - default = {} -} - -variable "account" { - description = "Resolved account configuration provided by Terragrunt" - type = map(any) - default = {} -} diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/locals.tf b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/locals.tf index cd71a14a..ec47840d 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/locals.tf +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/locals.tf @@ -1,5 +1,5 @@ locals { - bootstrap = var.bootstrap + bootstrap = yamldecode(file("${path.module}/../../config/accounts/bootstrap.yaml")) dynamodb_table_name = coalesce(var.table_name, local.bootstrap.state.dynamodb_table_name) region = coalesce(var.region, local.bootstrap.region) diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/terragrunt.hcl b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/terragrunt.hcl index ce4c3c9a..7553a16d 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/terragrunt.hcl +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/terragrunt.hcl @@ -2,27 +2,10 @@ include "root" { path = find_in_parent_folders() } -locals { - root_config = read_terragrunt_config(find_in_parent_folders()) - bootstrap_config = local.root_config.locals.bootstrap_config -} - -dependency "state" { - config_path = "../state" - - mock_outputs = { - bucket_name = local.bootstrap_config.state.bucket_name - region = local.bootstrap_config.region - } - - mock_outputs_allowed_terraform_commands = ["plan", "validate"] +dependencies { + paths = ["../state"] } terraform { - source = "./" -} - -inputs = { - region = dependency.state.outputs.region - bootstrap = local.bootstrap_config + source = "${get_parent_terragrunt_dir()}/..//bootstrap/lock" } diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/variables.tf b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/variables.tf index 8474ce27..a2efe3b3 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/variables.tf +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/lock/variables.tf @@ -9,9 +9,3 @@ variable "region" { type = string default = null } - -variable "bootstrap" { - description = "Bootstrap configuration provided by Terragrunt" - type = map(any) - default = {} -} diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/locals.tf b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/locals.tf index 64a1c3d7..f8412c24 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/locals.tf +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/locals.tf @@ -1,5 +1,5 @@ locals { - bootstrap = var.bootstrap + bootstrap = yamldecode(file("${path.module}/../../config/accounts/bootstrap.yaml")) bucket_name = coalesce(var.bucket_name, local.bootstrap.state.bucket_name) region = coalesce(var.region, local.bootstrap.region) diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/terragrunt.hcl b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/terragrunt.hcl index 1d1be78e..665b913b 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/terragrunt.hcl +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/terragrunt.hcl @@ -2,17 +2,6 @@ include "root" { path = find_in_parent_folders() } -locals { - root_config = read_terragrunt_config(find_in_parent_folders()) - bootstrap_config = local.root_config.locals.bootstrap_config -} - terraform { - source = "./" -} - -inputs = { - bucket_name = local.bootstrap_config.state.bucket_name - region = local.bootstrap_config.region - bootstrap = local.bootstrap_config + source = "${get_parent_terragrunt_dir()}/..//bootstrap/state" } diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/variables.tf b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/variables.tf index f51ac18f..e08efbea 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/variables.tf +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/state/variables.tf @@ -9,9 +9,3 @@ variable "region" { type = string default = null } - -variable "bootstrap" { - description = "Bootstrap configuration provided by Terragrunt" - type = map(any) - default = {} -} diff --git a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/terragrunt.hcl b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/terragrunt.hcl index 49335045..c2366d8f 100644 --- a/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/terragrunt.hcl +++ b/iac-template/terraform-hcl-standard/aws-cloud/bootstrap/terragrunt.hcl @@ -2,5 +2,5 @@ terraform_version_constraint = ">= 1.2.0" terragrunt_version_constraint = ">= 0.67.14" locals { - bootstrap_config = yamldecode(file(find_in_parent_folders("config/accounts/bootstrap.yaml"))) + bootstrap_config = yamldecode(file("${get_original_terragrunt_dir()}/../config/accounts/bootstrap.yaml")) }