Created
December 6, 2017 12:33
-
-
Save guss77/d2a44d063cafbe27ba9a92dcc4059730 to your computer and use it in GitHub Desktop.
Create a YAML mapping file for CloudFormation to select a CoreOS 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
#!/usr/bin/ruby | |
require 'yaml' | |
require 'json' | |
require 'net/http' | |
def get_releases | |
JSON[Net::HTTP.get_response(URI.parse "https://coreos.com/dist/aws/aws-stable.json").body.gsub(/,\s*\]/,"]")] | |
end | |
File.open("coreos-images.yaml","w") do |f| | |
f << ({ | |
"Mappings" => { | |
"CoreosRegionImages" => get_releases.delete_if { |k,v| k == "release_info" } | |
} | |
}).to_yaml | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment