test-kitchen / kitchen-ec2

A Test Kitchen Driver for Amazon EC2
Other
221 stars 202 forks source link

kitchen-ec2 not picking the image-id provided to while spinning the instance its taking some default image #531

Closed Vasu1105 closed 3 years ago

Vasu1105 commented 3 years 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

kitchen ec2 not picking the image-id that has been provided in the kitchen.yml. It is picking some default image to spin the instance. On further debugging I found that config[:image_id] is coming nil here https://github.com/test-kitchen/kitchen-ec2/blob/2c934174d7661c2d1d0a2580cd3442b869bfe74d/lib/kitchen/driver/ec2.rb#L307

Version

v3.6.0 [Version of the project installed]

Environment

[Details about the environment such as the Operating System, cookbook details, etc...]

Scenario

[What you are trying to achieve and you can't?]

Steps to Reproduce

[If you are filing an issue what are the things we need to do in order to repro your problem?]

example:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected Result

[What are you expecting to happen as the consequence of above reproduction steps?]

Actual Result

[What actually happens after the reproduction steps?]

:heavy_plus_sign: Additional context

Add any other context about the problem here. e.g. related issues or existing pull requests.

deric4 commented 3 years ago

@Vasu1105 can you provide an example kitchen.yml ?

Vasu1105 commented 3 years ago

@deric4 here is the one.

driver:
  name: ec2
  shared_credentials_profile: xxxxx
  region: us-west-2
  # This security group is in the Chef Partner account
  # TODO: Make the account used for testing configurable
  security_group_ids: ['sg-xxxxxf']
  interface: dns
  associate_public_ip: true
  aws_ssh_key_id: xxxxxx
  block_device_mappings:
  - device_name: /dev/sda1
    ebs:
      volume_size: 30
      delete_on_termination: false

transport:
  ssh_key: ~/.ssh/xxxxx.pem

provisioner:
  name: chef_zero
  deprecations_as_errors: false
  chef_license: accept

verifier:
  name: inspec
  sudo: true
  reporter:
    - cli
    - json:.kitchen/logs/%{platform}_%{suite}_inspec.json

platforms:
  - name: windows-2019
    transport:
      name: winrm
      elevated: true
    driver:
      retryable_tries: 240
      image-id: ami-0300fe0852e0add56
      instance_type: t3.large
      tags:
        Name: compliance_profiles_windows_2019
        created-by: test-kitchen

suites:
  - name: windows2019_memberserver_v1.1.0
    named_run_list: kitchen_remediation_windows_2019
    includes:
      - windows-2019
    verifier:
      inspec_tests:
        - path: test/integration/default/inspec/cis-windows2019-level2-memberserver-v1.1.0
deric4 commented 3 years ago

I think you just need to change the - to _ like so:

  image_id: ami-0300fe0852e0add56
Vasu1105 commented 3 years ago

Thanks. @deric4 closing this.