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

Use AMI from mappings #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
sudo: false

language: python
language: 'python'

install:
- 'pip install awscli'

script:
- 'for template in $(ls *.yml); do aws cloudformation validate-template --template-body file://$template; done'
- 'make test'

before_deploy:
- 'mkdir -p templates'
Expand All @@ -23,7 +23,7 @@ deploy:
skip_cleanup: true
local_dir: 'templates'
on:
repo: 'Chialab/aws-autoscaling-gitlab-runner'
repo: 'chialab/aws-autoscaling-gitlab-runner'
all_branches: true
# Deploy templates in `s3://thebucket/org/repo/commit-sha`.
- provider: 's3'
Expand All @@ -36,5 +36,5 @@ deploy:
skip_cleanup: true
local_dir: 'templates'
on:
repo: 'Chialab/aws-autoscaling-gitlab-runner'
repo: 'chialab/aws-autoscaling-gitlab-runner'
all_branches: true
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.PHONY: list-instance-types list-latest-amis test

test:
@for template in $$(ls *.yml); do \
aws cloudformation validate-template --template-body file://$$template; \
done

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