Cross account access to a CodeArtifact repo


I have an IAM user in account A with admin privileges and arn:aws:iam::aws:policy/AWSCodeArtifactReadOnlyAccess attached for good measure.

The iam user from account A has an arn of arn:aws:iam::***:user/test-user.

Account B has a CodeArtifact repo with an arn of arn:aws:codeartifact:***:***:domain/test-repo. This repo has a resource policy of

When running AWS CLI commands, I’m using the access keys for the IAM user from account A. The following command works:

Results in


This demonstrates that my resource policy is working (flipping the Effect to a Deny successful makes the above command fail).

However, the following command

fails with

An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:iam:::user/test-user is not authorized to perform: codeartifact:GetAuthorizationToken on resource: arn:aws:codeartifact::***:domain/test-repo

I believe I’ve followed the docs here:

I would like to accomplish this with the specified principal and would like to not assume a role as it complicates my CI/CD pipeline


I was having this same issue for a couple days, finally figured out there needs to be a policy applied to both the repository AND the codeartifact domain.

This example uses an organization based policy but any principal should work, the only other important part is the permission of sts:GetServiceBearerToken

Leave a Reply