Clean up resources

The lab creates a NAT Gateway, VPC Link, load balancers, ECS task, ECR repository, DynamoDB table, CloudWatch log group, and IAM roles. Some of these resources will continue to incur costs if left running.

Delete all stacks using the command:

cd cdk
npx cdk destroy --all --force

Before deleting, check whether DynamoDB contains any data that needs to be kept. After the command completes, open CloudFormation, ECS, ECR, DynamoDB, VPC, and API Gateway to confirm that resources have been deleted. The ECR repository and DynamoDB table are configured with DESTROY removal policies for lab purposes.

Tip for handling stuck ECR DELETE_FAILED errors: If the ECR Repository reports an error that it cannot be deleted because it still contains images, run the force delete command from the AWS CLI:

  1. Access Cloudformation Console -> select the stuck stack.

Cloudformation Console

  1. Or use AWS CLI to remove the stuck stack:
aws ecr delete-repository --repository-name fcaj-products-service --region ap-southeast-1 --force