aws / copilot-cli

The AWS Copilot CLI is a tool for developers to build, release and operate production ready containerized applications on AWS App Runner or Amazon ECS on AWS Fargate.
https://aws.github.io/copilot-cli/
Apache License 2.0
3.52k stars 414 forks source link

Unable to retrieve Arn attribute for AWS::ECR::Repository, with error #5683

Closed scble closed 8 months ago

scble commented 8 months ago

Environment

I tried to deploy a new svc. I already have 3 environments and 3 services running in each environment.

However, the StackSet-xxxxx-web-infrastructure stack(Description: Cross-regional resources to support the CodePipeline for a workspace) has become UPDATE_ROLLBACK_COMPLETE.

copilot svc delete --name example-app

I tried to delete, but get the error

"Unable to retrieve Arn attribute for AWS::ECR::Repository, with error".

I then tried to run delete again, but get the following message. "✘ couldn't find service example-app in the application xxxxx".

copilot svc init --name example-app I tried executing

Resource handler returned message: "Resource of type 'AWS::ECR::Reposi
      tory' with identifier 'xxxxxxx/example-app' already exists.
      " (RequestToken: xxxxxxxxxxxxxxxx, HandlerErrorCod
      e: AlreadyExists)

I ran init again and it recommended deploying as follows.

Run `copilot svc deploy --name example-app --env test` to deploy your service to a test environment.

Therefore, I ran deploy but it stopped with the following error.

 - An ECS task definition to group your containers and run them on ECS              [delete complete]    [3.8s]
    Resource handler returned message: "Invalid request provided: Create T
    askDefinition: Container.image repository should not be null or empty.
     (Service: AmazonECS; Status Code: 400; Error Code: ClientException; R
    equest ID: 6be2f88f-c21a-4546-8984-806e9a7bfb38; Proxy: null)" (Reques
    tToken: 0932c9f5-648b-8296-b32f-3adb6d795cbe, HandlerErrorCode: Invali
    dRequest)

✅ I checked the stack parameters and found that ContainerImage is specified as a URI in the stack of other successful services, but the failing task has a digest (@sha256:xxxxxxxxxxxxxxxxxxxxxxxxx).

I also ran copilot svc delete and was able to confirm that the service stack was deleted, but I got the following error and the stack for StackSet-xxxx-web-infrastructure was UPDATE_ROLLBACKIN with the following error PROGRESS.

Unable to retrieve Arn attribute for AWS::ECR::Repository, with error message null

Is there any way to recover?

ECR Repository permissions and tags are set.

scble commented 8 months ago

copilot svc init --name example-app I have confirmed that the ECR has been created after executing the following command, and that it has permissions and tags. However, I then received the following error and confirmed that the repository had been deleted.

Unable to retrieve Arn attribute for AWS::ECR::Repository, with error

Therefore, when we look at the resources and output of the stack, we do not recognize the example-app repository, so we cannot proceed with the deployment either.

scble commented 8 months ago

https://github.com/aws/copilot-cli/issues/4296 I don't want to delete the stack because it contains the production environment settings.

scble commented 8 months ago

Sorry, I found the cause. I checked the corresponding stack template from CloudFormation's StackSets and found that there are multiple RepositoryName's. This is as expected.

However, a non-existent ECR repository configuration remained. It was probably deleted manually.

In other words, the problem was not with the newly deployed workloads I wanted to deploy, but with the ECR repository not existing, even though the previously existing ECR configuration was still there.