From a51fd3bef3f9ec8418a046b90a3578f6eed1c422 Mon Sep 17 00:00:00 2001 From: "mail@typicalrunt.me" Date: Thu, 26 Nov 2020 18:23:30 -0800 Subject: [PATCH] Automating the listing of AMIs from the original JSON template --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 8c3b9a6..47f17d3 100644 --- a/Makefile +++ b/Makefile @@ -18,3 +18,13 @@ download-original: ## Download the original CFN template from AT&T convert-to-yaml: ## Convert JSON template to YAML @ruby -e "require 'json'; require 'yaml'; puts YAML.dump(JSON.parse(File.read('$(output.file)')))" > $(yaml.file) +.PHONY: list-amis +list-amis: ## Lists the AMIs available for use with the sensor + @jq '.Mappings.RegionMap | to_entries[] | [.key, .value.AMI]' $(output.file) + +.PHONY: ami +ami: ## Lists the AMI for a given REGION +ifndef REGION + @echo "You need to supply a REGION"; exit 1 +endif + @jq '.Mappings.RegionMap | to_entries[] | [.key, .value.AMI] | select(.[0] == "$(REGION)")' $(output.file)