How to stop AWS EC2 Container Service (Fargate) from running - amazon-web-services

I had a container service instance i believe running in ECS/EC2. I deleted the EC2 instance and any ECS cluster around 12:30pm yesterday. Now over 24 hours i noticed that the cost of vCPU usage is still going up even though i deleted the EC2 Instance and ECS Cluster under US East 2 (Ohio) region as that what it states on the bill.
But i still see an increase under the following resource AWS Fargate - vCPU - US East 2 (Ohio) when i navigate to the bills area why?
I double checked everywhere under the various regions and i cannot see anything still running or being consumed. I can only see "inactive" Task Definitions.
So how do i prevent from incurring further costs?
Has anyone come across this before?

Whether you are using EC2 or Fargate launch type, you still need a cluster to host your tasks. So if there is no cluster in your account, you should incur no charges. There might be some problem with console UI that is not showing your cluster correctly, it happened to me that I have deleted cluster from console and there was some error which prevented cluster from being completely deleted and I ended up in a weird state where console indicated that the cluster was deleted while it wasn't.
This stuff actually happened to me more than once and not only with ECS so I would always recommend to use CLI to double check your actions.
Run this command
aws ecs list-clusters --region us-east-2
If the output is not empty then you will need to delete that cluster via CLI
aws ecs delete-cluster --cluster <value> --region us-east-2
If the output is empty then there is no cluster running in your Ohio region and those charges were simply delayed a bit.

Related

Is there a proper way to stop ECS tasks and the EC2 instances inside a cluster?

I have 2 ECS clusters in one aws account and planning to shut down 1 of the clusters, the services inside that cluster as well as stop/terminate the ec2 instances in the auto-scaling group. Is there a proper way to achieve this without leaving any traces? I have thought about the following:
Changing number of tasks to 0 in each ECS service (cumbersome as I have 7-8 services)
Setting Desired Count in auto scaling group to 0 (Not sure if this will stop or terminate the EC2 instances)
Any help is appreciated
Assuming you are using AWS Cloudformation to setup the ecs cluster, you can delete the cloudformation stack, that will remove all the resources with respect to that CF stack.
Else, see if this helps - deleting via console : https://docs.aws.amazon.com/AmazonECS/latest/developerguide/delete_cluster.html
Whenever you delete ECS cluster it will delete auto-scalling configuration, which also delete instances managed by autoscalling.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/asg-capacity-providers-delete-capacity-provider.html#:~:text=Option%201%3A%20Use%20the%20delete%20command%20to%20delete%20the%20cluster.

Does AWS ECS Control Plane i.e Cluster cost any thing?

On looking at the EKS Pricing page, its very clear that the cluster i.e control plane as of today costs $.10/hour. Quote from - https://aws.amazon.com/eks/pricing/
You pay $0.10 per hour for each Amazon EKS cluster that you create.
But on looking at ECS pricing page - https://aws.amazon.com/ecs/pricing/, I am not able to figure out the cluster i.e control plane cost. So before creating an ECS cluster and leaving it there irrespective of usage, I want to know how I will be billed.
Please share your thoughts!!!!
Also, my understanding is, for EKS cluster, I will be charged for the cluster irrespective of the usage i.e the cluster is used for deployments/pods/services etc or just left doing nothing. Please correct if wrong.
No, ECS does not have a control plane/cluster fee. You only pay for the EC2 or Fargate resources ECS runs your containers on.
Your understanding about the EKS cluster costs is correct.
Note: There are other fees an ECS cluster can generate, such as CloudWatch Logs and Metrics fees, but that's true for all the AWS compute services, including EKS, Elastic Beanstalk, Lambda, etc.

Does running AWS Redshift/taking/keeping snapshot of it run EC2 instance internally?

I am running few experiments on AWS Redshift in the free tier with a single node dc2.large cluster. I keep a snapshot as I do not need it to run the cluster at night and again restoring from that snapshot the next morning.
I can see my EC2 bill is slowly rising up with the utility but not a single documentation or blog I could find to understand if a running Redshift cluster uses EC2 instance or taking and keeping a snapshot of a Redshift cluster does the same.
Can anyone help me understanding the behavior?
Your usage of Amazon Redshift (including running a cluster and creating/keeping snapshots) should not create a charge for Amazon EC2 resources.
It might generate traffic within the VPC depending upon how you are connecting to it (eg cross-AZ traffic).

AWS Data Pipeline Service creates new ec2 instance

I have created a new DataPipeline to stop some instances e.g tagged as auto-stop/auto-start .
My command is sth like this:
aws ec2 describe-instances --region us-west-2 --filter "Name=tag:auto-stop,Values=yes" "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].[InstanceId]' --output text |xargs aws ec2 stop-instances --region us-west-2 --instance-ids
i.e Stop all instances which are running and tagged as auto-stop:yes in given region
Now as soon as scheduler starts an activity, I see a new t1.micro instance is started with a public ip assigned. My question is,is this behavior normal for Data Pipelines ?
Please provide me any link to documentation and how much I ll be charged for this activity.
If the creation of the associated instance is a normal thing,what is the life-cycle of that instance ?
Yes, this behavior is normal. The t1.micro instance is the one executing the command.
An Ec2Resource object is set up in your Data Pipeline. It can be customized, see documentation: http://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-object-ec2resource.html
By default it's a t1.micro instance that terminates after 50 minutes. You are charged for this instance (EC2 pricing: https://aws.amazon.com/ec2/pricing/).
As mentioned in one of EC2 knowledge base article https://aws.amazon.com/premiumsupport/knowledge-center/stop-start-ec2-instances/:
An Amazon EC2 t1.micro instance is started as the host environment for
execution of a data pipeline. EC2 instances started for this purpose
run for a default timeout period of 50 minutes. All resources used to
host execution of a data pipeline are accrued to your account.
Executing pipelines to stop and restart an EC2 instance for 100
minutes or less will use the same amount of resources as would be used
by simply letting an EC2 t1.micro instance continue to run. You should
stop and restart one or more EC2 t1.micro or larger instances for more
than 100 minutes (50 minutes to stop and 50 minutes to start) to
ensure that the method described in this article does not consume more
resources than are conserved.
The life cycle of the Ec2 Resource is tied to the activities that need to run on that resource. Resource is terminated when activities are complete or the 'terminateAfter' timeout is reached.
I believe, as it stands today, AWS Ec2 does not charge for t1.micro instances.

Mesososphere DCOS cluster on AWS. EC2 instances are terminated and again restarted after they are stopped

I have created a Mesosphere DCOS cluster on AWS using the DCOS template. I want to stop the instances after the day end. But after stopping the instances they are terminated and replaced by new instances. Please suggest how to stop the instances.
If the EC2 instances are detached from the auto scaling groups, is the functioning of the DCOS cluster hampered?
To fully shut down the cluster, follow the steps in the docs, which means deleting the CloudFormation stack as well as removing the S3 bucket that contains config data.
UPDATE: since the OP made it clear that the underlying motivation is to 'pause' the cluster over night in order to cut down on costs, I'm clarifying hereby that this is not possible, currently. In order to keep the configuration data around while minimizing the costs you can scale the DCOS cluster down, for a certain period of time.
I found this is the instance behaviour when a server is part of an autoscaling group. Remove the servers from the autoscaling groups then you can stop them. You can add them back later.
Why does my AWS EC2 Instance terminates when stopped?
http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/detach-instance-asg.html
Luck!