Clean Up

If you are running these labs as part of a formal workshop using Event Engine, the AWS resources and the account will be automatically deleted after the workshop. You dont need to take any further action. If you are runnning these labs in your own AWS account, make sure to delete the resources following the procedure below to avoid unnecessary charges.

Delete unused AWS resources to avoid unnecessary charges

  1. By using the Aurora machine learning labs, you have created additional AWS resources. We recommend you run the commands below to remove these resources once you have completed these labs, to ensure you do not incur any unwanted charges for using these services.

Execute the following commands from the Cloud9 IDE terminal.

aws sagemaker delete-endpoint --endpoint-name auroraml-churn-endpoint

aws sagemaker delete-endpoint-config --endpoint-config-name auroraml-churn-endpoint

aws sagemaker delete-model --model-name $(aws sagemaker list-models --output text --query 'Models[*].[ModelName]' | grep sagemaker-scikit-learn)

aws rds remove-role-from-db-cluster --db-cluster-identifier $(echo $DBENDP | cut -d'.' -f1) \
--role-arn $(aws iam list-roles --query 'Roles[?RoleName==`Cloud9-auroralab-comprehend-access`].Arn' --output text) --feature-name Comprehend

aws rds remove-role-from-db-cluster --db-cluster-identifier $(echo $DBENDP | cut -d'.' -f1) \
--role-arn $(aws iam list-roles --query 'Roles[?RoleName==`Cloud9-auroralab-sagemaker-access`].Arn' --output text) --feature-name SageMaker

aws rds remove-role-from-db-cluster --db-cluster-identifier $(echo $DBENDP | cut -d'.' -f1) \
--role-arn $(aws iam list-roles --query 'Roles[?RoleName==`Cloud9-rds-s3-import-role-forlab`].Arn' --output text) --feature-name s3Import


sleep 2m

aws rds failover-db-cluster --db-cluster-identifier $(echo $DBENDP | cut -d'.' -f1)

aws iam delete-role-policy --role-name Cloud9-auroralab-sagemaker-access --policy-name inline-policy

aws iam delete-role --role-name aws iam delete-role --role-name auroralab-comprehend-access

aws iam delete-role --role-name Cloud9-auroralab-sagemaker-access
    
  1. If you created Aurora PostgreSQL cluster manually, open RDS Console, choose apg-labstack-node Aurora cluster node, click Actions and then choose Delete for each of the Nodes starting with Reader role nodes, and finally Writer role node. After that Cluster deletion will be automatically triggered.
Delete Node
  1. If you did “Lab9: Aurora Global Database”, you also created a NACL in your primary AWS region. Delete it manually by going to the VPC Console.
Delete Stack
  1. If you did “Lab9: Aurora Global Database”, you created an Aurora cluster in a seondary AWS region and promoted it later. Delete the Aurora cluster in the secondary region by following step #1 above.

  2. If you did Lab10: Aurora Serverless, you also created an Aurora Serverless cluster. Repeat the above process to delete the Aurora Serverless cluster as well.

  3. Proceed to CloudFormation Console in your primary AWS region, choose the stack with description “Amazon Aurora PostgreSQL Labs Stackset” and choose Delete. This will take care of deleting the nested stacks as well.

Delete Stack
  1. Verify that all the lab related Cloudformation stacks are deleted successfully in the primary AWS region.

  2. If you did “Lab9: Aurora Global Database”, you also created AWS networking resources and Cloud9 instance in a secondary AWS region. Repeat step #5 above for the secondary AWS region to cleanup all the resources.

  3. Verify that all the lab related Cloudformation stacks are deleted successfully in the secondary AWS region.