amazon-web-servicesaws-iot

how do I set the default aws user with the CLI?


Been having issues with this for the past hour at least, and so I hope someone can point me in the right direction. I am running a windows system using the AWS CLI through windows PowerShell.

I have numerous profiles setup on my system for AWS. Normally, it is not a problem but today it seems to be. I need to switch from my default profile to another profile. Currently when I run aws configure list I get the following output:

      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                      nam           manual    --profile
access_key     ****************KBU2 shared-credentials-file
secret_key     ****************XLn7 shared-credentials-file
    region                us-east-1      config-file    ~/.aws/config

So my default profile is set to nam, which is good. However, I need to use my profile called "butterfly". And this is where I am getting stuck. I can see that my butterfly profile is setup correctly by using aws configure-list --profile butterfly which results in:

      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                butterfly           manual    --profile
access_key     ****************FS7W shared-credentials-file
secret_key     ****************88vh shared-credentials-file
    region                us-east-1      config-file    ~/.aws/config

All the documentation that I have found has suggested that either set AWS_DEFAULT_PROFILE=butterfly or setx AWS_DEFAULT_PROFILE butterfly should do the trick. However, when I re-run aws configure list after setting, I am still getting the previous output and no profile change.

My end goal is I need to connect several IoT devices using AWS. If I run aws iot list-things I get an error exception error:

An error occurred (InvalidSignatureException) when calling the ListThings operation: The request signature we calculated does not match the signature you provided

That is fine and I am not concerned about that. However, if I adjust my call and add a profile aws iot list-things --profile butterfly I then get a list of my IoT devices. I will be using mongoose os part of the software on these boards. https://mongoose-os.com/docs/mongoose-os/cloud/aws.md Where I am getting stuck with the profile is on the second step "setup device", with the provision AWS IoT.

EDIT Looking at the link in the first comment, I tried to set all the variables individually with:

setx AWS_ACCESS_KEY_ID AKIAIOSFODNN7EXAMPLE
setx AWS_SECRET_ACCESS_KEY wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
setx AWS_DEFAULT_REGION us-west-2

That still didn't do anything as when I list I still have nam.

I am cleary missing a step, just not sure what.


Solution

  • AWS_DEFAULT_PROFILE is not listed at Environment variables to configure the AWS CLI. It is no longer supported. Arguably, it never made a lot of sense in the first place.

    Use AWS_PROFILE instead.