Skip to content

Instantly share code, notes, and snippets.

@guss77
Created December 6, 2017 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guss77/d2a44d063cafbe27ba9a92dcc4059730 to your computer and use it in GitHub Desktop.
Save guss77/d2a44d063cafbe27ba9a92dcc4059730 to your computer and use it in GitHub Desktop.
Create a YAML mapping file for CloudFormation to select a CoreOS AMI
#!/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