Sha256: bea772e6107131fa4d41000fabc45072a3fab73db2fd9084c98c841e46c101ef

Contents?: true

Size: 1.08 KB

Versions: 68

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

class Convection::Model::Template::Resource
  describe Lambda do
    let(:template) do
      Convection.template do
        description 'Lambda Permission Test Template'

        lambda_permission 'LambdaInvokePermission' do
          action 'lambda:InvokeFunction'
          function_name get_att('MyLambdaFunction', 'Arn')
          principal 's3.amazonaws.com'
          source_account fn_ref('AWS::AccountId')
        end
      end
    end

    subject do
      template_json
        .fetch('Resources')
        .fetch('LambdaInvokePermission')
        .fetch('Properties')
    end

    it 'action parameter is set correctly' do
      expect(subject['Action']).to eq('lambda:InvokeFunction')
    end

    it 'function name parameter is set with get_att' do
      expect(subject['FunctionName']).to eq('Fn::GetAtt' => %w(MyLambdaFunction Arn))
    end

    it 'source account fn ref sets param properly' do
      expect(subject['SourceAccount']).to eq('Ref' => 'AWS::AccountId')
    end

    private

    def template_json
      JSON.parse(template.to_json)
    end
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
convection-2.2.12 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.11 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.10 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.9 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.8 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.7 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.6 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.5 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.4 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.3 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.2 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.1 spec/convection/model/template/resource/permission_spec.rb
convection-2.2.0 spec/convection/model/template/resource/permission_spec.rb
convection-2.1.2 spec/convection/model/template/resource/permission_spec.rb
convection-2.1.1 spec/convection/model/template/resource/permission_spec.rb
convection-2.1.0 spec/convection/model/template/resource/permission_spec.rb
convection-2.0.0 spec/convection/model/template/resource/permission_spec.rb
convection-1.1.7 spec/convection/model/template/resource/permission_spec.rb
convection-1.1.5 spec/convection/model/template/resource/permission_spec.rb
convection-1.1.4 spec/convection/model/template/resource/permission_spec.rb