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.
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.|
After you’ve decided that you no longer need the alarm, you can delete it.
To delete your alarm
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/.
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:
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
PROMPT > as-update-auto-scaling-group MyAutoScalingGroup –min-size 0 –max-size 0
Auto Scaling returns the following:
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:
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:
All that remains now is to delete the launch configuration which you have created for this Auto Scaling group.
To delete the launch configuration
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
[ 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
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
AWS SAMPLE RESUMES
|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 Ahmedabad, AWS Training in Bangalore, AWS Training in Chennai, AWS Training in Delhi, AWS Training in Dallas, AWS Training in Hyderabad, AWS Training in London, AWS Training in Mumbai, AWS Training in NewYork, AWS 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.
Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!
|AWS Training||Sep 26 to Oct 11||View Details|
|AWS Training||Sep 30 to Oct 15||View Details|
|AWS Training||Oct 03 to Oct 18||View Details|
|AWS Training||Oct 07 to Oct 22||View Details|
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.
Copyright © 2013 - 2023 MindMajix Technologies