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

Commit 7d29d4a

Browse files
committed
#6 refactor: use AMI from mappings
1 parent 8d30105 commit 7d29d4a

File tree

3 files changed

+479
-83
lines changed

3 files changed

+479
-83
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ insert_final_newline = true
88

99
[*.{yml,yaml}]
1010
indent_size = 2
11+
12+
[Makefile]
13+
indent_style = tab

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.PHONY: list-instance-types list-latest-amis
2+
3+
list-instance-types:
4+
@instance_types=$$( \
5+
aws pricing get-attribute-values \
6+
--service-code AmazonEC2 \
7+
--attribute-name instanceType \
8+
--region us-east-1 \
9+
--query 'AttributeValues[].Value' \
10+
--output text \
11+
); \
12+
for instance_type in $$instance_types; do \
13+
printf ' - '\''%s'\''\n' $$instance_type; \
14+
done
15+
16+
list-latest-amis:
17+
@for region in $$(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do \
18+
ami_id=$$( \
19+
aws ec2 describe-images \
20+
--owners amazon \
21+
--filters 'Name=name,Values=amzn2-ami-hvm-*-gp2' \
22+
'Name=image-type,Values=machine' \
23+
'Name=virtualization-type,Values=hvm' \
24+
'Name=architecture,Values=x86_64' \
25+
--region $$region \
26+
--query 'reverse(sort_by(Images, &CreationDate))[0].ImageId' \
27+
--output text \
28+
); \
29+
printf '%s:\n %s: '\''%s'\''\n' $$region 'AmiId' $$ami_id; \
30+
done

0 commit comments

Comments
 (0)