amazon-web-servicesaws-regionsaws-codeartifactaws-sso

AWS SSO and CodeArtifact Login requires manual config file changes for Region


When I run

AWS SSO Login --Profile Default

on my machine if my .aws/config file is not set to a Default region of us-east-1 I get "Invalid Grant" When the Browser opens to authenticate. When I set the config region to us-west-2 I can authenticate.

Issue is I then need to login to CodeArtifact and if I do not change the config file to us-west-2 I get:

An error occurred (ResourceNotFoundException) when calling the GetAuthorizationToken operation: Domain not found. Domain 'MY-domain' owned by account '1234567890' does not exist.

I need to be able to login to CodeArtifact inside of a docker container and manually changing the region is not an option there. Please advise. Thank you!


Solution

  • AWS CLI has global parameters you can use to pass the region when calling get-authorization-token.

    aws codeartifact get-authorization-token --domain MY-domain --region us-west-2