diff --git a/.gitignore b/.gitignore index b072ea2..4787ef6 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ terragrunt.hcl common_vars.yaml remote-state.tf -destroyCleanup.sh +!tf/roots/*/terragrunt.hcl + graph.svg diff --git a/tf/roots/1_static/terragrunt.hcl b/tf/roots/1_static/terragrunt.hcl new file mode 100644 index 0000000..516b901 --- /dev/null +++ b/tf/roots/1_static/terragrunt.hcl @@ -0,0 +1,19 @@ +// Doc: [Configuration Parsing Order](https://terragrunt.gruntwork.io/docs/getting-started/configuration/#configuration-parsing-order) + +include { + path = find_in_parent_folders() +} + +locals { + common_vars = yamldecode(file("${get_terragrunt_dir()}/${find_in_parent_folders("common_vars.yaml")}")) + // More locals here ... +} + +inputs = { + suts_attributes = local.common_vars.suts_attributes +} + +terraform { + +} + diff --git a/tf/roots/2_nw/terragrunt.hcl b/tf/roots/2_nw/terragrunt.hcl new file mode 100644 index 0000000..0f4dae6 --- /dev/null +++ b/tf/roots/2_nw/terragrunt.hcl @@ -0,0 +1,20 @@ +// Doc: [Configuration Parsing Order](https://terragrunt.gruntwork.io/docs/getting-started/configuration/#configuration-parsing-order) + +include { + path = find_in_parent_folders() +} + +locals { + common_vars = yamldecode(file("${get_terragrunt_dir()}/${find_in_parent_folders("common_vars.yaml")}")) + // More locals here ... +} + +inputs = { + suts_attributes = local.common_vars.suts_attributes + +} + +terraform { + +} + diff --git a/tf/roots/3_contOrc/terragrunt.hcl b/tf/roots/3_contOrc/terragrunt.hcl new file mode 100644 index 0000000..0b7d8f7 --- /dev/null +++ b/tf/roots/3_contOrc/terragrunt.hcl @@ -0,0 +1,49 @@ +// Doc: [Configuration Parsing Order](https://terragrunt.gruntwork.io/docs/getting-started/configuration/#configuration-parsing-order) + +include { + path = find_in_parent_folders() +} + +locals { + common_vars = yamldecode(file("${get_terragrunt_dir()}/${find_in_parent_folders("common_vars.yaml")}")) + // More locals here ... +} + +dependency "static" { + config_path = "../1_static" +} + +dependency "nw" { + config_path = "../2_nw" +} + +inputs = { + // Consume static outputs + ecs_instance_profile = dependency.static.outputs.ecs_instance_profile + ecs_service_role = dependency.static.outputs.ecs_service_role + ecs_task_execution_role = dependency.static.outputs.ecs_task_execution_role + + // Consume nw outputs + sg_sut_id = dependency.nw.outputs.sg_sut_id + sg_ssh_id = dependency.nw.outputs.sg_ssh_id + vpc_id = dependency.nw.outputs.vpc_id + aws_lb_target_groups = dependency.nw.outputs.aws_lb_target_groups + public_subnet_ids = dependency.nw.outputs.public_subnet_ids + // Take public_subnet_ids from the output of the nw root (Ex: ["subnet-053a640b55610b633"]) and merge into each of the SUTs attributes currently null public_subnet_ids. + suts_attributes = { + for sut_key, sut_val in local.common_vars.suts_attributes: + sut_key => merge(sut_val, {public_subnet_ids = dependency.nw.outputs.public_subnet_ids}) + } +} + +terraform { + after_hook "delete_left_over_log_groups" { + commands = ["destroy"] + execute = ["bash", "./deleteLeftOverLogGroups.sh", "${get_terragrunt_dir()}/${find_in_parent_folders(".env")}"] + run_on_error = true + } +} + +# redirects stderr (2) into stdout (1), then pipes stdout into tee, which copies it to the terminal and to the log file. +# terragrunt apply -no-color 2>&1 | tee out + diff --git a/tf/roots/4_api/terragrunt.hcl b/tf/roots/4_api/terragrunt.hcl new file mode 100644 index 0000000..7853871 --- /dev/null +++ b/tf/roots/4_api/terragrunt.hcl @@ -0,0 +1,26 @@ +// Doc: [Configuration Parsing Order](https://terragrunt.gruntwork.io/docs/getting-started/configuration/#configuration-parsing-order) + +include { + path = find_in_parent_folders() +} + +locals { + common_vars = yamldecode(file("${get_terragrunt_dir()}/${find_in_parent_folders("common_vars.yaml")}")) + // More locals here ... +} + + + +inputs = { + +} + + +terraform { + // https://github.com/terraform-providers/terraform-provider-aws/issues/3174#issuecomment-383718440 + extra_arguments "concurrency_issues_in_api_gateway" { + commands = ["apply", "destroy"] + arguments = ["-parallelism=5"] + } +} +