EC2 / Client / create_spot_datafeed_subscription

create_spot_datafeed_subscription#

EC2.Client.create_spot_datafeed_subscription(**kwargs)#

Creates a data feed for Spot Instances, enabling you to view Spot Instance usage logs. You can create one data feed per Amazon Web Services account. For more information, see Spot Instance data feed in the Amazon EC2 User Guide.

See also: AWS API Documentation

Request Syntax

response = client.create_spot_datafeed_subscription(
    DryRun=True|False,
    Bucket='string',
    Prefix='string'
)
Parameters:
  • DryRun (boolean) – Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • Bucket (string) –

    [REQUIRED]

    The name of the Amazon S3 bucket in which to store the Spot Instance data feed. For more information about bucket names, see Bucket naming rules in the Amazon S3 User Guide.

  • Prefix (string) – The prefix for the data feed file names.

Return type:

dict

Returns:

Response Syntax

{
    'SpotDatafeedSubscription': {
        'Bucket': 'string',
        'Fault': {
            'Code': 'string',
            'Message': 'string'
        },
        'OwnerId': 'string',
        'Prefix': 'string',
        'State': 'Active'|'Inactive'
    }
}

Response Structure

  • (dict) –

    Contains the output of CreateSpotDatafeedSubscription.

    • SpotDatafeedSubscription (dict) –

      The Spot Instance data feed subscription.

      • Bucket (string) –

        The name of the Amazon S3 bucket where the Spot Instance data feed is located.

      • Fault (dict) –

        The fault codes for the Spot Instance request, if any.

        • Code (string) –

          The reason code for the Spot Instance state change.

        • Message (string) –

          The message for the Spot Instance state change.

      • OwnerId (string) –

        The Amazon Web Services account ID of the account.

      • Prefix (string) –

        The prefix for the data feed files.

      • State (string) –

        The state of the Spot Instance data feed subscription.

Examples

This example creates a Spot Instance data feed for your AWS account.

response = client.create_spot_datafeed_subscription(
    Bucket='my-s3-bucket',
    Prefix='spotdata',
)

print(response)

Expected Output:

{
    'SpotDatafeedSubscription': {
        'Bucket': 'my-s3-bucket',
        'OwnerId': '123456789012',
        'Prefix': 'spotdata',
        'State': 'Active',
    },
    'ResponseMetadata': {
        '...': '...',
    },
}