Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unable to create EC2 instance with unexpected value at params[:key_type] error #595

Closed
jmvbxx opened this issue Jan 21, 2023 · 2 comments
Closed

Comments

@jmvbxx
Copy link

jmvbxx commented Jan 21, 2023

🗣️ 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.

👻 Brief Description

When attempting to spin up an EC2 instance the following error occurs:

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [unexpected value at params[:key_type] in the specified region us-east-1. Please check this AMI is available in this region.] on default-amazonlinux
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Before I continue, yes, I've confirmed that the AMI is correct and exists in the account/region specified.

Version

kitchen-ec2 v3.15.0

Environment

Local workstation: Ubuntu 22.04
kitchen-ec2 v3.15.0

Scenario

Trying to spin up an EC2 instance and unable to based on the above error. Full output is:

-----> Starting Test Kitchen (v2.4.0)
-----> Creating <default-amazonlinux>...
       instance_type not specified. Using free tier t2.micro instance ...
       Detected platform: amazon2 version 5.10 on x86_64. Instance Type: t2.micro. Default username: ec2-user (default).
       If you are not using an account that qualifies under the AWS
free-tier, you may be charged to run these suites. The charge
should be minimal, but neither Test Kitchen nor its maintainers
are responsible for your incurred costs.

       Created automatic security group sg-0ce07fb5bdbaaab85
       Removing automatic security group sg-0ce07fb5bdbaaab85
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [unexpected value at params[:key_type] in the specified region us-east-1. Please check this AMI is available in this region.] on default-amazonlinux
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Steps to Reproduce

Run the command bundle exec kitchen converge default-amazonlinux. Both create and converge have the same behaviour. Also, with and without aws-vault also ends the same way.

The output is as above.

Expected Result

I expect an EC2 instance to get spun up.

Actual Result

The error is above, specifically:

Failed to complete #create action: [unexpected value at params[:key_type] in the specified region us-east-1. Please check this AMI is available in this region.]

Thank you in advance!

@jmvbxx
Copy link
Author

jmvbxx commented Jan 21, 2023

I'm sorry, I forgot to include my config

---
driver:
  name: ec2
  subnet_id: subnet-a1b2c3d4e5

provisioner:
  name: chef_solo

verifier:
  name: inspec

platforms:
  - name: amazonlinux
    driver:
      image_id: ami-0b5eea76982371e91

@jmvbxx
Copy link
Author

jmvbxx commented Jan 23, 2023

After reading the source code, I discovered that the error was related to SSH key configuration. I solved this today by explicitly updating the config to the following:

---
driver:
  name: ec2
  aws_ssh_key_id: <SSH_KEY_NAME>
  subnet_id: subnet-a1b2c3d4e5

provisioner:
  name: chef_solo

verifier:
  name: inspec

transport:
  ssh_key: <SSH_KEY_PATH>
  connection_timeout: 10
  connection_retries: 5
  username: ec2-user

platforms:
  - name: amazon
    driver:
      image_id: ami-0b5eea76982371e91

@jmvbxx jmvbxx closed this as completed Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant