chef/knife-ec2

Another ERROR: Aws::Errors::MissingCredentialsError: unable to sign request without credentials set

Closed this issue · 0 comments

Version:

Knife Version: Chef Infra Client: 15.6.10
knife-ec2 (1.0.26)
CentOS-8

Scenario:

I am still having issues when trying to create a simple server with with the knife-ec2. This was supposed to be fixed in issue #617 but it still hasn't been fixed. We have multiple AWS accounts so we use the aws-profile to switch between accounts. The weird part is that I can view all my servers but when trying to create a server, it says it can't find the credentials.

If I query to show all my servers, it runs without issue.

knife ec2 server list --aws-profile mycompany
knife ec2 server list --aws-profile mycompany2

But when I try to create a server, the following error message shows

knife ec2 server create 10.50.14.140 -N server1.mycompany.com --image ami-gafdcera4a5444842 -f m5.large --region ca-central-1 --ssh-key myssh-awskey --subnet subnet-d528fac2 -g sg-8144b258 -E production -r 'recipe[baseinstall]' --ebs-size 100 -A --server-connect-attribute private_ip_address --private-ip-address 10.50.14.140 --json-attributes='{"tags": ["app:myapp"]}' --node-ssl-verify-mode none --ssh-verify-host-key never -U root --aws-profile mycompany

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

It's like the EC2 server creation is not seeing the AWS profile credentials.

Expected Result:

I should be able to just bootstrap without any issues.

Actual Result:

Getting an error ERROR: Aws::Errors::MissingCredentialsError: unable to sign request without credentials set

Steps to Reproduce:

cat ~/.chef/config.rb

knife[:aws_credential_file] = File.join(ENV['HOME'], "/.aws/credentials")
knife[:aws_config_file] = File.join(ENV['HOME'], "/.aws/config")

cat ~/.aws/credentials

[mycompany]
aws_access_key_id = 12345
aws_secret_access_key = 67890

[profile  mycompany]
aws_access_key_id = 12345
aws_secret_access_key = 67890

[mycompany2]
aws_access_key_id = 52341
aws_secret_access_key = 27891

[profile  mycompany]
aws_access_key_id = 52341
aws_secret_access_key = 27891

cat ~/.aws/config

[mycompany]
region = ca-central-1

[profile mycompany]
region = ca-central-1

[mycompany2]
region = ca-central-1

[profile mycompany2]
region = ca-central-1

It seems the only temporary 'workaround' is to hard code the credentials in the knife configuration file. This doesn't work well when juggling a few AWS accounts.

cat ~/.chef/config.rb
knife[:aws_access_key_id] = "12345"
knife[:aws_secret_access_key] = "67890"