Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
#6 refactor: use AMI from mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
fquffio committed Mar 21, 2019
1 parent 8d30105 commit 7d29d4a
Show file tree
Hide file tree
Showing 3 changed files with 479 additions and 83 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ insert_final_newline = true

[*.{yml,yaml}]
indent_size = 2

[Makefile]
indent_style = tab
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.PHONY: list-instance-types list-latest-amis

list-instance-types:
@instance_types=$$( \
aws pricing get-attribute-values \
--service-code AmazonEC2 \
--attribute-name instanceType \
--region us-east-1 \
--query 'AttributeValues[].Value' \
--output text \
); \
for instance_type in $$instance_types; do \
printf ' - '\''%s'\''\n' $$instance_type; \
done

list-latest-amis:
@for region in $$(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do \
ami_id=$$( \
aws ec2 describe-images \
--owners amazon \
--filters 'Name=name,Values=amzn2-ami-hvm-*-gp2' \
'Name=image-type,Values=machine' \
'Name=virtualization-type,Values=hvm' \
'Name=architecture,Values=x86_64' \
--region $$region \
--query 'reverse(sort_by(Images, &CreationDate))[0].ImageId' \
--output text \
); \
printf '%s:\n %s: '\''%s'\''\n' $$region 'AmiId' $$ami_id; \
done
Loading

0 comments on commit 7d29d4a

Please sign in to comment.