envato / cloudformation_rspec Goto Github PK
View Code? Open in Web Editor NEWTest your CloudFormation templates
License: MIT License
Test your CloudFormation templates
License: MIT License
When testing a YAML template, if I include a Version in an IAM trust policy document for a role, or an IAM policy document, I receive the following error message:
Failure/Error: expect(template_body).to have_output_including("Role")
Psych::DisallowedClass:
Tried to load unspecified class: Date
...
to reproduce use the following template.yaml:
Resources:
Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Sid: ''
Effect: Allow
Principal:
Service:
- firehose.amazonaws.com
Action: 'sts:AssumeRole'
Condition:
StringEquals:
'sts:ExternalId': !Ref 'AWS::AccountId'
and the following test:
require 'cloudformation_rspec'
describe 'template' do
let(:template_body) { File.read('template.yaml') }
it 'outputs stack resources' do
expect(template_body).to have_output_including("Role")
end
end
Hi Patrick,
Thanks for building out this library it is very useful!
I was wondering if this was published to rubygems.org as I cannot find it?
if there is an error in a test (e.g. try reproducing #10), the CFN stack does not get cleaned up and is left in state REVIEW_IN_PROGRESS.
I believe the issue is coming from https://github.com/envato/cloudformation_rspec/blob/master/lib/cloudformation_rspec/change_set.rb#L62 since the stack only gets deleted if it was actually created, which may not always be the case. Ideally the stack should always get deleted along with the changesets as it doesn't serve any purpose
I'm having an issue when testing a template which includes a serverless function. When i execute the test, I get the following error:
Failure/Error: expect(stack).to contain_in_change_set("AWS::S3::Bucket", "Bucket")
NoMethodError:
undefined method `status_reason' for #<CloudFormationRSpec::ChangeSet:0x00007fdb0b10e850>
Reproducible using a the following template:
Transform: 'AWS::Serverless-2016-10-31'
Resources:
Function:
Type: 'AWS::Serverless::Function'
Properties:
Handler: index.handler
Runtime: nodejs8.10
CodeUri: ./code
Bucket:
Type: "AWS::S3::Bucket"
and the following test:
require 'cloudformation_rspec'
describe 'template' do
let(:template_body) { File.read('template.yaml') }
let(:stack) {{
template_body: template_body
}}
it 'creates bucket' do
expect(stack).to contain_in_change_set("AWS::S3::Bucket", "Bucket")
end
end
I am trying a simple test and I appear to be getting a syntax error.
My code is hosted here: https://github.com/eamonnfaherty/cloudformation_rpec_trial
I am trying to run your example by running rspec and I am getting error:
SyntaxError:
/specs/vpc_spec.rb:4: syntax error, unexpected ':', expecting '}'
template_body: template_json,
^
I have added a dockerfile in my example so you can see what I am doing in a clean env.
Do you have any idea where I am going wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.