test-kitchen / kitchen-vagrant

A Test Kitchen Driver for Vagrant
Other
348 stars 189 forks source link

AWS credentials not passing through to Vagrant box #482

Open jmvbxx opened 1 year ago

jmvbxx commented 1 year ago

:speaking_head: Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

:ghost: Brief Description

When spinning up a new Vagrant box, the AWS credentials are not being properly passed to the Vagrant box resulting in errors such as the following when trying to access SSM parameters

Aws::Errors::MissingCredentialsError
------------------------------------
unable to sign request without credentials set

Version

kitchen-vagrant 1.13.0

Environment

Here are some specs about the overall environment:

Scenario

I'm trying to access AWS resources from within the Vagrant box and am unable to do so

Steps to Reproduce

Here is the configuration I'm using:

driver:
  name: vagrant
  env:
    - AWS_REGION=<%= ENV['AWS_REGION'] %>
    - AWS_ACCESS_KEY_ID=<%= ENV['AWS_ACCESS_KEY_ID'] %>
    - AWS_SECRET_ACCESS_KEY=<%= ENV['AWS_SECRET_ACCESS_KEY'] %>
    - AWS_SESSION_TOKEN=<%= ENV['AWS_SESSION_TOKEN'] %>

provisioner:
  name: chef_zero

verifier:
  name: inspec

platforms:
  - name: amazonlinux
    driver:
      box: bento/amazonlinux-2

I run the following command: bundle exec kitchen converge default-amazonlinux

Everything runs correctly, the box spins up and the Chef run begins and then I get the following error Error executing actiongeton resource 'aws_ssm_parameter_store along with the error already shared above.

Expected Result

A successful Chef run

Actual Result

Error executing actiongeton resource 'aws_ssm_parameter_store

Aws::Errors::MissingCredentialsError
------------------------------------
unable to sign request without credentials set

Thanks in advance for any help/guidance.

jmvbxx commented 1 year ago

Btw, the same happens if I use aws-vault and remove the env block under driver. For example:

driver:
  name: vagrant

provisioner:
  name: chef_zero

verifier:
  name: inspec

platforms:
  - name: amazonlinux
    driver:
      box: bento/amazonlinux-2