GithubHelp home page GithubHelp logo

cloudformation_rspec's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudformation_rspec's Issues

Unable to validate outputs when IAM policy document contains version

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

Publish to rubygems.org?

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?

Test stacks aren't cleaned up when there is an error

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

Error when testing template with Serverless Functions (Transforms)

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

Example doesn't seem to work

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.