Hello all, I am creating an AWS fargate service us...
# general
a
Hello all, I am creating an AWS fargate service using
awsx.ecs.FargateService
which automatically creates
ecr
repository for the container images. But while attempting to
pulumi destroy
the stack I get this error
* ECR Repository (***-api-server-38-07d115e) not empty, consider using force_delete: RepositoryNotEmptyException: The repository with name '***-api-server-38-07d115e' in registry with id '***' cannot be deleted because it still contains images
Is there a way to force delete the ecr repo which is auto-created by
awsx
? Below is the way I'm creating the
Fargate Service
Copy code
const fargateService = new awsx.ecs.FargateService(`tooling-app-${stackName}`, {
  name: `tooling-app-${stackName}`,
  cluster: fargateCluster,
  desiredCount: 1,
  forceNewDeployment: true,
  taskDefinitionArgs: {
    containers: {
      apolloServer: {
        image: awsx.ecs.Image.fromDockerBuild(
          `tooling-api-server-${stackName}`,
          {
            dockerfile: "../../api-server/Dockerfile",
            context: "../../api-server/",
          }
        ),
        portMappings: [albTargetGroupApiServer],
      },
   }
}
These are the package versions that i am using
Copy code
"@pulumi/aws": "^5.0.0",
"@pulumi/awsx": "^0.40.0",
"@pulumi/pulumi": "^3.0.0"
b
@agreeable-window-77899 no, this is an AWS limitation. You’ll need to clear the images out first
a
thanks for your response @billowy-army-68599 What I ended up doing is to NOT let
awx.ecs.FargateService
create the
ecr
repository. Instead I created the instance explicitly with the
forceDelete: true,
flag and that seems to do the trick. Now it is deleting the
ecr
repo when I do
pulumi destroy
. Here is the code that worked:
Copy code
const toolingApiServerEcrRepo = new aws.ecr.Repository(
  `tooling-app-api-server-${stackName}`,
  {
    name: `tooling-app-api-server-${stackName}`,
    forceDelete: true,
    tags: { app: "tooling-app", stack: stackName },
  }
);
230 Views