Step 6: Clean up your "hello, world!" application and related resources
You've now successfully made an update to the "Hello, World!" code and redeployed the site. To avoid ongoing charges for resources you created to complete this tutorial, you should delete:
-
Any AWS CloudFormation stacks (or terminate any Amazon EC2 instances, if you created them outside of AWS CloudFormation).
-
Any Amazon S3 buckets.
-
The
HelloWorld_App
application in CodeDeploy. -
The AWS Systems Manager State Manager association for the CodeDeploy agent.
You can use the AWS CLI, the AWS CloudFormation, Amazon S3, Amazon EC2, and CodeDeploy consoles, or the AWS APIs to perform the cleanup.
To use clean up resources (CLI)
-
If you used the AWS CloudFormation stack for this tutorial, delete the stack by calling the delete-stack command against the stack named
CodeDeployDemoStack
. This terminates all accompanying Amazon EC2 instances and delete all accompanying IAM roles originally created by the stack.aws cloudformation delete-stack --stack-name CodeDeployDemoStack
-
To delete the Amazon S3 bucket, call the rm command with the --recursive switch against the bucket named
amzn-s3-demo-bucket
. This deletes the bucket and all objects in the bucket.aws s3 rm s3://amzn-s3-demo-bucket --recursive --region
region
-
To delete the
HelloWorld_App
application from CodeDeploy, call the delete-application command. This deletes all associated deployment group records and deployment records for the application.aws deploy delete-application --application-name HelloWorld_App
-
To delete the Systems Manager State Manager association, call the delete-association command.
aws ssm delete-association --assocation-id
association-id
You can get the
association-id
by calling the describe-association command.aws ssm describe-association --name AWS-ConfigureAWSPackage --targets Key=tag:Name,Values=CodeDeployDemo
-
If you did not use the AWS CloudFormation stack for this tutorial, call the terminate-instances command to terminate Amazon EC2 instances you manually created. Supply the ID of the Amazon EC2 instance to terminate.
aws ec2 terminate-instances --instance-ids
instanceId
To clean up resources (console)
If you used our AWS CloudFormation template for this tutorial, delete the associated AWS CloudFormation stack.
Sign in to the AWS Management Console and open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation
. -
In the search box, type the AWS CloudFormation stack name (for example,
CodeDeployDemoStack
). -
Select the box beside the stack name.
-
In the Actions menu, choose Delete Stack. This deletes the stack, terminate all accompanying Amazon EC2 instances, and delete all accompanying IAM roles.
To terminate Amazon EC2 instances you created outside of an AWS CloudFormation stack:
Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
. -
In the Instances area, choose Instances.
-
In the search box, type the name of Amazon EC2 instance you want to terminate, and then press Enter.
-
Choose the Amazon EC2 instance.
-
Choose Actions, point to Instance State, and then choose Terminate. When prompted, choose Yes, Terminate. Repeat these steps for any additional Amazon EC2 instances.
To delete the Amazon S3 bucket:
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/
. -
In the list of buckets, browse to and choose the name of the Amazon S3 bucket (for example,
amzn-s3-demo-bucket
). -
Before you can delete a bucket, you must first delete its contents. Select all of the files in the bucket, such as
HelloWorld_App.zip
. In the Actions menu, choose Delete. When prompted to confirm the deletion, choose OK. -
After the bucket is empty, you can delete the bucket. In the list of buckets, choose the row of the bucket (but not the bucket name). Choose Delete bucket, and when prompted to confirm, choose OK.
To delete the HelloWorld_App
application from CodeDeploy:
Sign in to the AWS Management Console and open the CodeDeploy console at https://console.aws.amazon.com/codedeploy
. Note
Sign in with the same user that you set up in Getting started with CodeDeploy.
In the navigation pane, expand Deploy, then choose Applications.
-
Choose
HelloWorld_App
. -
Choose Delete application.
-
When prompted, enter
Delete
, and then choose Delete.
To delete the Systems Manager State Manager association:
-
Open the AWS Systems Manager console at https://console.aws.amazon.com/systems-manager.
-
In the navigation pane, choose State Manager.
-
Choose the association you created and choose Delete.
What's next?
If you've arrived here, you have successfully completed a deployment with CodeDeploy. Congratulations!