Kaynağa Gözat

Merge pull request #28 from mdr-engineering/feature/ftd_MSOCI-1314_CIS_Hardening_Spreading_Around

Spreading the account standards around.
Frederick Damstra 5 yıl önce
ebeveyn
işleme
7f84a835ae
68 değiştirilmiş dosya ile 525 ekleme ve 88 silme
  1. 1 0
      .gitignore
  2. 1 1
      000-skeleton/005-iam/terragrunt.hcl
  3. 61 0
      000-skeleton/006-account-standards-regional/us-gov-west-1/terragrunt.hcl
  4. 8 0
      000-skeleton/006-account-standards/README.md
  5. 10 9
      000-skeleton/006-account-standards/terragrunt.hcl
  6. 1 1
      000-skeleton/010-standard-vpc/terragrunt.hcl
  7. 1 1
      000-skeleton/020-attach-transit-gateway-to-standard-vpc/terragrunt.hcl
  8. 1 1
      000-skeleton/025-test-instance/terragrunt.hcl
  9. 1 0
      000-skeleton/account.hcl
  10. 7 2
      README.md
  11. 4 2
      bin/terragrunt-apply-all
  12. 103 0
      bin/update_refs
  13. 1 1
      common/aws-us-gov/afs-mdr-common-services-gov/015-security-vpc/terragrunt.hcl
  14. 1 1
      common/aws/mdr-common-services/015-security-vpc/terragrunt.hcl
  15. 6 0
      common/aws/partition.hcl
  16. 6 0
      globals.hcl
  17. 4 4
      terragrunt.hcl
  18. 1 1
      test/aws-us-gov/mdr-test-c2/005-account-standards-c2/terragrunt.hcl
  19. 1 1
      test/aws-us-gov/mdr-test-c2/005-iam/terragrunt.hcl
  20. 1 1
      test/aws-us-gov/mdr-test-c2/006-account-standards-regional/us-gov-west-1/terragrunt.hcl
  21. 1 1
      test/aws-us-gov/mdr-test-c2/006-account-standards/terragrunt.hcl
  22. 1 1
      test/aws-us-gov/mdr-test-c2/008-transit-gateway-hub/terragrunt.hcl
  23. 1 1
      test/aws-us-gov/mdr-test-c2/010-standard-vpc/terragrunt.hcl
  24. 1 1
      test/aws-us-gov/mdr-test-c2/015-security-vpc/terragrunt.hcl
  25. 1 1
      test/aws-us-gov/mdr-test-c2/018-interconnect-instances/terragrunt.hcl
  26. 1 1
      test/aws-us-gov/mdr-test-c2/019-attach-transit-gateway-to-hub-account/terragrunt.hcl
  27. 1 1
      test/aws-us-gov/mdr-test-c2/020-transit-gateway-interconnect-vpn/terragrunt.hcl
  28. 1 1
      test/aws-us-gov/mdr-test-c2/025-test-instance/terragrunt.hcl
  29. 1 1
      test/aws-us-gov/mdr-test-malware/005-iam/terragrunt.hcl
  30. 1 1
      test/aws-us-gov/mdr-test-malware/006-account-standards/terragrunt.hcl
  31. 1 1
      test/aws-us-gov/mdr-test-malware/010-standard-vpc/terragrunt.hcl
  32. 1 1
      test/aws-us-gov/mdr-test-malware/020-attach-transit-gateway-to-standard-vpc/terragrunt.hcl
  33. 1 1
      test/aws-us-gov/mdr-test-malware/025-test-instance/terragrunt.hcl
  34. 1 1
      test/aws-us-gov/mdr-test-malware/044-VMRay-Instances/terragrunt.hcl
  35. 1 1
      test/aws-us-gov/mdr-test-modelclient/005-iam/terragrunt.hcl
  36. 1 1
      test/aws-us-gov/mdr-test-modelclient/006-account-standards/terragrunt.hcl
  37. 1 1
      test/aws-us-gov/mdr-test-modelclient/010-standard-vpc/terragrunt.hcl
  38. 1 1
      test/aws-us-gov/mdr-test-modelclient/020-attach-transit-gateway-to-standard-vpc/terragrunt.hcl
  39. 1 1
      test/aws-us-gov/mdr-test-modelclient/025-test-instance/terragrunt.hcl
  40. 1 1
      test/aws/legacy-mdr-test/005-iam/terragrunt.hcl
  41. 11 0
      test/aws/legacy-mdr-test/006-account-standards/README.md
  42. 38 0
      test/aws/legacy-mdr-test/006-account-standards/terragrunt.hcl
  43. 1 1
      test/aws/legacy-mdr-test/021-attach-transit-gateway-to-legacy-main_infrastructure/terragrunt.hcl
  44. 1 1
      test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-afs/terragrunt.hcl
  45. 1 1
      test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-customer-portal/terragrunt.hcl
  46. 1 1
      test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-dc-c19/terragrunt.hcl
  47. 1 1
      test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-la-c19/terragrunt.hcl
  48. 1 1
      test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-ma-c19/terragrunt.hcl
  49. 30 1
      test/aws/legacy-mdr-test/account.hcl
  50. 3 0
      test/aws/mdr-test-c2/005-account-standards-c2/README.md
  51. 34 0
      test/aws/mdr-test-c2/005-account-standards-c2/terragrunt.hcl
  52. 4 1
      test/aws/mdr-test-c2/005-iam/terragrunt.hcl
  53. 61 0
      test/aws/mdr-test-c2/006-account-standards-regional/us-west-1/terragrunt.hcl
  54. 13 15
      test/aws/mdr-test-c2/006-account-standards/terragrunt.hcl
  55. 1 1
      test/aws/mdr-test-c2/008-transit-gateway-hub/terragrunt.hcl
  56. 2 2
      test/aws/mdr-test-c2/010-standard-vpc/terragrunt.hcl
  57. 1 1
      test/aws/mdr-test-c2/019-attach-transit-gateway-to-hub-account/terragrunt.hcl
  58. 1 1
      test/aws/mdr-test-c2/020-transit-gateway-interconnect-vpn/terragrunt.hcl
  59. 1 1
      test/aws/mdr-test-c2/025-test-instance/terragrunt.hcl
  60. 1 0
      test/aws/mdr-test-c2/account.hcl
  61. 2 0
      test/aws/mdr-test-malware/account.hcl
  62. 1 1
      test/aws/mdr-test-modelclient/005-iam/terragrunt.hcl
  63. 61 0
      test/aws/mdr-test-modelclient/006-account-standards-regional/us-west-1/terragrunt.hcl
  64. 10 9
      test/aws/mdr-test-modelclient/006-account-standards/terragrunt.hcl
  65. 1 1
      test/aws/mdr-test-modelclient/010-standard-vpc/terragrunt.hcl
  66. 1 1
      test/aws/mdr-test-modelclient/020-attach-transit-gateway-to-standard-vpc/terragrunt.hcl
  67. 1 1
      test/aws/mdr-test-modelclient/025-test-instance/terragrunt.hcl
  68. 1 0
      test/aws/mdr-test-modelclient/account.hcl

