Skip to content

Instantly share code, notes, and snippets.

@mza
Created May 6, 2011 10:32
Show Gist options
  • Save mza/958737 to your computer and use it in GitHub Desktop.
Save mza/958737 to your computer and use it in GitHub Desktop.
Really simple CloudFormation template validation
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
@ralph-tice
Copy link

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment