Skip to content

Allow using images from other accounts and regions #2011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 29, 2021
Merged
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
24 changes: 0 additions & 24 deletions pkg/types/spec/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"strings"
"time"

"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/cortexlabs/cortex/pkg/consts"
"github.com/cortexlabs/cortex/pkg/lib/aws"
"github.com/cortexlabs/cortex/pkg/lib/cast"
Expand Down Expand Up @@ -1494,31 +1493,8 @@ func validateDockerImagePath(
dockerAuthStr := docker.NoAuth

if regex.IsValidECRURL(image) {
ecrRegion := aws.GetRegionFromECRURL(image)
if ecrRegion != awsClient.Region {
return ErrorRegistryInDifferentRegion(ecrRegion, awsClient.Region)
}

operatorID, _, err := awsClient.GetCachedAccountID()
if err != nil {
return err
}
registryID := aws.GetAccountIDFromECRURL(image)

if operatorID != registryID {
return ErrorRegistryAccountIDMismatch(registryID, operatorID)
}

dockerAuthStr, err = docker.AWSAuthConfig(awsClient)
if err != nil {
if _, ok := errors.CauseOrSelf(err).(awserr.Error); ok {
// because the operator's IAM user != instances's IAM role (which is created by eksctl and
// has access to ECR), if the operator IAM doesn't include ECR access, then this will fail
// even though the instance IAM role may have access; instead, ignore this error because the
// instance will have access (this will result in missing the case where the image does not exist)
return nil
}

return err
}
} else if k8sClient != nil {
Expand Down