Skip to content

Commit

Permalink
Wired up roots with terragrunt hcl's
Browse files Browse the repository at this point in the history
  • Loading branch information
binarymist committed Aug 13, 2020
1 parent 507e649 commit a77549c
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ terragrunt.hcl
common_vars.yaml
remote-state.tf

destroyCleanup.sh
!tf/roots/*/terragrunt.hcl

graph.svg

19 changes: 19 additions & 0 deletions tf/roots/1_static/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -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 {

}

20 changes: 20 additions & 0 deletions tf/roots/2_nw/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -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 {

}

49 changes: 49 additions & 0 deletions tf/roots/3_contOrc/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -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

26 changes: 26 additions & 0 deletions tf/roots/4_api/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -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"]
}
}

0 comments on commit a77549c

Please sign in to comment.