Search code examples
powershellauthenticationamazon-web-serviceschef-infraknife

ERROR chef powershell ec2


I am trying to connect to ec2 (AWS) from my powershell (windows7) I added the following lines to the knife.rb file:

knife[:aws_access_key_id] = ENV['XXXXXX']
knife[:aws_secret_access_key] = ENV['xxxxxxxxxxxxxxxxxxxxxxxxxx']

I run for example

knife ec2 server list --region eu-west-1

but get the following:

knife : ERROR: You did not provide a valid 'AWS Access Key Id' value. At line:1 char:1
ERROR: You did ... Key Id' value.:String) [], RemoteException
ERROR: You did not provide a valid 'AWS Secret Access Key' value.

do I need to upload the knife.rb file to the server after I saved it? (how?) where should I save my pem file and how should I use it in the commands? i tried for example:

knife ec2 server create -I ami-6e7bd919 -N MyEc2Instance -x ec2-user -r "role[webserver]" -i C:\Users\MyName\Documents\openvoip.pem --region eu-west-1

Thanks!


Solution

  • The knife.rb file should have the following and not as described in the question:

    knife[:aws_access_key_id] = "XXXXXXXXXXXXXX"
    knife[:aws_secret_access_key] = "XXXXXXXXXXXXXXXXXXXX"
    

    I had no such ENV variables, so I set the credentials directly.