+ 1 - 0
.gitignore

@@ -4,6 +4,7 @@
 *.rpm
 salt/splunk/deployment_server/files/*
 salt/splunk/master/files/*
+*.bak
 
 # Created by https://www.gitignore.io/api/macos,splunk,terraform,visualstudiocode
 # Edit at https://www.gitignore.io/?templates=macos,splunk,terraform,visualstudiocode

+ 1 - 1
000-skeleton/005-iam/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 61 - 0
000-skeleton/006-account-standards-regional/us-gov-west-1/terragrunt.hcl

@@ -0,0 +1,61 @@
+locals {
+  # If you want to use any of the variables in _this_ file, you have to load them here.
+  # However, they will all be available as inputs to the module loaded in terraform.source
+  # below.
+
+  environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+  partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
+  region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+  account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
+  global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
+
+  aws_partition  = local.partition_vars.locals.aws_partition
+  account_id     = local.account_vars.locals.aws_account_id
+  common_profile = local.partition_vars.locals.common_profile
+
+  target_aws_region = "us-gov-west-1"
+}
+
+# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
+# working directory, into a temporary folder, and execute your Terraform commands in that folder.
+terraform {
+  # Double slash is intentional and required to show root of modules
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_regional?ref=v0.5.1"
+}
+
+# Include all settings from the root terragrunt.hcl file
+include {
+  path = find_in_parent_folders()
+}
+
+############# Custom provider for the region
+generate "provider" {
+  path      = "provider.tf"
+  if_exists = "overwrite_terragrunt"
+  contents  = <<EOF
+provider "aws" {
+  version = "~> 2.66"
+  region = "${local.target_aws_region}"
+
+  assume_role {
+    role_arn = "arn:${local.aws_partition}:iam::${local.account_id}:role/user/mdr_terraformer"
+    session_name = "terraform"
+  }
+
+  profile = "${local.common_profile}"
+
+  # Only these AWS Account IDs may be operated on by this template
+  allowed_account_ids = ["${local.account_id}"]
+}
+EOF
+}
+
+# These are the variables we have to pass in to use the module specified in the terragrunt source above
+inputs = {
+  # All of the inputs from the inherited hcl files are available automatically
+  # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
+  # will be more flexible if you specify particular input values.
+  tags = {
+    Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
+  }
+}

+ 8 - 0
000-skeleton/006-account-standards/README.md

@@ -1,3 +1,11 @@
 # Account Standards
 
 Creates elements that are standard in all accounts, such as access keys, kms keys, etc.
+
+NOTE: For commercial accounts, camrs may have set up AWS config already, though in a configuration where they don't appear to be able to use it. This will conflict with the AWS Config setup present in this module. To fix this, the existing recorder must be imported. In the module directory, run (this will only need to be done once per account):
+```
+terragrunt import aws_config_configuration_recorder.awsconfig_recorder default
+aws --profile <account-profile> configservice describe-delivery-channels
+terragrunt import aws_config_delivery_channel.awsconfig_delivery_channel camrs-rt-aws-mdr-14019-tstsc-config-rDeliveryChannel-3JUH8QIHEQE6
+```
+

+ 10 - 9
000-skeleton/006-account-standards/terragrunt.hcl

@@ -3,22 +3,22 @@ locals {
   # However, they will all be available as inputs to the module loaded in terraform.source
   # below.
 
-  # e.g. inherited variables:
-  #environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
-  #partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
-  #region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+  environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+  partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
+  region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
   account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
-  #global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
-
-  # Extract out common variables for reuse
-  #env = local.environment_vars.locals.environment
+  global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
 }
 
 # Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.1"
+}
+
+dependency "c2_account_standards" {
+  config_path = local.account_vars.locals.c2_account_standards_path
 }
 
 # Include all settings from the root terragrunt.hcl file
@@ -34,4 +34,5 @@ inputs = {
   tags = {
     Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
   }
+  cloudtrail_key_arn = dependency.c2_account_standards.outputs.cloudtrail_logging_bucket.kms_key_id
 }

+ 1 - 1
000-skeleton/010-standard-vpc/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
000-skeleton/020-attach-transit-gateway-to-standard-vpc/terragrunt.hcl

@@ -24,7 +24,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
000-skeleton/025-test-instance/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 0
000-skeleton/account.hcl

@@ -8,6 +8,7 @@ locals {
   instance_termination_protection = TODO # set to true for production!
   
   account_tags = { } 
+  c2_account_standards_path = "../../mdr-TODO-c2/005-account-standards-c2"
 
   # For CIDR assignment, see https://github.mdr.defpoint.com/mdr-engineering/msoc-infrastructure/wiki/IP-Address-Allocation
   standard_vpc_cidr = "TODO/TODO"

+ 7 - 2
README.md

@@ -2,7 +2,7 @@
 
 Live configurations of the environments.
 
-# Testing Locally
+## Testing Locally
 
 To test locally:
 1) Make sure a copy of the `xdr-terraform-modules` directory is at the same level as this repository.
@@ -15,5 +15,10 @@ cd test/aws-us-gov/mdr-test-malware/006-account-standards
 ~/xdr-terraform-live/bin/terragrunt-local plan
 ```
 
-(Helpful tip: Create a symbolic link from `bin/terragrunt-local` to something in your path)
+(Helpful tip: Create a symbolic link from `bin/` to something in your path)
 
+## Deploying a New Account
+
+1. Copy `000-skeleton` into the directory structure.
+2. Edit `account.hcl` and update the `TODO` items.
+3. Modify the `*-regional` modules to be appopriate for the regions in the current environment.

+ 4 - 2
bin/terragrunt-apply-all

@@ -103,14 +103,16 @@ for i in `seq -f "%g*" 0 9 | sort -n`; do
           pushd . > /dev/null
           cd $i
           [[ $TESTING ]] && ${TERRAGRUNT_BIN} plan  # Run a plan if testing
-          [[ $TESTING ]] || ${TERRAGRUNT_BIN} apply # Run an apply otherwise
+          [[ $TESTING ]] || ${TERRAGRUNT_BIN} init  # Run an init and apply
+          [[ $TESTING ]] || ${TERRAGRUNT_BIN} apply
           popd > /dev/null
           echo "========== Region completed: $i"
         fi
       done
     else
       [[ $TESTING ]] && ${TERRAGRUNT_BIN} plan  # Run a plan if testing
-      [[ $TESTING ]] || ${TERRAGRUNT_BIN} apply # Run an apply otherwise
+      [[ $TESTING ]] || ${TERRAGRUNT_BIN} init  # Run an init and apply otherwise
+      [[ $TESTING ]] || ${TERRAGRUNT_BIN} apply
     fi
     popd > /dev/null
     echo "=======================================DONE=========================================="

+ 103 - 0
bin/update_refs

@@ -0,0 +1,103 @@
+#! /bin/bash
+# 
+# Run from an account directory to update all the child directory's references.
+# This should be run before or after `terragrunt-local`
+
+function argparse {
+  PARAMS=""
+  while (( "$#" )); do
+    case "$1" in
+      -n|--newtag)
+        if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+          NEWTAG=$2
+          shift 2
+        else
+          echo "Error: Argument for $1 is missing" >&2
+          exit 1
+        fi
+        ;;
+      -h|--help)
+        echo Usage: $0 '[-t|--test] [-d|--debug] -n|--newtag NEWTAG'
+        exit 0
+        ;;
+      -t|--test)
+        TESTING="/bin/echo TESTING: "
+        shift
+        ;;
+      -d|--debug)
+        >&2 echo debug: Enabling debugging..
+        DEBUG=1
+        shift
+        ;;
+#      -p|--only-path)
+#        if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+#          ONLY_PATH=$2
+#          shift 2
+#        else
+#          echo "Error: Argument for $1 is missing" >&2
+#          exit 1
+#        fi
+#        ;;
+      -*|--*=) # unsupported flags
+        echo "Error: Unsupported flag $1" >&2
+        exit 1
+        ;;
+      *) # preserve positional arguments
+        PARAMS="$PARAMS $1"
+        shift
+        ;;
+    esac
+  done
+  # set positional arguments in their proper place
+  eval set -- "$PARAMS"
+}
+
+# Main
+argparse $*
+
+SHORT_PWD=$( basename ${PWD}  )
+PARENT_PWD=$( basename $( cd .. && pwd ) )
+[[ $DEBUG == 1 ]] && >&2 echo debug: PWD=$PWD
+[[ $DEBUG == 1 ]] && >&2 echo debug: SHORT_PWD=$SHORT_PWD
+
+# Sanity Checking
+if [[ "$NEWTAG" == "" ]]; then
+  >&2 echo Error: Parameter \'--newtag\' is required.
+  exit 5
+fi
+
+if [[ $SHORT_PWD =~ ^[0-9]{3}-.* ]]; then
+  if [[ $SHORT_PWD == "000-skeleton" ]]; then
+    read -p "Are you sure you wish to update the SKELETON directory [y/N]? " -n 1 -r
+    echo ""
+    if [[ $REPLY =~ ^[Yy]$ ]]
+    then
+      echo Continuing...
+    else
+      echo Exiting...
+      exit 10
+    fi
+  else
+    >&2 echo Error: We appear to be in a module directory. Please run from the account directory you wish to update. Exiting...
+    exit 2
+  fi
+fi
+
+if [[ -f UNUSED.ACCOUNT ]]; then
+  >&2 echo Error: This account is marked as unused. Failing...
+  exit 4
+fi
+
+if [[ $NEWTAG =~ v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+  [[ $TESTING ]] && >&2 echo debug: Newtag $NEWTAG is valid format.
+else
+  >&2 echo Error: Invalid format for new tag. \"$NEWTAG\" must be of format v1.2.3
+  exit 6
+fi
+
+for i in `find . -maxdepth 2 -name "terragrunt.hcl"`; do
+  echo ======= Processing $i
+  ${TESTING} sed -E -i .bak 's/ref=v[0-9]+.[0-9]+\.[0-9]+"$/ref='${NEWTAG}'"/' $i
+done
+
+

+ 1 - 1
common/aws-us-gov/afs-mdr-common-services-gov/015-security-vpc/terragrunt.hcl

@@ -13,7 +13,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/palo_alto/security_vpc?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/security_vpc?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
common/aws/mdr-common-services/015-security-vpc/terragrunt.hcl

@@ -13,7 +13,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/palo_alto/security_vpc?ref=v0.3.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/security_vpc?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 6 - 0
common/aws/partition.hcl

@@ -44,6 +44,12 @@ locals {
   account_list = flatten([
     for env, accounts in local.account_map: accounts
   ])
+  # This is similar to the account_map, but used for "what accounts am I responsible for"?
+  responsible_accounts = {
+    "prod"   = concat(local.account_map["prod"], local.account_map["common"]),
+    "test"   = local.account_map["test"],
+    "common" = concat(local.account_map["prod"], local.account_map["common"], local.account_map["test"]),
+  }
 
   aws_marketplace_ubuntu_owner_id = "679593333241"
 

+ 6 - 0
globals.hcl

@@ -33,4 +33,10 @@ locals {
     "msoc-build" = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDv8N5N/ECQNKdqZKmjQqGkPiAtJc3WmWdpcZmhxUfplGRFW0IlHGH/wPUgkXXg+djWNpMyT+bqWI8B4Q18uw0Y+w09lN+F1t/vp2GNPYyIPHTGbr2u/r5RCuPXc5Gg6ogkneyAipPCPAhBRbvPaFtfLSJ94ba01LoFs4xgCIZXetr/3ql61OlLyB8vb8FohpW/7u32zzOVJwObA+QlDrRgivaYpwNBxd+No9HEz29dUVFMsKb3ko0GpBuu4pptbj73XxP0EeodMj0hee0FH4kEkZy80LVbg2WeTsq6Mi/FRZmeGt5f3oZEcfflGqYOPA4FmhTrc9O9pp36DDOGts79TeZ6abky+a0jRJQvaeN8x8DZ6PQXfVGpOrNst5zw0Z9EP3ZrFAkX6CYfZkckq0h5Fs+rcWLeUfM/ppZqcyNBDys7zxjFNdmWk86pgn+XvdCVIlsp99B6CzgDoAJkay09ROVqh39HTK7m2aKZoyFWZvUpaqUOlLkOb47bMQzIBSp8Yaoo4PozSg0lQOzkJl3JTR0OZksbeN0pFKY4qNcUcpgUU5mVYs5SXWAOsih51kC5s+0F6Uxt+iDjT9ASaF1O+Bl46UnhpwrtN4ckpHsFnp58mdfhJCUMjt6PX+UPxjRlSL21EkjGALybG2C0gPuoGo0x5bEsZl/gFrFJ+3r6gQ== MSOC Build Key",
     "fdamstra" = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDF3pGU9+HufgfEhPP7P0Lt7kqfGWLTGd6sfJgSypcSo3FP1XhwFOWkaNvZIpoIeQXhux5vTm+RoqYZ/3Gj7hcGMLdoHWArvLHD2AGjxbFnsmiCioQgsC/rYLBjiWNsDdVF5Arofby/RwzivMAi7yivhY4nGzXPsHZoucB0Wi34/9AmxbvXWv6ckuWkMjrXVe+uwFje3U7jQHRW9jQRpCRRfUjVA4FmH0PWqWFBlt/zqsDPOzbxNNhAvyrJho7jVBNjCLsq0++lT8BDKrYbaZiT0F2c9uIDRpHJSdjpqVCf9bghmeJWYMoNHAkGR7WCFjPCJ7QM57a2oRBtm1A/EWcr",
   }
+
+  # Some sane defaults we don't want to specify everywhere
+  is_legacy = false # By default, accounts are not legacy accounts
+  extra_ebs_key_admins = [ ]
+  extra_ebs_key_users  = [ ]
+  extra_ebs_key_attachers = [ ]
 }

+ 4 - 4
terragrunt.hcl

@@ -133,11 +133,11 @@ remote_state {
 # Configure root level variables that all resources can inherit. This is especially helpful with multi-account configs
 # where terraform_remote_state data sources are placed directly into the modules.
 inputs = merge(
-  local.account_vars.locals,
-  local.region_vars.locals,
-  local.partition_vars.locals,
-  local.environment_vars.locals,
   local.global_vars.locals,
+  local.environment_vars.locals,
+  local.partition_vars.locals,
+  local.region_vars.locals,
+  local.account_vars.locals,
   { # Variables created in this file that we want to pass through
     standard_tags = local.standard_tags
   }

+ 1 - 1
test/aws-us-gov/mdr-test-c2/005-account-standards-c2/terragrunt.hcl

@@ -15,7 +15,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_c2?ref=v0.5.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_c2?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-c2/005-iam/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-c2/006-account-standards-regional/us-gov-west-1/terragrunt.hcl

@@ -20,7 +20,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_regional?ref=v0.5.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_regional?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-c2/006-account-standards/terragrunt.hcl

@@ -14,7 +14,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.1"
 }
 
 dependency "c2_account_standards" {

+ 1 - 1
test/aws-us-gov/mdr-test-c2/008-transit-gateway-hub/terragrunt.hcl

@@ -15,7 +15,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_hub?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_hub?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-c2/010-standard-vpc/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-c2/015-security-vpc/terragrunt.hcl

@@ -13,7 +13,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/palo_alto/security_vpc?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/security_vpc?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-c2/018-interconnect-instances/terragrunt.hcl

@@ -13,7 +13,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/interconnects?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/interconnects?ref=v0.5.1"
 }
 
 dependency "security_vpc" {

+ 1 - 1
test/aws-us-gov/mdr-test-c2/019-attach-transit-gateway-to-hub-account/terragrunt.hcl

@@ -24,7 +24,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-c2/020-transit-gateway-interconnect-vpn/terragrunt.hcl

@@ -8,7 +8,7 @@ locals {
 
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_interconnect_vpn?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_interconnect_vpn?ref=v0.5.1"
 }
 
 dependency "transit-gateway-hub" {

+ 1 - 1
test/aws-us-gov/mdr-test-c2/025-test-instance/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-malware/005-iam/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-malware/006-account-standards/terragrunt.hcl

@@ -14,7 +14,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.1"
 }
 
 dependency "c2_account_standards" {

+ 1 - 1
test/aws-us-gov/mdr-test-malware/010-standard-vpc/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-malware/020-attach-transit-gateway-to-standard-vpc/terragrunt.hcl

@@ -24,7 +24,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-malware/025-test-instance/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-malware/044-VMRay-Instances/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/vmray_instances?ref=v0.3.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/vmray_instances?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-modelclient/005-iam/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-modelclient/006-account-standards/terragrunt.hcl

@@ -14,7 +14,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.1"
 }
 
 dependency "c2_account_standards" {

+ 1 - 1
test/aws-us-gov/mdr-test-modelclient/010-standard-vpc/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-modelclient/020-attach-transit-gateway-to-standard-vpc/terragrunt.hcl

@@ -24,7 +24,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws-us-gov/mdr-test-modelclient/025-test-instance/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws/legacy-mdr-test/005-iam/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.2.1"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 11 - 0
test/aws/legacy-mdr-test/006-account-standards/README.md

@@ -0,0 +1,11 @@
+# Account Standards
+
+Creates elements that are standard in all accounts, such as access keys, kms keys, etc.
+
+NOTE: For commercial accounts, camrs may have set up AWS config already, though in a configuration where they don't appear to be able to use it. This will conflict with the AWS Config setup present in this module. To fix this, the existing recorder must be imported. In the module directory, run (this will only need to be done once per account):
+```
+terragrunt import aws_config_configuration_recorder.awsconfig_recorder default
+aws --profile <account-profile> configservice describe-delivery-channels
+terragrunt import aws_config_delivery_channel.awsconfig_delivery_channel camrs-rt-aws-mdr-14019-tstsc-config-rDeliveryChannel-3JUH8QIHEQE6
+```
+

+ 38 - 0
test/aws/legacy-mdr-test/006-account-standards/terragrunt.hcl

@@ -0,0 +1,38 @@
+locals {
+  # If you want to use any of the variables in _this_ file, you have to load them here.
+  # However, they will all be available as inputs to the module loaded in terraform.source
+  # below.
+
+  environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+  partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
+  region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+  account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
+  global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
+}
+
+# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
+# working directory, into a temporary folder, and execute your Terraform commands in that folder.
+terraform {
+  # Double slash is intentional and required to show root of modules
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.1"
+}
+
+dependency "c2_account_standards" {
+  config_path = local.account_vars.locals.c2_account_standards_path
+}
+
+# Include all settings from the root terragrunt.hcl file
+include {
+  path = find_in_parent_folders()
+}
+
+# These are the variables we have to pass in to use the module specified in the terragrunt source above
+inputs = {
+  # All of the inputs from the inherited hcl files are available automatically
+  # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
+  # will be more flexible if you specify particular input values.
+  tags = {
+    Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
+  }
+  cloudtrail_key_arn = dependency.c2_account_standards.outputs.cloudtrail_logging_bucket.kms_key_id
+}

+ 1 - 1
test/aws/legacy-mdr-test/021-attach-transit-gateway-to-legacy-main_infrastructure/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "transit_gateway" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.1"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-afs/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "transit_gateway" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.1"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-customer-portal/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "transit_gateway" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.1"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-dc-c19/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "transit_gateway" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.1"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-la-c19/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "transit_gateway" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.1"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws/legacy-mdr-test/022-attach-transit-gateway-to-legacy-ma-c19/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "transit_gateway" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.1"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 30 - 1
test/aws/legacy-mdr-test/account.hcl

@@ -1,12 +1,41 @@
 # Set account-wide variables. These are automatically pulled in to configure the remote state bucket in the root
 # terragrunt.hcl configuration.
 locals {
-  # TODO put the right values here
   account_name   = "legacy-mdr-test"
   account_alias  = "" # No alias for legacy
   aws_account_id = "527700175026"
+  instance_termination_protection = true # set to true for production!
   
   account_tags = { } 
+  c2_account_standards_path = "../../mdr-test-c2/005-account-standards-c2"
+
+  # For CIDR assignment, see https://github.mdr.defpoint.com/mdr-engineering/msoc-infrastructure/wiki/IP-Address-Allocation
+  standard_vpc_cidr = "TODO"
+
+  # For testing
+  create_test_instance = false
+  test_instance_key_name = "TODO" # They with which to provision the test instance
+
+  # Legacy accounts have some extra key users
+  is_legacy = true
+  extra_ebs_key_admins = [ 
+    "arn:aws:iam::527700175026:root",
+    "arn:aws:iam::527700175026:role/mdr_iam_admins",
+    "arn:aws:iam::527700175026:role/mdr_powerusers"
+  ]
+  extra_ebs_key_users  = [ 
+    "arn:aws:iam::527700175026:role/mdr_powerusers",
+    "arn:aws:iam::527700175026:role/msoc-default-instance-role",
+    "arn:aws:iam::527700175026:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling",
+    "arn:aws:iam::527700175026:role/portal-instance-role",
+    "arn:aws:iam::527700175026:role/mdr_iam_admins"
+  ]
+  extra_ebs_key_attachers = [
+    "arn:aws:iam::527700175026:role/mdr_powerusers",
+    "arn:aws:iam::527700175026:role/msoc-default-instance-role",
+    "arn:aws:iam::527700175026:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling",
+    "arn:aws:iam::527700175026:role/portal-instance-role",
+  ] 
 
   # Legacy information
   legacy_vpcs = {

+ 3 - 0
test/aws/mdr-test-c2/005-account-standards-c2/README.md

@@ -0,0 +1,3 @@
+# Account Standards
+
+Creates elements that are standard in all accounts, such as access keys, kms keys, etc.

+ 34 - 0
test/aws/mdr-test-c2/005-account-standards-c2/terragrunt.hcl

@@ -0,0 +1,34 @@
+locals {
+  # If you want to use any of the variables in _this_ file, you have to load them here.
+  # However, they will all be available as inputs to the module loaded in terraform.source
+  # below.
+
+  # e.g. inherited variables:
+  environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+  partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
+  region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+  account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
+  global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
+}
+
+# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
+# working directory, into a temporary folder, and execute your Terraform commands in that folder.
+terraform {
+  # Double slash is intentional and required to show root of modules
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_c2?ref=v0.5.1"
+}
+
+# Include all settings from the root terragrunt.hcl file
+include {
+  path = find_in_parent_folders()
+}
+
+# These are the variables we have to pass in to use the module specified in the terragrunt source above
+inputs = {
+  # All of the inputs from the inherited hcl files are available automatically
+  # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
+  # will be more flexible if you specify particular input values.
+  tags = {
+    Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
+  }
+}

+ 4 - 1
test/aws/mdr-test-c2/005-iam/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file
@@ -31,4 +31,7 @@ inputs = {
   # All of the inputs from the inherited hcl files are available automatically
   # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
   # will be more flexible if you specify particular input values.
+  tags = {
+    Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
+  }
 }

+ 61 - 0
test/aws/mdr-test-c2/006-account-standards-regional/us-west-1/terragrunt.hcl

@@ -0,0 +1,61 @@
+locals {
+  # If you want to use any of the variables in _this_ file, you have to load them here.
+  # However, they will all be available as inputs to the module loaded in terraform.source
+  # below.
+
+  environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+  partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
+  region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+  account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
+  global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
+
+  aws_partition  = local.partition_vars.locals.aws_partition
+  account_id     = local.account_vars.locals.aws_account_id
+  common_profile = local.partition_vars.locals.common_profile
+
+  target_aws_region = "us-west-1"
+}
+
+# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
+# working directory, into a temporary folder, and execute your Terraform commands in that folder.
+terraform {
+  # Double slash is intentional and required to show root of modules
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_regional?ref=v0.5.0"
+}
+
+# Include all settings from the root terragrunt.hcl file
+include {
+  path = find_in_parent_folders()
+}
+
+############# Custom provider for the region
+generate "provider" {
+  path      = "provider.tf"
+  if_exists = "overwrite_terragrunt"
+  contents  = <<EOF
+provider "aws" {
+  version = "~> 2.66"
+  region = "${local.target_aws_region}"
+
+  assume_role {
+    role_arn = "arn:${local.aws_partition}:iam::${local.account_id}:role/user/mdr_terraformer"
+    session_name = "terraform"
+  }
+
+  profile = "${local.common_profile}"
+
+  # Only these AWS Account IDs may be operated on by this template
+  allowed_account_ids = ["${local.account_id}"]
+}
+EOF
+}
+
+# These are the variables we have to pass in to use the module specified in the terragrunt source above
+inputs = {
+  # All of the inputs from the inherited hcl files are available automatically
+  # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
+  # will be more flexible if you specify particular input values.
+  tags = {
+    Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
+  }
+}

+ 13 - 15
test/aws/mdr-test-c2/006-account-standards/terragrunt.hcl

@@ -3,22 +3,22 @@ locals {
   # However, they will all be available as inputs to the module loaded in terraform.source
   # below.
 
-  # e.g. inherited variables:
-  #environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
-  #partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
-  #region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+  environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+  partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
+  region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
   account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
-  #global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
-
-  # Extract out common variables for reuse
-  #env = local.environment_vars.locals.environment
+  global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
 }
 
 # Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.1"
+}
+
+dependency "c2_account_standards" {
+  config_path = local.account_vars.locals.c2_account_standards_path
 }
 
 # Include all settings from the root terragrunt.hcl file
@@ -31,10 +31,8 @@ inputs = {
   # All of the inputs from the inherited hcl files are available automatically
   # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
   # will be more flexible if you specify particular input values.
-  #name = "vpc_primary_${local.account_vars.locals.account_name}"
-  #cidr = local.account_vars.locals.standard_vpc_cidr
-  #tags = {
-  #  Purpose = "Malware Detonation"
-  #  Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
-  #}
+  tags = {
+    Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
+  }
+  cloudtrail_key_arn = dependency.c2_account_standards.outputs.cloudtrail_logging_bucket.kms_key_id
 }

+ 1 - 1
test/aws/mdr-test-c2/008-transit-gateway-hub/terragrunt.hcl

@@ -15,7 +15,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_hub?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_hub?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 2 - 2
test/aws/mdr-test-c2/010-standard-vpc/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file
@@ -34,7 +34,7 @@ inputs = {
   name = "vpc_primary_${local.account_vars.locals.account_name}"
   cidr = local.account_vars.locals.standard_vpc_cidr
   tags = {
-    Purpose = "Malware Detonation"
+    Purpose = "Standard VPC"
     Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
   }
 }

+ 1 - 1
test/aws/mdr-test-c2/019-attach-transit-gateway-to-hub-account/terragrunt.hcl

@@ -24,7 +24,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws/mdr-test-c2/020-transit-gateway-interconnect-vpn/terragrunt.hcl

@@ -8,7 +8,7 @@ locals {
 
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_interconnect_vpn?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_interconnect_vpn?ref=v0.5.1"
 }
 
 dependency "transit-gateway-hub" {

+ 1 - 1
test/aws/mdr-test-c2/025-test-instance/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.2.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 0
test/aws/mdr-test-c2/account.hcl

@@ -7,6 +7,7 @@ locals {
   instance_termination_protection = true # set to true for production!
   
   account_tags = { } 
+  c2_account_standards_path = "../../mdr-test-c2/005-account-standards-c2"
 
   # For CIDR assignment, see https://github.mdr.defpoint.com/mdr-engineering/msoc-infrastructure/wiki/IP-Address-Allocation
   standard_vpc_cidr = "10.16.0.0/22"

+ 2 - 0
test/aws/mdr-test-malware/account.hcl

@@ -1,9 +1,11 @@
 # Set account-wide variables. These are automatically pulled in to configure the remote state bucket in the root
 # terragrunt.hcl configuration.
 locals {
+  # UNUSED ACCOUNT
   account_name   = "afs-mdr-test-malware"
   account_alias  = "afs-mdr-test-malware"
   aws_account_id = "404265901253"
   
   account_tags = { } 
+  c2_account_standards_path = "../../mdr-test-c2/005-account-standards-c2"
 }

+ 1 - 1
test/aws/mdr-test-modelclient/005-iam/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/iam?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 61 - 0
test/aws/mdr-test-modelclient/006-account-standards-regional/us-west-1/terragrunt.hcl

@@ -0,0 +1,61 @@
+locals {
+  # If you want to use any of the variables in _this_ file, you have to load them here.
+  # However, they will all be available as inputs to the module loaded in terraform.source
+  # below.
+
+  environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+  partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
+  region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+  account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
+  global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
+
+  aws_partition  = local.partition_vars.locals.aws_partition
+  account_id     = local.account_vars.locals.aws_account_id
+  common_profile = local.partition_vars.locals.common_profile
+
+  target_aws_region = "us-west-1"
+}
+
+# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
+# working directory, into a temporary folder, and execute your Terraform commands in that folder.
+terraform {
+  # Double slash is intentional and required to show root of modules
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards_regional?ref=v0.5.0"
+}
+
+# Include all settings from the root terragrunt.hcl file
+include {
+  path = find_in_parent_folders()
+}
+
+############# Custom provider for the region
+generate "provider" {
+  path      = "provider.tf"
+  if_exists = "overwrite_terragrunt"
+  contents  = <<EOF
+provider "aws" {
+  version = "~> 2.66"
+  region = "${local.target_aws_region}"
+
+  assume_role {
+    role_arn = "arn:${local.aws_partition}:iam::${local.account_id}:role/user/mdr_terraformer"
+    session_name = "terraform"
+  }
+
+  profile = "${local.common_profile}"
+
+  # Only these AWS Account IDs may be operated on by this template
+  allowed_account_ids = ["${local.account_id}"]
+}
+EOF
+}
+
+# These are the variables we have to pass in to use the module specified in the terragrunt source above
+inputs = {
+  # All of the inputs from the inherited hcl files are available automatically
+  # (via the `inputs` section of the root `terragrunt.hcl`). However, modules
+  # will be more flexible if you specify particular input values.
+  tags = {
+    Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
+  }
+}

+ 10 - 9
test/aws/mdr-test-modelclient/006-account-standards/terragrunt.hcl

@@ -3,22 +3,22 @@ locals {
   # However, they will all be available as inputs to the module loaded in terraform.source
   # below.
 
-  # e.g. inherited variables:
-  #environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
-  #partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
-  #region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+  environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+  partition_vars = read_terragrunt_config(find_in_parent_folders("partition.hcl"))
+  region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
   account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
-  #global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
-
-  # Extract out common variables for reuse
-  #env = local.environment_vars.locals.environment
+  global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
 }
 
 # Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.5.1"
+}
+
+dependency "c2_account_standards" {
+  config_path = local.account_vars.locals.c2_account_standards_path
 }
 
 # Include all settings from the root terragrunt.hcl file
@@ -34,4 +34,5 @@ inputs = {
   tags = {
     Terraform = "aws/${basename(get_parent_terragrunt_dir())}/${path_relative_to_include()}/"
   }
+  cloudtrail_key_arn = dependency.c2_account_standards.outputs.cloudtrail_logging_bucket.kms_key_id
 }

+ 1 - 1
test/aws/mdr-test-modelclient/010-standard-vpc/terragrunt.hcl

@@ -18,7 +18,7 @@ locals {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/standard_vpc?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws/mdr-test-modelclient/020-attach-transit-gateway-to-standard-vpc/terragrunt.hcl

@@ -24,7 +24,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/transit_gateway_client?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 1
test/aws/mdr-test-modelclient/025-test-instance/terragrunt.hcl

@@ -19,7 +19,7 @@ dependency "standard_vpc" {
 # working directory, into a temporary folder, and execute your Terraform commands in that folder.
 terraform {
   # Double slash is intentional and required to show root of modules
-  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.4.0"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v0.5.1"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 1 - 0
test/aws/mdr-test-modelclient/account.hcl

@@ -6,6 +6,7 @@ locals {
   aws_account_id = "449047653882"
   
   account_tags = { } 
+  c2_account_standards_path = "../../mdr-test-c2/005-account-standards-c2"
 
   # For CIDR assignment, see https://github.mdr.defpoint.com/mdr-engineering/msoc-infrastructure/wiki/IP-Address-Allocation
   standard_vpc_cidr = "10.16.8.0/22"