diff --git a/internal/test/e2e/ecr.go b/internal/test/e2e/ecr.go new file mode 100644 index 000000000000..9738ba09e7a2 --- /dev/null +++ b/internal/test/e2e/ecr.go @@ -0,0 +1,22 @@ +package e2e + +import ( + "fmt" + + "github.com/go-logr/logr" + + "github.com/aws/eks-anywhere/internal/pkg/ssm" +) + +func (e *E2ESession) loginToPublicECR() error { + e.logger.V(1).Info("Logging in to public ECR") + + command := "aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws" + if err := ssm.Run(e.session, logr.Discard(), e.instanceId, command, ssmTimeout); err != nil { + return fmt.Errorf("sign in to public ecr: %v", err) + } + + e.logger.V(1).Info("Logged in to public ECR") + + return nil +} diff --git a/internal/test/e2e/setup.go b/internal/test/e2e/setup.go index 554d4c98f995..27d1f1aa58ff 100644 --- a/internal/test/e2e/setup.go +++ b/internal/test/e2e/setup.go @@ -178,6 +178,11 @@ func (e *E2ESession) setup(regex string) error { return err } + err = e.loginToPublicECR() + if err != nil { + return err + } + ipPool := e.ipPool.ToString() if ipPool != "" { e.testEnvVars[e2etests.ClusterIPPoolEnvVar] = ipPool