瀏覽代碼

Merge pull request #136 from mdr-engineering/feature/ftd_na_CleanAndTestImages

Updates for testing AMIs, Script for Cleaning Old AMIs
Frederick Damstra 4 年之前
父節點
當前提交
450272b797

+ 22 - 0
bin/clean_old_amis.sh

@@ -0,0 +1,22 @@
+#! /bin/bash
+#
+# Requires amicleaner:
+# ```
+#  pip3 install aws-amicleaner
+# ```
+VERSIONS_TO_KEEP=3
+
+for profile in mdr-common-services-gov mdr-common-services; do
+  echo 
+  echo ==== Cleaning $profile
+  echo
+  AWS_PROFILE=${profile} amicleaner --full-report --keep-previous ${VERSIONS_TO_KEEP} --mapping-key tags --mapping-values Description Release --check-orphans
+  echo =========== Done
+  echo
+done
+
+echo 
+echo AMIs listed under \'no-tags\' were likely orphaned by packer via ctrl-c. Clean them up via:
+echo \ \ aws ec2 deregister-image --image-id ami-xxxxxxx --profile mdr-common-services-gov
+echo and then rerun $0
+echo

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

@@ -19,7 +19,7 @@ dependency "vpc_system_services" {
 # 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=v1.0.2"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v1.0.4"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 6 - 4
test/aws-us-gov/mdr-test-c2/account.hcl

@@ -157,12 +157,14 @@ locals {
   # Vault Server
   vault_server_instance_type = "t3a.micro"
 
-  # For testing
+  # For testing:
+  # Note: instead of changing this here, you can pass parameters to terragrunt on the CLI, such as:
+  #   TFVAR_create_test_instance=true TFVAR_test_instance_ami=base terragrunt apply
   create_test_instance = false
-  test_instance_key_name = "fdamstra" # They with which to provision the test instance
   # Extra customization if you want it
-  test_instance_ami = "base" # default = minion
-  test_instance_type = "t3a.micro" # default = t3a.micro
+  #test_instance_key_name = "fdamstra" # They with which to provision the test instance
+  #test_instance_ami = "base" # default = minion
+  #test_instance_type = "t3a.micro" # default = t3a.micro
 
   # AS Number used for various resources, but not every account needs one.
   asn = 64710 # changing this replaces the gateway

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

@@ -19,7 +19,7 @@ dependency "vpc_splunk" {
 # 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=v1.0.2"
+  source = "git@github.mdr.defpoint.com:mdr-engineering/xdr-terraform-modules.git//base/test_instance?ref=v1.0.4"
 }
 
 # Include all settings from the root terragrunt.hcl file

+ 8 - 2
test/aws-us-gov/mdr-test-modelclient/account.hcl

@@ -26,9 +26,15 @@ locals {
     }
   } 
 
-  # For testing
+  # For testing:
+  # Note: instead of changing this here, you can pass parameters to terragrunt on the CLI, such as:
+  #   TFVAR_create_test_instance=true TFVAR_test_instance_ami=base terragrunt apply
   create_test_instance = false
-
+  # Extra customization if you want it
+  #test_instance_key_name = "fdamstra" # They with which to provision the test instance
+  #test_instance_ami = "base" # default = minion
+  #test_instance_type = "t3a.micro" # default = t3a.micro
+  
   # Qualys Connector
   qualys_connector_externalid = "LATER" # Needs to come from the qualys console