terragrunt.hcl 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-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.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_regional?ref=v0.5.3"
  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. version = "~> 2.66"
  32. region = "${local.target_aws_region}"
  33. assume_role {
  34. role_arn = "arn:${local.aws_partition}:iam::${local.account_id}:role/user/mdr_terraformer"
  35. session_name = "terraform"
  36. }
  37. profile = "${local.common_profile}"
  38. # Only these AWS Account IDs may be operated on by this template
  39. allowed_account_ids = ["${local.account_id}"]
  40. }
  41. EOF
  42. }
  43. # These are the variables we have to pass in to use the module specified in the terragrunt source above
  44. inputs = {
  45. # All of the inputs from the inherited hcl files are available automatically
  46. # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
  47. # will be more flexible if you specify particular input values.
  48. tags = {
  49. Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
  50. }
  51. }