Browse Source

mdr-test-malware/006-account-standards migrated successfully

Fred Damstra 5 years ago
parent
commit
e05388df43

+ 15 - 1
README.md

@@ -2,4 +2,18 @@
 
 Live configurations of the environments.
 
-For development, put this repository at the same level as a copy of `xdr-terraform-modules` or the local scripts will not work for testing. You can certainly look at how the local scripts work and modify them for your development environment.
+# Testing Locally
+
+To test locally:
+1) Make sure a copy of the `xdr-terraform-modules` directory is at the same level as this repository.
+2) Change to the directory in which you want to test. (e.g. `cd test/aws-us-gov/mdr-test-malware/006-account-standards`)
+3) Run `bin/terragrunt-local` from this repository with the usual terragrunt parameters.
+
+e.g.
+```
+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)
+

+ 21 - 0
bin/terragrunt-local

@@ -0,0 +1,21 @@
+#! /bin/bash
+
+if [ ! -f terragrunt.hcl ]; then
+  echo "ERROR: No terragrunt.hcl in this directory. Aborting."
+  exit 1
+fi
+
+GITSOURCE=$( cat terragrunt.hcl | egrep -v '^ *#' | egrep 'source *= *.git@github\.mdr' )
+
+if [ "$GITSOURCE" == "" ]; then
+  echo "ERROR: No source from MDR Git detected. Aborting."
+  exit 2
+fi
+
+# Remove the git URL and the reference
+NEWPATH=$( echo $GITSOURCE | sed 's#^.*//#../../../../../xdr-terraform-modules//#' | sed 's/\?.*$//' )
+echo Substituting \'$GITSOURCE\' with \'$NEWPATH\'
+
+# Test locally
+# the double // is intentional! Terragrunt uses this to determine the root of the modules repository.
+terragrunt $* --terragrunt-source $NEWPATH

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

@@ -17,10 +17,7 @@ locals {
 # 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 {
-  # Ideally, these would be in a git repo with a version number, and we would override via 'terragrunt-source'
-  #source = "git::git@github.mdr.defpoint.com:frederick-t-damstra/terraform-modules.git//testvpc?ref=v0.1.0"
-  # Double slash is intentional and required to show root of modules
-  source = "../../../../modules//account_standards/0.1/"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/account_standards?ref=v0.0.1"
 }
 
 # Include all settings from the root terragrunt.hcl file