Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

'aws_lambda' resource not identified #275

Open
mihirvijdeshpande opened this issue Mar 8, 2021 · 0 comments
Open

'aws_lambda' resource not identified #275

mihirvijdeshpande opened this issue Mar 8, 2021 · 0 comments
Labels
Status: Untriaged An issue that has yet to be triaged.

Comments

@mihirvijdeshpande
Copy link

mihirvijdeshpande commented Mar 8, 2021

Version:

Test Kitchen version 2.10.0

Environment:

Ubuntu 20.04
Terraform 13.5
ruby 2.7.1

Using Kitchen-terraform to test aws infra

Scenario:

We are trying to run tests on resource aws_lambda but are unable to, the verify command fails with error.

Steps to Reproduce:

Write the following code in lambda_spec.rb:

control 'lambda' do
    describe aws_lambdas('tdd-terraform-lambda') do
        it { should exist}
        its ('handler') { should eq 'lambda'}
#        its ('version') { should eq '$LATEST' }
        its ('runtime') { should eq 'go1.x' }
    end
end

Tree:

.
├── Gemfile
├── Gemfile.lock
├── <redacted>.pem
├── main.tf
├── output.tf
├── src
│   ├── lambda
│   └── lambda.go
├── tdd-terraform-lambda.zip
├── terraform.tfstate.d
├── terraform.tfvars
├── test
│   └── integration
│       └── default
│           ├── controls
│           │   ├── ec2_spec.rb
│           │   ├── httpd_spec.rb
│           │   ├── lambda_spec.rb
│           ├── files
│           │   └── terraform.json
│           └── inspec.yml
├── user-data
│   └── user-data.sh
└── variables.tf

kitchen.yml:

---
driver:
  name: terraform
  variable_files:
    - terraform.tfvars
  region: "us-east-1"

provisioner:
  name: terraform

platforms:
  - name: ubuntu

verifier:
  name: terraform
  systems:
    - name: default
      controls:
        - httpd
      backend: ssh
      user: <redacted>
      key_files:
        - <redacted>.pem
      hosts_output: private_ip
      reporter:
        - documentation
    - name: aws
      controls:
        - lambda
      backend: aws
      reporter:
        - documentation

suites:
  - name: default

AWS Credentials exported in the ENV

run command kitchen converge to create aws resources >> this Passes

run command kitchen verify to run tests >> this Fails

Expected Result:

Run test and return result if Lambda function is present (or not)

Actual Result:

 1) Control Source Code Error /home/ubuntu/tdd-test/terraform-tdd/kitchen/test/integration/default/controls/lambda_spec.rb:1
     Failure/Error: its(location) { fail e.message } # rubocop: disable Style/SignalException
     RuntimeError:
       undefined local variable or method `aws_lambdas' for #<Inspec::Rule:0x00007f5e88277070>
@mihirvijdeshpande mihirvijdeshpande added the Status: Untriaged An issue that has yet to be triaged. label Mar 8, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Status: Untriaged An issue that has yet to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant