Created
December 6, 2017 12:21
-
-
Save guss77/d12c14594a431e4789fe47d2b2bb97bc to your computer and use it in GitHub Desktop.
Create a YAML mapping file for CloudFormation to select a CentOS AMI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
( | |
cat <<EOF | |
Mappings: | |
CentOSRegionImages: | |
EOF | |
curl -s 'https://wiki.centos.org/Cloud/AWS' | xmllint -html --xpath '//table[1]/tbody/tr' - | perl -nle ' | |
m|CentOS Linux (\d+)| and $version=$1; | |
m|>\s*(\w{2}-\w+-\d)| and $region=$1; | |
m|>\s*(ami-\w+)| and $amis{$region}->{"centos$version"} = $1; | |
END { | |
for my $region (keys %amis) { | |
print " $region: { ". join(", ", map { "$_: \"".$amis{$region}->{$_}."\"" } (keys %{$amis{$region}})) . " }"; | |
} | |
}' | sort | |
) > centos-images.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment