A build role can read packages from CodeArtifact and has codeartifact:GetAuthorizationToken permission on its domain, but token requests fail with an AccessDenied error for sts:GetServiceBearerToken. Which change grants the missing permission with the narrowest service scope?
Show the answer
Correct answerD. Allow sts:GetServiceBearerToken in the role policy, conditioned on sts:AWSServiceName being codeartifact.amazonaws.com.
AWhy not this: GetAuthorizationToken is already allowed and is a domain-level permission, not a repository-level permission.
BWhy not this: AssumeRole obtains role credentials, not the service bearer token required by CodeArtifact.
CWhy not this: A CodeArtifact domain resource policy cannot grant the required sts:GetServiceBearerToken permission.
DWhy this is right: The role policy grants the missing STS action while restricting the service for which a bearer token can be requested.
CodeArtifact token retrieval requires sts:GetServiceBearerToken in an identity-based policy; the service-name condition limits its use to CodeArtifact. Adding that permission to a CodeArtifact domain policy has no effect.