Hurry! 20% Off Ends SoonRegister Now

Clean Up Process in AWS

When you are finished using a particular Amazon ECS cluster, you should clean up the resources associated with it to avoid incurring charges for resources that you are not using.

Clean-Up in AWS

Some Amazon ECS resources, such as tasks, services, clusters, and container instances, are cleaned up using the Amazon ECS console. Other resources, such as Amazon EC2 instances, Elastic Load Balancing load balancers, and Auto Scaling groups, must be cleaned up manually in the Amazon EC2 console or by deleting the AWS Cloud Formation stack that created them.

If you would like to become an AWS Certified professional, then visit Mindmajix - A Global online training platform: "AWS Online Certification Course".This course will help you to achieve excellence in this domain.

Delete Your CloudWatch Alarm:

After you’ve decided that you no longer need the alarm, you can delete it.

To delete your alarm

  • Open the Amazon CloudWatch console at https:// console.aws.amazon.com/ cloudwatch/.
amazon cloud watch
  • In the Navigation pane, under Regions, click US East (Virginia).
  • Select the check box next to the alarm that you want to delete, and then click Delete.
  • When a confirmation message appears, click ‘Yes, Delete‘.
confirmation message

Delete Your Elastic Load Balancer:

If you decide that you no longer need the load balancer that you created earlier, you can delete it.

Important: The EC2 instances associated with the load balancer continue to run after you delete the load balancer. You continue to accrue charges for the instances while they are running. Deleting a load balancer does not affect the instances registered with the load balancer.

As soon as your load balancer becomes available, AWS bills you for each hour or partial hour for which you keep the load balancer running. After you’ve decided that you no longer wish to have the load balancer, you can delete it too.

To delete your load balancer

Open the Amazon EC2 console at https:// console.aws.amazon.com/ ec2/.

amazon ec2 console
  • In the Navigation pane, under Regions, click US East (Virginia).
  • Under Load Balancers, select the check box next to the load balancer you want to delete, and then click Delete.
  • When a confirmation message appears, click Yes, Delete.
confirmation message

Elastic Load Balancing deletes the load balancer. As soon as the load balancer is deleted, you stop incurring charges for that load balancer.

Caution: Even deleting a load balancer, the Amazon EC2 instances associated with the load balancer still continue to run. You will continue to incur charges on the Amazon EC2 instances if they are still running.

Terminate Your Amazon EC2 Instances in Your Auto Scaling Group:

You can remove an instance from an Auto Scaling group. After the instances are detached, you can manage them independently from the rest of the Auto Scaling group. By detaching an instance, you can:

  • Move an instance out of one Auto Scaling group and attach it to a different one.
  • Test an Auto Scaling group by creating it using existing instances running your application, and then detach these instances from the Auto Scaling group when your tests are complete.

When you detach instances, you have the option of decrementing the desired capacity for the Auto Scaling group by the number of instances being detached. If you choose not to decrement the capacity, Auto Scaling launches new instances to replace the ones that you detached.

If you detach an instance from an Auto Scaling group that is also registered with a load balancer, the instance is deregistered from the load balancer. If connection draining is enabled for your load balancer, Auto Scaling waits for the in-flight requests to complete.

In this section, you will first remove the Amazon EC2 instance, then delete the Auto Scaling group, and finally delete the launch configuration.

You must terminate all Amazon EC2 instances in an Auto Scaling group before you can delete the group. A simple way to terminate all instances in a group is to update the group so that both the minimum size and maximum size are set to zero.

[ Related Article:- Amazon Instances Using Auto Scaling ]

To remove the Amazon EC2 instance from the Auto Scaling group

  • Open a command prompt window from a Windows computer, click Start. In the Search box, type cmd, and then press Enter.
  • You’ll use the as-update-auto-scaling-group command to update the Auto Scaling group which we have been created earlier. At the command prompt, type the following, and then press Enter:

PROMPT > as-update-auto-scaling-group MyAutoScalingGroup –min-size 0 –max-size 0

Auto Scaling returns the following:

OK-Updated AutoScalingGroup

  • Now you’ll use the as-describe-auto-scaling-groups command to verify that Auto Scaling has already removed the instance from MyAutoScalingGroup. It can take a few minutes for the instance to terminate, so you might have to check the status more than once. At the command prompt, type the following, and then press Enter:

PROMPT > as-describe-auto-scaling-groups MyAutoScalingGroup –headers

If the instance termination is still in progress, Auto Scaling returns information similar to the following. (Your value for INSTANCE-ID will differ):

AUTO-SCALING-GROUP GROUP-NAME LAUNCH-CONFIG AVAILABILITY-ZONES LOAD-BALANCERS MIN-SIZE MAX-SIZE DESI RED-CAPACITY

AUTO-SCALING-GROUP MyAutoScalingGroup MyLC us-east-1b, us-east-1c MyLB 0 0 0 INSTANCE INSTANCE-ID AVAILABILITY-ZONE STATE STATUS LAUNCH-CONFIG INSTANCE i-xxxxxxxx us-east-1c In-service Healthy MyLC

