- Newest
- Most votes
- Most comments
It appears you're having an issue with retrieving the CodeArtifact authorization token in your App Runner configuration. The problem is likely related to how the token is being fetched and stored in the environment variable.
Here are a few ways to fix this issue:
- Use a simpler syntax for token retrieval:
- export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain ** --domain-owner *** --region us-west-2 --query authorizationToken --output text`
- Break down the command into multiple steps:
- TOKEN=$(aws codeartifact get-authorization-token --domain ** --domain-owner *** --region us-west-2 --query authorizationToken --output text) - echo "Token retrieved successfully" - export CODEARTIFACT_AUTH_TOKEN=$TOKEN
-
Make sure the AWS CLI has the necessary permissions to call the CodeArtifact service. App Runner might need specific IAM permissions to access CodeArtifact.
-
Verify that your domain and domain-owner values (currently masked as ** and ***) are correct.
-
Add error handling to see what's happening:
- | set -e echo "Retrieving CodeArtifact token..." TOKEN=$(aws codeartifact get-authorization-token --domain ** --domain-owner *** --region us-west-2 --query authorizationToken --output text || echo "TOKEN_ERROR") if [ "$TOKEN" = "TOKEN_ERROR" ]; then echo "Failed to retrieve token" exit 1 fi echo "Token retrieved successfully" export CODEARTIFACT_AUTH_TOKEN=$TOKEN
Remember that CodeArtifact authorization tokens are valid for 12 hours by default, so if you're testing repeatedly, the token retrieval should still work even if you already have a valid token.
If you continue to have issues, you might want to consider using AWS Secrets Manager to store the token and retrieve it during the build process instead of generating it on the fly.
Sources
Configure the Swift Package Manager with CodeArtifact - CodeArtifact
CodeArtifact examples using AWS CLI - AWS SDK Code Examples
Configure and use RubyGems and Bundler with CodeArtifact - CodeArtifact
AWS CodeArtifact authentication and tokens - CodeArtifact
answered 9 months ago
Relevant content
asked 3 years ago
asked 4 years ago
asked 4 years ago
asked 5 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated a year ago
