How to Subscribe to an AWS EC2 Spot Instance Auto Feed
An AWS spot instance helps to reduce the running cost of the EC2 instance. The user bids for a spot instance request specifying the maximum price that the user is willing to pay per hour per instance. Once the spot instance request is fulfilled, the instance will continue to run until it is manually terminated or the spot price increases above the maximum bid price. The user is not charged as per the max price; instead the user will be charged at the current spot price in that availability zone. To know the charges for spot instances, Amazon EC2 provides access to a data feed, which details the user’s spot instance usage and pricing every hour.
The present guide demonstrates how to subscribe or delete the spot instances price data feed.
The spot instance pricing data feed is delivered to the S3 bucket. To get the data feed in the S3 bucket, the user needs to create a bucket as well as subscribe to the AWS spot instance data feed. The spot instance data feed will create a folder inside the bucket as per the prefix supplied during creation and will create a file every hour in name format given below.
{Bucket Name}.s3.amazonaws.com/{Optional Prefix}/{AWS Account ID}.{YYYY}-{MM}-{DD}-{HH}.{n}.{Unique ID}.gz
1. Create the S3 bucket. Configure the settings such that the user subscribing to the data feed has full access to the bucket. Learn how to Manage the bucket policies.
[Newvem analytics provides comprehensive visibility to your EC2 footprint with drill downs from a consolidated view to a detailed resource status report. Newvem continuously analyzes EC2 instance utilization patterns and provides a down-to-the-hour picture of your AWS EC2 consumption and usage. Learn More]
3. The spot instance price data feed can be set through the command line tool. First setup the AWS EC2 CLI.
4. Run the command:
ec2-describe-spot-instance-requests --region <region name>
It lists the current spot instance requests.
5. Run the command:
ec2-create-spot-datafeed-subscription --bucket <bucket Name> --prefix <Prefix>
6. The above mentioned command subscribes the user to the price data feed. Every hour the price data feed fill will be created and uploaded to the AWS S3 bucket specified in the above mentioned command.
7. AWS will create a folder (prefix) inside the bucket if a prefix is specified in the command.
8. Inside the price feed, all the files generated every hour will be available. The user can download different files to view the price feed.
9. The spot instance price data feed files will have data, such as the spot instance request number (sir number), instance ID, time when the report was generated, max bid specified by the user, the market price of the spot instance during that hour, and the amount the user was charged for the spot instance that hour.
10. One more sample file with a different time is given below.
11. To delete the spot price data feed request, run the below mentioned command.
ec2-delete-spot-datafeed-subscription
The actual output is given below.
[Newvem analytics tracks your AWS cloud utilization:
- Hourly Utilization Pattern Analysis
- Reserved Instances Decision Tool
- Resource Resizing Opportunities
Get Started For Free or Learn More]
Keywords: Amazon AWS elastic cloud services, Amazon EC2, Cloud Utilization, Amazon Web Services, AWS EC2, Amazon Machine Image, Spot Instance, EC2 Dashboard, EC2 Spot Instances, S3 Bucket, Cloud Automation, Cost Efficiency
You must be logged in to post a comment.