Created
May 6, 2011 10:32
-
-
Save mza/958737 to your computer and use it in GitHub Desktop.
Really simple CloudFormation template validation
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
require 'rubygems' | |
require 'fog' | |
require 'yaml' | |
config = YAML::load_file(File.dirname(__FILE__) + '/config.yml') | |
cf = Fog::AWS::CloudFormation.new( | |
:aws_access_key_id => config['key'], | |
:aws_secret_access_key => config['secret'] | |
) | |
template = File.open(ARGV[0], 'rb') | |
template_contents = template.read | |
begin | |
response = cf.validate_template( "TemplateBody" => template_contents) | |
rescue Excon::Errors::BadRequest => e | |
puts "Validation error: 400 Bad request" | |
puts e.inspect | |
else | |
puts "Template validated successfully." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the script. for non-native Rubizens, config.yml is expected to be of the format:
"key": "your-aws-access-key"
"secret": "your-aws-secret-key-id"