Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cmd/ecr-credential-provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,15 @@ func (e *ecrPlugin) getPrivateCredsData(ctx context.Context, imageHost string, i
func (e *ecrPlugin) buildCredentialsProvider(ctx context.Context, request *v1.CredentialProviderRequest, imageHost string) (aws.CredentialsProvider, error) {
var err error

arn, ok := request.ServiceAccountAnnotations["eks.amazonaws.com/ecr-role-arn"]
if !ok {
arn = os.Getenv("AWS_ECR_ROLE_ARN")
var arn string
if candidateARN, ok := request.ServiceAccountAnnotations["eks.amazonaws.com/ecr-role-arn"]; ok {
arn = candidateARN
} else if candidateARN, ok = os.LookupEnv("AWS_ECR_ROLE_ARN"); ok {
arn = candidateARN
} else if candidateARN, ok = request.ServiceAccountAnnotations["eks.amazonaws.com/role-arn"]; ok {
arn = candidateARN
}

if arn == "" {
return nil, errors.New("no arn provided, cannot assume role using ServiceAccountToken")
}
Expand Down