Spot Instance data feed
To help you understand the charges for your Spot Instances, Amazon EC2 provides a data feed that describes your Spot Instance usage and pricing. This data feed is sent to an Amazon S3 bucket that you specify when you subscribe to the data feed.
Data feed files arrive in your bucket typically once an hour, and each hour of usage is typically covered in a single data file. These files are compressed (gzip) before they are delivered to your bucket. Amazon EC2 can write multiple files for a given hour of usage where files are large (for example, when file contents for the hour exceed 50 MB before compression).
You can create only one Spot Instance data feed per AWS account. If you don't have a Spot Instance running during a certain hour, you don't receive a data feed file for that hour.
Spot Instance data feed is supported in all AWS Regions except China (Beijing), China (Ningxia), AWS GovCloud (US), and the Regions that are disabled by default.
Contents
Data feed file name and format
The Spot Instance data feed file name uses the following format (with the date and hour in UTC):
bucket-name
.s3.amazonaws.com/optional-prefix
/aws-account-id.YYYY-MM-DD-HH.n.unique-id.gz
For example, if your bucket name is my-bucket-name
and your
prefix is my-prefix
, your file names are similar to the
following:
my-bucket-name
.s3.amazonaws.com/my-prefix
/111122223333
.2019-03-17-20.001.pwBdGTJG.gz
For more information about bucket names, see Rules for bucket naming in the Amazon Simple Storage Service User Guide.
The Spot Instance data feed files are tab-delimited. Each line in the data file corresponds to one instance hour and contains the fields listed in the following table.
Field | Description |
---|---|
|
The timestamp used to determine the price charged for this instance usage. |
|
The type of usage and instance type being charged for. For
|
|
The product being charged for. For Linux Spot Instances, this field is
set to |
|
The ID of the Spot Instance that generated this instance usage. |
|
The ID for the Spot Instance request that generated this instance usage. |
|
The maximum price specified for this Spot request. |
|
The Spot price at the time specified in the
|
|
The price charged for this instance usage. |
|
The version included in the data feed file name for this record. |
Amazon S3 bucket requirements
When you subscribe to the data feed, you must specify an Amazon S3 bucket to store the data feed files.
Before you choose an Amazon S3 bucket for the data feed, consider the following:
-
You must have
FULL_CONTROL
permission to the bucket, which includes permission for thes3:GetBucketAcl
ands3:PutBucketAcl
actions.If you're the bucket owner, you have this permission by default. Otherwise, the bucket owner must grant your AWS account this permission.
-
When you subscribe to a data feed, these permissions are used to update the bucket ACL to give the AWS data feed account
FULL_CONTROL
permission. The AWS data feed account writes data feed files to the bucket. If your account doesn't have the required permissions, the data feed files cannot be written to the bucket.Note If you update the ACL and remove the permissions for the AWS data feed account, the data feed files cannot be written to the bucket. You must resubscribe to the data feed to receive the data feed files.
-
Each data feed file has its own ACL (separate from the ACL for the bucket). The bucket owner has
FULL_CONTROL
permission to the data files. The AWS data feed account has read and write permissions. -
If you delete your data feed subscription, Amazon EC2 doesn't remove the read and write permissions for the AWS data feed account on either the bucket or the data files. You must remove these permissions yourself.
-
You must use a customer managed key if you encrypt your Amazon S3 bucket using server-side encryption with a AWS KMS key stored in AWS Key Management Service (SSE-KMS). For more information, see Amazon S3 bucket server-side encryption in the Amazon CloudWatch Logs User Guide.
Note For Spot Instance data feed, the resource that generates the S3 files is no longer Amazon CloudWatch Logs. Therefore, you must remove the
aws:SourceArn
section from the S3 bucket permission policy and from the KMS policy.
Subscribe to your Spot Instance data feed
To subscribe to your data feed, use the create-spot-datafeed-subscription command.
aws ec2 create-spot-datafeed-subscription \ --bucket
my-bucket-name
\ [--prefixmy-prefix
]
Example output
{
"SpotDatafeedSubscription": {
"OwnerId": "111122223333",
"Bucket": "my-bucket-name
",
"Prefix": "my-prefix
",
"State": "Active"
}
}
Describe your Spot Instance data feed
To describe your data feed subscription, use the describe-spot-datafeed-subscription command.
aws ec2 describe-spot-datafeed-subscription
Example output
{
"SpotDatafeedSubscription": {
"OwnerId": "123456789012",
"Prefix": "spotdata",
"Bucket": "my-s3-bucket",
"State": "Active"
}
}
Delete your Spot Instance data feed
To delete your data feed, use the delete-spot-datafeed-subscription command.
aws ec2 delete-spot-datafeed-subscription