Delete stacks in reverse order (delete main stack first, then auth lambdas, auth base, finally database):
Delete main stack:
aws cloudformation delete-stack \
--stack-name <MAIN_STACK_NAME> \
--region <REGION>
Delete auth lambdas stack:
aws cloudformation delete-stack \
--stack-name <AUTH_LAMBDAS_STACK_NAME> \
--region <REGION>
Delete auth base stack:
aws cloudformation delete-stack \
--stack-name <AUTH_BASE_STACK_NAME> \
--region <REGION>
Delete database stack:
aws cloudformation delete-stack \
--stack-name <DATABASE_STACK_NAME> \
--region <REGION>
Check deletion status:
aws cloudformation list-stacks \
--region <REGION> \
--query 'StackSummaries[?StackStatus==`DELETE_IN_PROGRESS`]'
Note: Deleting stacks will delete all resources created by CloudFormation (Lambda, DynamoDB, API Gateway, etc.)
Empty bucket (delete all objects):
aws s3 rm s3://<BUCKET_NAME> --recursive
Delete bucket:
aws s3 rb s3://<BUCKET_NAME>
Or delete all Lexi buckets:
aws s3 ls | grep lexi | awk '{print $3}' | xargs -I {} aws s3 rb s3://{} --force
Note: S3 bucket must be empty before deletion.
Delete Amplify app (from project directory):
amplify delete
Or via AWS CLI:
aws amplify delete-app \
--app-id <APP_ID> \
--region <REGION>
Delete specific log group:
aws logs delete-log-group \
--log-group-name <LOG_GROUP_NAME> \
--region <REGION>
Or delete all Lexi log groups:
aws logs describe-log-groups \
--log-group-name-prefix /aws/lambda/lexi-be \
--region <REGION> \
--query 'logGroups[].logGroupName' \
--output text | xargs -I {} aws logs delete-log-group --log-group-name {} --region <REGION>
List roles:
aws iam list-roles \
--query 'Roles[?contains(RoleName, `lexi`)].RoleName'
Delete role (must delete inline policies first):
aws iam delete-role --role-name <ROLE_NAME>
After deletion, verify no resources remain:
Check Lambda functions:
aws lambda list-functions \
--region <REGION> \
--query 'Functions[?contains(FunctionName, `lexi`)].FunctionName'
Check DynamoDB tables:
aws dynamodb list-tables --region <REGION>
Check S3 buckets:
aws s3 ls | grep lexi
Check Cognito user pools:
aws cognito-idp list-user-pools \
--max-results 10 \
--region <REGION>
Check API Gateway:
aws apigateway get-rest-apis \
--region <REGION> \
--query 'items[?contains(name, `lexi`)].name'
View current costs:
aws ce get-cost-and-usage \
--time-period Start=2026-05-01,End=2026-05-02 \
--granularity DAILY \
--metrics "UnblendedCost" \
--group-by Type=DIMENSION,Key=SERVICE
View monthly costs:
aws ce get-cost-and-usage \
--time-period Start=2026-05-01,End=2026-05-31 \
--granularity MONTHLY \
--metrics "UnblendedCost"
After completing clean-up, you should have:
You have completed the Lexi workshop! You learned:
✅ Lexi’s serverless architecture ✅ Deploy Lambda, DynamoDB, API Gateway ✅ Integrate Cognito, Bedrock, Transcribe, Polly ✅ Build WebSocket real-time communication ✅ Deploy frontend with Next.js + Amplify ✅ Setup CI/CD pipeline ✅ Monitor and optimize costs ✅ Manage AWS resources
Congratulations on completing the workshop!