terragrunt.hcl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. locals {
  2. # If you want to use any of the variables in _this_ file, you have to load them here.
  3. # However, they will all be available as inputs to the module loaded in terraform.source
  4. # below.
  5. environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
  6. partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
  7. region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
  8. account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
  9. global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
  10. # Extract the variables we need for easy access
  11. account_name = local.account_vars.locals.account_name
  12. account_id = local.account_vars.locals.aws_account_id
  13. aws_region = local.region_vars.locals.aws_region
  14. aws_partition = local.partition_vars.locals.aws_partition
  15. common_services_account = local.partition_vars.locals.common_services_account
  16. legacy_account = local.environment_vars.locals.legacy_account
  17. tfstate_region = local.partition_vars.locals.tfstate_region
  18. common_profile = local.partition_vars.locals.common_profile
  19. }
  20. # Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
  21. # working directory, into a temporary folder, and execute your Terraform commands in that folder.
  22. terraform {
  23. # Double slash is intentional and required to show root of modules
  24. source = "git@github.xdr.accenturefederalcyber.com:mdr-engineering/xdr-terraform-modules.git//base/codebuild_splunk_apps?ref=v4.0.13"
  25. }
  26. # ---------------------------------------------------------------------------------------------------------------------
  27. # Generate an AWS provider block
  28. # Temp fix to backlevel provider because of codebuild issue
  29. # <insert github link here to provider issue>
  30. # ---------------------------------------------------------------------------------------------------------------------
  31. generate "provider" {
  32. path = "provider.tf"
  33. if_exists = "overwrite_terragrunt"
  34. contents = <<EOF
  35. provider "template" {
  36. }
  37. provider "aws" {
  38. region = "${local.aws_region}"
  39. assume_role {
  40. role_arn = "arn:${local.aws_partition}:iam::${local.account_id}:role/user/mdr_terraformer"
  41. session_name = "terraform-default"
  42. }
  43. profile = "${local.common_profile}"
  44. # Only these AWS Account IDs may be operated on by this template
  45. allowed_account_ids = ["${local.account_id}"]
  46. }
  47. # The "common" provider in the respective partition is always available
  48. provider "aws" {
  49. region = "${local.aws_region}"
  50. allowed_account_ids = [ "471284459109", "701290387780" ]
  51. profile = "${local.common_profile}"
  52. alias = "common"
  53. assume_role {
  54. role_arn = "arn:${local.aws_partition}:iam::${local.common_services_account}:role/user/mdr_terraformer"
  55. session_name = "terraform-common"
  56. }
  57. }
  58. # The "mdr-common-services-commercial" provider is used for public DNS entries
  59. provider "aws" {
  60. region = "us-east-1"
  61. allowed_account_ids = [ "471284459109" ]
  62. profile = "commercial"
  63. alias = "mdr-common-services-commercial"
  64. assume_role {
  65. role_arn = "arn:aws:iam::471284459109:role/user/mdr_terraformer"
  66. session_name = "terraform-mdr-common-services-commercial"
  67. }
  68. }
  69. # The "C2" provider, used for private DNS
  70. provider "aws" {
  71. region = "us-gov-east-1"
  72. allowed_account_ids = [ "721817724804", "738800754746" ]
  73. profile = "govcloud"
  74. alias = "c2"
  75. #use_fips_endpoint = true
  76. assume_role {
  77. role_arn = "arn:aws-us-gov:iam::${ local.environment_vars.locals.c2_accounts["aws-us-gov"] }:role/user/mdr_terraformer"
  78. session_name = "terraform-c2"
  79. }
  80. }
  81. EOF
  82. }
  83. #Github specific provider
  84. generate "required_providers" {
  85. path = "required_provider.tf"
  86. if_exists = "overwrite_terragrunt"
  87. contents = <<EOF
  88. terraform {
  89. required_providers {
  90. aws = {
  91. source = "hashicorp/aws"
  92. version = "= 3.63.0" # 2022-03-08: upgrade from 3.63.0; 2021-09-21: upgrade from 3.37.0
  93. }
  94. vault = {
  95. source = "hashicorp/vault"
  96. version = "= 2.19.1" # 2021-04-29: upgrade from 2.18.0
  97. }
  98. sensu = {
  99. source = "jtopjian/sensu"
  100. version = "= 0.10.5"
  101. }
  102. github = {
  103. source = "integrations/github"
  104. version = "4.2.0"
  105. }
  106. }
  107. }
  108. EOF
  109. }
  110. generate "github-provider" {
  111. path = "github-provider.tf"
  112. if_exists = "overwrite_terragrunt"
  113. contents = <<EOF
  114. provider "github" {
  115. organization = "content-delivery"
  116. base_url = "https://github.xdr.accenturefederalcyber.com/"
  117. }
  118. EOF
  119. }
  120. # Include all settings from the root terragrunt.hcl file
  121. include {
  122. path = find_in_parent_folders()
  123. }
  124. # These are the variables we have to pass in to use the module specified in the terragrunt source above
  125. inputs = {
  126. # All of the inputs from the inherited hcl files are available automatically
  127. # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
  128. # will be more flexible if you specify particular input values.
  129. tags = {
  130. Purpose = "Build Splunk Apps and place in bucket"
  131. Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
  132. }
  133. source_version = "develop"
  134. enable_webhooks = false
  135. }
  136. terraform_version_constraint = "= 1.1.6"
  137. terragrunt_version_constraint = "= 0.36.2"