Khi bạn hoàn thành workshop và không muốn tiếp tục sử dụng, hãy xóa tất cả resources để tránh phí phát sinh.
⚠️ Warning: Quá trình này không thể hoàn tác. Tất cả dữ liệu sẽ bị xóa vĩnh viễn.
Phải xóa theo thứ tự ngược lại với deployment:
1. Amplify App (Frontend)
2. Observability Stack
3. Backend Stack
4. Auth Stack
5. Core Stack
6. Certificate Stack
7. DNS Stack
8. CDK Bootstrap (optional)
1. Delete via Console
2. Delete via CLI
# Get app ID
APP_ID=$(aws amplify list-apps \
--query 'apps[?name==`everyonecook-frontend`].appId' \
--output text)
# Delete app
aws amplify delete-app --app-id $APP_ID
S3 buckets phải empty trước khi xóa:
# List all EveryoneCook buckets
aws s3 ls | grep everyonecook
# Empty each bucket (4 buckets)
aws s3 rm s3://everyonecook-content-dev-xxxxx --recursive
aws s3 rm s3://everyonecook-logs-dev-xxxxx --recursive
aws s3 rm s3://everyonecook-emails-dev-xxxxx --recursive
aws s3 rm s3://everyonecook-cdn-logs-dev-xxxxx --recursive
# Or use PowerShell script
$buckets = aws s3 ls | Select-String "everyonecook" | ForEach-Object { $_.ToString().Split()[-1] }
foreach ($bucket in $buckets) {
Write-Host "Emptying bucket: $bucket"
aws s3 rm "s3://$bucket" --recursive
}
1. Delete Observability Stack
cd infrastructure
# Delete Observability stack
npx cdk destroy EveryoneCook-dev-Observability --context environment=dev
# Type 'y' to confirm
2. Delete Backend Stack
# Delete Backend stack
npx cdk destroy EveryoneCook-dev-Backend --context environment=dev
# Type 'y' to confirm
3. Delete Auth Stack
# Delete Auth stack
npx cdk destroy EveryoneCook-dev-Auth --context environment=dev
# Type 'y' to confirm
4. Delete Core Stack
# Delete Core stack (takes 15-20 minutes due to CloudFront)
npx cdk destroy EveryoneCook-dev-Core --context environment=dev
# Type 'y' to confirm
5. Delete Certificate Stack
# Delete Certificate stack
npx cdk destroy EveryoneCook-dev-Certificate --context environment=dev
# Type 'y' to confirm
6. Delete DNS Stack (Optional)
# Delete DNS stack (only if you don't need the domain)
npx cdk destroy EveryoneCook-dev-DNS --context environment=dev
# Type 'y' to confirm
# List remaining stacks
aws cloudformation list-stacks \
--stack-status-filter CREATE_COMPLETE UPDATE_COMPLETE \
--query 'StackSummaries[?contains(StackName, `EveryoneCook-dev`)].StackName'
# Should return empty array
⚠️ Only do this if you’re done with CDK completely:
# Delete CDK bootstrap stack
aws cloudformation delete-stack --stack-name CDKToolkit
# Empty and delete CDK assets bucket
BUCKET_NAME=$(aws s3 ls | grep cdk | awk '{print $3}')
aws s3 rm s3://$BUCKET_NAME --recursive
aws s3 rb s3://$BUCKET_NAME
1. Archive Repository
2. Delete Repository
1. Check CloudFormation
aws cloudformation list-stacks \
--stack-status-filter CREATE_COMPLETE UPDATE_COMPLETE \
| grep EveryoneCook
# Should return nothing
2. Check S3
aws s3 ls | grep everyonecook
# Should return nothing
3. Check Lambda
aws lambda list-functions | grep EveryoneCook
# Should return nothing
4. Check DynamoDB
aws dynamodb list-tables | grep EveryoneCook
# Should return nothing
5. Check API Gateway
aws apigateway get-rest-apis | grep EveryoneCook
# Should return nothing
6. Check Cognito
aws cognito-idp list-user-pools --max-results 10 | grep EveryoneCook
# Should return nothing
7. Check CloudFront
aws cloudfront list-distributions | grep EveryoneCook
# Should return nothing
8. Check OpenSearch
aws opensearch list-domain-names | grep everyonecook
# Should return nothing
9. Check Amplify
aws amplify list-apps | grep everyonecook
# Should return nothing
Immediate:
After 30 days:
Issue: S3 bucket deletion fails
# Force empty and delete
aws s3 rb s3://bucket-name --force
Issue: CloudFormation stack stuck
# Check stack events
aws cloudformation describe-stack-events \
--stack-name EveryoneCook-dev-Core \
--max-items 20
# If stuck, skip failed resources
aws cloudformation delete-stack \
--stack-name EveryoneCook-dev-Core \
--retain-resources ResourceLogicalId
Issue: CloudFront distribution can’t be deleted
# Disable distribution first
DIST_ID=$(aws cloudfront list-distributions \
--query "DistributionList.Items[?Comment=='EveryoneCook-dev'].Id" \
--output text)
# Get ETag
ETAG=$(aws cloudfront get-distribution --id $DIST_ID \
--query "ETag" --output text)
# Disable distribution
aws cloudfront update-distribution \
--id $DIST_ID \
--if-match $ETAG \
--distribution-config file://disabled-config.json
# Wait 15-20 minutes, then delete
aws cloudfront delete-distribution --id $DIST_ID --if-match $ETAG
Issue: DynamoDB table has deletion protection
# Disable deletion protection
aws dynamodb update-table \
--table-name EveryoneCook-dev \
--no-deletion-protection-enabled
# Then delete stack
# Check AWS billing
aws ce get-cost-and-usage \
--time-period Start=2024-01-01,End=2024-01-31 \
--granularity MONTHLY \
--metrics BlendedCost
# Should show decreasing costs
Bạn đã hoàn thành workshop EveryoneCook! Bạn đã học được:
✅ Infrastructure as Code với AWS CDK ✅ Serverless Architecture với Lambda và API Gateway ✅ DynamoDB Single Table Design với username-based PK ✅ OpenSearch với Vietnamese analyzer ✅ CloudFront CDN với Origin Access Control ✅ Cognito Authentication với Lambda triggers ✅ Bedrock AI integration ✅ GitLab version control và CI/CD ✅ AWS Amplify frontend deployment ✅ CloudWatch monitoring và X-Ray tracing
Tổng cộng đã deploy:
Cảm ơn bạn đã hoàn thành workshop! 🎉