Note that you can also click Instances in the Amazon EC2 console to view the status of your instances.

When no instances exist in MyAutoScalingGroup, you can delete the group.

To delete the Auto Scaling group:

  • At the command prompt, type the following, and then press Enter:
  • PROMPT > as-delete-auto-scaling-group MyAutoScalingGroup

To confirm the deletion, type Y, and then press Enter.

Are you sure you want to delete this MyAutoScalingGroup? [Ny]

Auto Scaling returns the following:

OK-Deleted MyAutoScalingGroup

All that remains now is to delete the launch configuration which you have created for this Auto Scaling group.

MindMajix YouTube Channel

To delete the launch configuration

  • At the command prompt, type the following, and then press Enter: PROMPT > as-delete-launch-config MyLC

To confirm the deletion, type Y and then press Enter.

Are you sure you want to delete this launch configuration? [Ny]

Auto Scaling returns the following:

OK-Deleted launch configuration

Terminate Your Instance:

When you’ve decided that you no longer need an instance, you can terminate it. As soon as the state of an instance changes to shutting down or terminated, you stop incurring charges for that instance.

As soon as your instance starts to boot, AWS bills you for each hour or partial hour that you keep the instance running, even if the instance is ‘idle’. You can terminate the instance, so you are no longer charged for it. Because this instance is not a part of your Auto Scaling group, you’ll need to terminate it manually.

To terminate an instance

  • Open the Amazon EC2 console at https:// console.aws.amazon.com/ ec2/.
  • Right-click the instance, and then click Terminate.
  • When you are prompted for confirmation, click yes, terminate. As soon as the instance status changes to shut down or terminate, you stop incurring charges for that instance.

[ Related Article:- Interview Questions and Answers in AWS ]

Delete a Key Pair:

This is an optional step. You are not charged for keeping a key pair, and you may reuse the key pair for later use.

delete-key-pair deletes the specified key pair, by removing the public key from Amazon EC2.

When you delete a key pair, you are only deleting Amazon EC2’s copy of the public key. Deleting a key pair doesn’t affect the private key on your computer or the public key on any instances which has been already launched using that key pair. You can’t launch a new instance using a deleted key pair, but you can continue to connect to any instances that you launched using a deleted key pair, as long as you still have the private key (.pem) file.

To delete a key pair

  • Open the Amazon EC2 console at https:// console.aws.amazon.com/ ec2/.
  • In the Navigation pane, in the Region list, click US East (Virginia).
  • In the Navigation pane, under Region, click Key Pairs.
  • Select the check box beside the key pair you want to delete, and then click Delete.
  • When a confirmation message appears, click Yes, Delete.

Delete an Amazon EC2 Security Group:

A security group acts as a virtual firewall that controls the traffic for one or more instances. When you launch an instance, you associate one or more security groups with the instance.

If you attempt to delete a security group that is associated with an instance, or is referenced by another security group, the operation fails with InvalidGroup.InUse in EC2-Classic or DependencyViolation in EC2-VPC.

To delete a security group

  • Open the Amazon EC2 console at https:// console.aws.amazon.com/ ec2/.
  • In the Navigation pane, under Region, click US East (Virginia).
  • In the Navigation pane, click Security Groups.
  • In the details pane, under Security Groups, Select a security group you want to delete, and then click Delete.
  • Click Yes, Delete.

Sample Resume:
AWS SAMPLE RESUMES

List Of AWS Courses Offered By Mindmajix:

 AWS Certified SysOps Administrator AWS Certified Solutions Architect / Professional
 AWS Certified Developer AWS Certified DevOps Engineer
 AWS Technical Essentials AWS Database Migration Service
 AWS Lambda 2016 and many more...

 

If you interested to learn AWS and build a career in Cloud Computing?  Then check out our AWS Certification Training Course at your near Cities

AWS Training in AhmedabadAWS Training in Bangalore,  AWS Training in Chennai,  AWS Training in Delhi AWS Training in Dallas, AWS Training in HyderabadAWS Training in LondonAWS Training in MumbaiAWS Training in NewYorkAWS Training in Pune

These courses are incorporated with Live instructor-led training, Industry Use cases, and hands-on live projects. This training program will make you an expert in AWS and help you to achieve your dream job.

 

Job Support Program

Online Work Support for your on-job roles.

jobservice

Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:

  • Pay Per Hour
  • Pay Per Week
  • Monthly
Learn MoreGet Job Support
Course Schedule
NameDates
AWS TrainingDec 21 to Jan 05View Details
AWS TrainingDec 24 to Jan 08View Details
AWS TrainingDec 28 to Jan 12View Details
AWS TrainingDec 31 to Jan 15View Details
Last updated: 03 Jul 2024
About Author

Prasanthi is an expert writer in MongoDB, and has written for various reputable online and print publications. At present, she is working for MindMajix, and writes content not only on MongoDB, but also on Sharepoint, Uipath, and AWS.

read less
  1. Share:
AWS Articles