Created
August 14, 2013 15:08
-
-
Save mlafeldt/6231957 to your computer and use it in GitHub Desktop.
Validate CloudFormation templates with aws-sdk
This file contains hidden or 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 'aws-sdk' | |
| def validate_template(body) | |
| cfn = AWS::CloudFormation.new | |
| cfn.validate_template(body) | |
| end | |
| desc 'Validate CloudFormation template files' | |
| task :test do | |
| Dir.glob('*.json').each do |template| | |
| puts "Validating template #{template}" | |
| result = validate_template(File.read(template)) | |
| if result.has_key?(:code) | |
| abort "#{result[:code]}: #{result[:message]}" | |
| end | |
| # Do not exceed API rate limit | |
| sleep(0.5) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment