Is there a way to get cpu credit balance value inside the burstable ec2 instance instead of getting it from cloudwatch via Internet?

0

I just checked IMDS and there is no such data. What I want to implement is to let the program running on a burstable ec2 moderate itself when it finds the CPU credit balance is not enough. the cloudwatch method is rather heavy and not so real time.

Thanks a lot :-)

1 Answer
2
Accepted Answer

You could create a private VPC endpoint for the CloudWatch Metrics service (the endpoint to choose is com.amazonaws.<region>.monitoring) and that way your instance can access the service without having to go through a NAT Gateway or Internet Gateway.

I'd note that using a VPC endpoint service does come with extra charges: https://aws.amazon.com/privatelink/pricing/

If your instance already has a public or Elastic IP address; or accesses public services via a NAT Gateway then you might as well continue to use that method - traffic between EC2 instances and AWS services always stays on the AWS network even if you are using public IP addresses (this is called out in the VPC FAQ). But if you are only using a NAT Gateway or public/Elastic IP to access CloudWatch Metrics then an endpoint is a better way to go.

profile pictureAWS
EXPERT
answered 25 days ago
profile picture
EXPERT
reviewed 25 days ago
profile picture
EXPERT
reviewed 25 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions