Login to AWS from AWS Tools for Powershell

sashoalm picture sashoalm · Sep 1, 2017 · Viewed 9k times · Source

I'm trying to use AWS Tools from Powershell, but I don't know how to log in. So when I run a command I naturally get this error:

No credentials specified or obtained from persisted/shell defaults.

How do I login? I read the article at https://docs.aws.amazon.com/powershell/latest/userguide/specifying-your-aws-credentials.html, but it talks about public and private keys. I don't have those, I login to AWS from the web interface with my username and password (and also a token sent to my phone because I have MFA enabled).

Also, my user isn't allowed to create IAM users (it's a company policy and I can't override it).

Answer

strongjz picture strongjz · Sep 1, 2017

If your IAM user account doesn't already have Access and Secret Keys you'll need to create them here.

http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey

Then create a profile

Writes a new (or updates existing) profile with name "myProfileName" in the encrypted SDK store file

Set-AWSCredential -AccessKey akey -SecretKey skey -StoreAs myProfileName

Checks the encrypted SDK credential store for the profile and then falls back to the shared credentials file in the default location

Set-AWSCredential -ProfileName myProfileName