2
votes

I am new to AWS and I am trying to register an image on ECR on windows. To do that I am using PowerShell to connect to AWS.

Below is my version

PS C:\> aws --version

aws-cli/2.0.0 Python/3.7.5 Windows/10 botocore/2.0.0dev4

I used aws configure command to login. I went to users -> createdUser -> Security Credentials for Access key and Secret key.

When I use Get-ECRLoginCommand

PS C:\> Get-ECRLoginCommand

Get-ECRLoginCommand : The request signature we calculated does not match the signature you provided. Check your AWS
Secret Access Key and signing method. Consult the service documentation for details.
At line:1 char:1
+ Get-ECRLoginCommand
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Amazon.PowerShe...inCommandCmdlet:GetECRLoginCommandCmdlet) [Get-ECRL
   oginCommand], InvalidOperationException
    + FullyQualifiedErrorId : Amazon.ECR.AmazonECRException,Amazon.PowerShell.Cmdlets.ECR.GetECRLoginCommandCmdlet  

Can someone please help me how to registry docker image on ECR?

3
check the config file under - %userprofile%/.aws. make sure the Access key and Secret key are the same as expected. - Amit Baranes
Thanks for the response. Access Id and Secret key %userprofile%/.aws is matching. aws ecr list-images --repository-name testrepo is returning empty list so I assume I am able to connect. - cubcoder00

3 Answers

0
votes

Try uninstalling AWS CLI V2 and install AWS CLI V1 that fixed the problem for me.

0
votes

You need to first set up you aws credentials on your Windows PC.

Separately you need to set up it for aws cli and aws sdk:

from documentation:

Credentials Store Locations The AWS Tools for PowerShell can use either of two credentials stores:

The AWS SDK store, which encrypts your credentials and stores them in your home folder. > In Windows, this store is located at: C:\Users\username\AppData\Local\AWSToolkit\RegisteredAccounts.json.

The AWS SDK for .NET and Toolkit for Visual Studio can also use the AWS SDK store.

The shared credentials file, which is also located in your home folder, but stores credentials as plain text.

By default, the credentials file is stored here:

On Windows: C:\Users\username.aws\credentials

On Mac/Linux: ~/.aws/credentials

The AWS SDKs and the AWS Command Line Interface can also use the credentials file. If you're running a script outside of your AWS user context, be sure that the file that contains your credentials is copied to a location where all user accounts (local system and user) can access your credentials.

Example:

PS > Set-AWSCredential `
                 -AccessKey AKIA0123456787EXAMPLE `
                 -SecretKey wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY `
                 -StoreAs MyNewProfile

Source: https://docs.aws.amazon.com/powershell/latest/userguide/specifying-your-aws-credentials.html#specifying-your-aws-credentials-store

0
votes

Try this

Get-AWSCredential -ListProfileDetail

If you get something like this(2 defaults)

enter image description here

The 1st default is causing the issue! you should remove it with the following command

Remove-AWSCredentialProfile -ProfileName default

Once you only have a single default left(the working one) Get-ECRLoginCommand should work as expected.