Skip to main content

aws_lambdas resource

[edit on GitHub]

Use the aws_lambdas resource to test the collection of lambdas deployed into an account.

Syntax

describe aws_lambdas do
  its('count') { should eq 20 }
end

Parameters

This resource does not expect any parameters.

Properties

PropertyDescription
namesThe names of the lambda deployed.
tagsThe tags of the lambda deployed.

Examples

tests that all lambdas with a particular tag is correctly deployed

lambdas = aws_lambdas()

describe lambdas do
  its ('count') { should eq 33}
end

lambdas.tags.each_with_index { | tag, i |
  if tag!= {} and tag.include? 'Application' and tag['Application']=='test')
    lambda_name = lambdas.names[i]

    describe aws_lambda(lambda_name) do
        it { should exist}
        its ('handler') { should eq 'main.on_event'}
        its ('version') { should eq '$LATEST' }
        its ('runtime') { should eq 'python3.7' }
    end
  end
}

Matchers

This InSpec audit resource uses the standard matchers. For a full list of available matchers, please visit our matchers page.

AWS Permissions

Your Principal will need the lambda:ListFunctions action with Effect set to Allow.

You can find detailed documentation at AWS Lambda

Was this page helpful?