terragrunt.hcl 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. aws_partition = local.partition_vars.locals.aws_partition
  11. account_id = local.account_vars.locals.aws_account_id
  12. common_profile = local.partition_vars.locals.common_profile
  13. target_aws_region = "us-gov-west-1"
  14. }
  15. # Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
  16. # working directory, into a temporary folder, and execute your Terraform commands in that folder.
  17. terraform {
  18. # Double slash is intentional and required to show root of modules
  19. source = "git@github.xdr.accenturefederalcyber.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_regional?ref=v5.0.0"
  20. }
  21. # Include all settings from the root terragrunt.hcl file
  22. include {
  23. path = find_in_parent_folders()
  24. }
  25. ############# Custom provider for the region
  26. generate "provider" {
  27. path = "provider.tf"
  28. if_exists = "overwrite_terragrunt"
  29. contents = <<EOF
  30. provider "aws" {
  31. region = "${local.target_aws_region}"
  32. assume_role {
  33. role_arn = "arn:${local.aws_partition}:iam::${local.account_id}:role/user/mdr_terraformer"
  34. session_name = "terraform"
  35. }
  36. profile = "${local.common_profile}"
  37. # Only these AWS Account IDs may be operated on by this template
  38. allowed_account_ids = ["${local.account_id}"]
  39. }
  40. EOF
  41. }
  42. # These are the variables we have to pass in to use the module specified in the terragrunt source above
  43. inputs = {
  44. # All of the inputs from the inherited hcl files are available automatically
  45. # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
  46. # will be more flexible if you specify particular input values.
  47. tags = {
  48. Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
  49. }
  50. }
  51. terraform_version_constraint = "= 1.1.6"
  52. terragrunt_version_constraint = "= 0.36.2"