Get AMI IDs per region automatically for your CloudFormation template
Project description
Get AMI IDs per region automatically for your CloudFormation template
In most cases, people use the Mapping section in CloudFormation to associate AMI IDs with AWS regions as described in THIS example.
I know how is it annoying to manually searching for AMI IDs in different AWS regions and build that map on your own, especially if your map is bigger than one image per region. That's why this tool had been created.
How to install
Install via pip
Ah, that's easy, just run next command
pip install cfn-ami-to-mapping
Or you can build source code
Clone the repository
git clone https://github.com/99stealth/cfn-ami-to-mapping.git
- Run the command
make install
How to use
Long story short
I also know how it's annoying to read all this stuff. So, enjoy watching :eyes:
Single image
The scenario
There is a requirement for only one image per region.
Ok, all you need to specify it's AMI id and an AWS region where it locates.
cfn-ami-to-mapping --image-name ami-02f706d959cedf892 --top-level-key AMIID --region us-east-2
or instead of AMI id, you may specify the image name
cfn-ami-to-mapping --image-name amzn-ami-hvm-2018.03.0.20190611-x86_64-gp2 --top-level-key AMIID --region us-east-2
Wait several seconds and you will get your autogenerated block of mapping
AMIRegionMap:
ap-northeast-1:
AMILinux: ami-04b2d1589ab1d972c
ap-northeast-2:
AMILinux: ami-0be3e6f84d3b968cd
ap-south-1:
AMILinux: ami-0b99c7725b9484f9e
ap-southeast-1:
AMILinux: ami-0fb6b6f9e81056553
ap-southeast-2:
AMILinux: ami-075caa3491def750b
ca-central-1:
AMILinux: ami-0a67d15f2858e33cb
eu-central-1:
AMILinux: ami-026d3b3672c6e7b66
eu-north-1:
AMILinux: ami-8c169ef2
eu-west-1:
AMILinux: ami-0862aabda3fb488b5
eu-west-2:
AMILinux: ami-0bdfa1adc3878cd23
eu-west-3:
AMILinux: ami-05b93cd5a1b552734
sa-east-1:
AMILinux: ami-0bb96001cf2299257
us-east-1:
AMILinux: ami-035b3c7efe6d061d5
us-east-2:
AMILinux: ami-02f706d959cedf892
us-west-1:
AMILinux: ami-0fcdcdb074d2bac5f
us-west-2:
AMILinux: ami-0f2176987ee50226e
Several images
Ok, but there are cases when you should specify several images and Fn::FindInMap
them based on some input Parameter
or maybe something else.
The scenario
You need to have possibility to swap your infrastructure from Amazon Linux
to Amazon Linux 2
.
Ok, then try to specify several values:
cfn-ami-to-mapping -i ami-035b3c7efe6d061d5 -k AMILinux -i ami-0b898040803850657 -k AMILinux2 --json
Here's what you'll get:
AMIRegionMap:
ap-northeast-1:
AMILinux: ami-04b2d1589ab1d972c
AMILinux2: ami-0c3fd0f5d33134a76
ap-northeast-2:
AMILinux: ami-0be3e6f84d3b968cd
AMILinux2: ami-095ca789e0549777d
ap-south-1:
AMILinux: ami-0b99c7725b9484f9e
AMILinux2: ami-0d2692b6acea72ee6
ap-southeast-1:
AMILinux: ami-0fb6b6f9e81056553
AMILinux2: ami-01f7527546b557442
ap-southeast-2:
AMILinux: ami-075caa3491def750b
AMILinux2: ami-0dc96254d5535925f
ca-central-1:
AMILinux: ami-0a67d15f2858e33cb
AMILinux2: ami-0d4ae09ec9361d8ac
eu-central-1:
AMILinux: ami-026d3b3672c6e7b66
AMILinux2: ami-0cc293023f983ed53
eu-north-1:
AMILinux: ami-8c169ef2
AMILinux2: ami-3f36be41
eu-west-1:
AMILinux: ami-0862aabda3fb488b5
AMILinux2: ami-0bbc25e23a7640b9b
eu-west-2:
AMILinux: ami-0bdfa1adc3878cd23
AMILinux2: ami-0d8e27447ec2c8410
eu-west-3:
AMILinux: ami-05b93cd5a1b552734
AMILinux2: ami-0adcddd3324248c4c
sa-east-1:
AMILinux: ami-0bb96001cf2299257
AMILinux2: ami-058943e7d9b9cabfb
us-east-1:
AMILinux: ami-035b3c7efe6d061d5
AMILinux2: ami-0b898040803850657
us-east-2:
AMILinux: ami-02f706d959cedf892
AMILinux2: ami-0d8f6eb4f641ef691
us-west-1:
AMILinux: ami-0fcdcdb074d2bac5f
AMILinux2: ami-056ee704806822732
us-west-2:
AMILinux: ami-0f2176987ee50226e
AMILinux2: ami-082b5a644766e0e6f
:warning: Please, pay attention
- You may not specify a region, in this case, it will use default one which is
us-east-1
. Therefore you need to specify AMI ID of image fromus-east-1
. - By default utility creates output using
yaml
format. If you want to change it tojson
, then run the utility with--json
flag.
cfn-ami-to-mapping --image-id ami-02f706d959cedf892 --top-level-key AMIID --us-east-2 --json
And the output:
{
"AMIRegionMap": {
"ap-northeast-1": {
"AMILinux": "ami-04b2d1589ab1d972c"
},
"ap-northeast-2": {
"AMILinux": "ami-0be3e6f84d3b968cd"
},
"ap-south-1": {
"AMILinux": "ami-0b99c7725b9484f9e"
},
"ap-southeast-1": {
"AMILinux": "ami-0fb6b6f9e81056553"
},
"ap-southeast-2": {
"AMILinux": "ami-075caa3491def750b"
},
"ca-central-1": {
"AMILinux": "ami-0a67d15f2858e33cb"
},
"eu-central-1": {
"AMILinux": "ami-026d3b3672c6e7b66"
},
"eu-north-1": {
"AMILinux": "ami-8c169ef2"
},
"eu-west-1": {
"AMILinux": "ami-0862aabda3fb488b5"
},
"eu-west-2": {
"AMILinux": "ami-0bdfa1adc3878cd23"
},
"eu-west-3": {
"AMILinux": "ami-05b93cd5a1b552734"
},
"sa-east-1": {
"AMILinux": "ami-0bb96001cf2299257"
},
"us-east-1": {
"AMILinux": "ami-035b3c7efe6d061d5"
},
"us-east-2": {
"AMILinux": "ami-02f706d959cedf892"
},
"us-west-1": {
"AMILinux": "ami-0fcdcdb074d2bac5f"
},
"us-west-2": {
"AMILinux": "ami-0f2176987ee50226e"
}
}
}
:warning: It doesn't work perfectly, so please report
Issues
if you faced with any problem during the installation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cfn-ami-to-mapping-0.8.3.tar.gz
.
File metadata
- Download URL: cfn-ami-to-mapping-0.8.3.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b8a506a302d328ea575957eca59a6b398fce5f2b6cb141337bc6898b9eaf36f |
|
MD5 | efadd4314d05a2ef324b391de413bc89 |
|
BLAKE2b-256 | db7ee59736fb02ea6f70e3d3a6709d2dc2871cc6706cfe79d283fb59519edc05 |
File details
Details for the file cfn_ami_to_mapping-0.8.3-py3-none-any.whl
.
File metadata
- Download URL: cfn_ami_to_mapping-0.8.3-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d73bb1fe9df6c6f504ecfd71dc8003e837ea062ce9e1e6862e8a168109d465d |
|
MD5 | 835f61823d5193da6dd62983cee8dc89 |
|
BLAKE2b-256 | f155e0e1b53519b3901aa3e36af3bb360bf3a6bbc3b60614c7b2ae7b4e4af7f1 |