Skip to main content

anomaly_subscriptions

Creates, updates, deletes, gets or lists an anomaly_subscriptions resource.

Overview

Nameanomaly_subscriptions
TypeResource
Idaws.ce.anomaly_subscriptions

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
account_idstringYour unique account identifier. (pattern: <code>[\S\s]*</code>)
frequencystringThe frequency that anomaly notifications are sent. Notifications are sent either over email (for DAILY and WEEKLY frequencies) or SNS (for IMMEDIATE frequency). For more information, see Creating an Amazon SNS topic for anomaly notifications. (DAILY, IMMEDIATE, WEEKLY)
monitor_arn_listarrayA list of cost anomaly monitors.
subscribersarrayA list of subscribers to notify.
subscription_arnstringThe AnomalySubscription Amazon Resource Name (ARN). (pattern: <code>[\S\s]*</code>)
subscription_namestringThe name for the subscription. (pattern: <code>[\S\s]*</code>)
thresholdnumber (double)(deprecated) An absolute dollar value that must be exceeded by the anomaly's total impact (see Impact for more details) for an anomaly notification to be generated. This field has been deprecated. To specify a threshold, use ThresholdExpression. Continued use of Threshold will be treated as shorthand syntax for a ThresholdExpression. One of Threshold or ThresholdExpression is required for this resource. You cannot specify both.
threshold_expressionobjectUse Expression to filter in various Cost Explorer APIs. Not all Expression types are supported in each API. Refer to the documentation for each specific API to see what is supported. There are two patterns: Simple dimension values. There are three types of simple dimension values: CostCategories, Tags, and Dimensions. Specify the CostCategories field to define a filter that acts on Cost Categories. Specify the Tags field to define a filter that acts on Cost Allocation Tags. Specify the Dimensions field to define a filter that acts on the DimensionValues . For each filter type, you can set the dimension name and values for the filters that you plan to use. For example, you can filter for REGION==us-east-1 OR REGION==us-west-1. For GetRightsizingRecommendation, the Region is a full name (for example, REGION==US East (N. Virginia). The corresponding Expression for this example is as follows: { "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] } } As shown in the previous example, lists of dimension values are combined with OR when applying the filter. You can also set different match options to further control how the filter behaves. Not all APIs support match options. Refer to the documentation for each specific API to see what is supported. For example, you can filter for linked account names that start with "a". The corresponding Expression for this example is as follows: { "Dimensions": { "Key": "LINKED_ACCOUNT_NAME", "MatchOptions": [ "STARTS_WITH" ], "Values": [ "a" ] } } Compound Expression types with logical operations. You can use multiple Expression types and the logical operators AND/OR/NOT to create a list of one or more Expression objects. By doing this, you can filter by more advanced options. For example, you can filter by ((REGION == us-east-1 OR REGION == us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer). The corresponding Expression for this example is as follows: { "And": [ {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] } Because each Expression can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that creates an error: { "And": [ ... ], "Dimensions": { "Key": "USAGE_TYPE", "Values": [ "DataTransfer" ] } } The following is an example of the corresponding error message: "Expression has more than one roots. Only one root operator is allowed for each expression: And, Or, Not, Dimensions, Tags, CostCategories" For the GetRightsizingRecommendation action, a combination of OR and NOT isn't supported. OR isn't supported between different dimensions, or dimensions and tags. NOT operators aren't supported. Dimensions are also limited to LINKED_ACCOUNT, REGION, or RIGHTSIZING_TYPE. For the GetReservationPurchaseRecommendation action, only NOT is supported. AND and OR aren't supported. Dimensions are limited to LINKED_ACCOUNT.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_anomaly_subscriptionsselectregionRetrieves the cost anomaly subscription objects for your account. You can filter using a list of cost anomaly monitor Amazon Resource Names (ARNs).
create_anomaly_subscriptioninsertregion, AnomalySubscriptionAdds an alert subscription to a cost anomaly detection monitor. You can use each subscription to define subscribers with email or SNS notifications. Email subscribers can set an absolute or percentage threshold and a time frequency for receiving notifications.
update_anomaly_subscriptionupdateregion, SubscriptionArnUpdates an existing cost anomaly subscription. Specify the fields that you want to update. Omitted fields are unchanged. The JSON below describes the generic construct for each type. See Request Parameters for possible values as they apply to AnomalySubscription.
delete_anomaly_subscriptiondeleteregionDeletes a cost anomaly subscription.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Retrieves the cost anomaly subscription objects for your account. You can filter using a list of cost anomaly monitor Amazon Resource Names (ARNs).

SELECT
account_id,
frequency,
monitor_arn_list,
subscribers,
subscription_arn,
subscription_name,
threshold,
threshold_expression
FROM aws.ce.anomaly_subscriptions
WHERE region = '{{ region }}' -- required
;

INSERT examples

Adds an alert subscription to a cost anomaly detection monitor. You can use each subscription to define subscribers with email or SNS notifications. Email subscribers can set an absolute or percentage threshold and a time frequency for receiving notifications.

INSERT INTO aws.ce.anomaly_subscriptions (
AnomalySubscription,
ResourceTags,
region
)
SELECT
'{{ AnomalySubscription }}' /* required */,
'{{ ResourceTags }}',
'{{ region }}'
RETURNING
subscription_arn
;

UPDATE examples

Updates an existing cost anomaly subscription. Specify the fields that you want to update. Omitted fields are unchanged. The JSON below describes the generic construct for each type. See Request Parameters for possible values as they apply to AnomalySubscription.

UPDATE aws.ce.anomaly_subscriptions
SET
SubscriptionArn = '{{ SubscriptionArn }}',
Threshold = {{ Threshold }},
Frequency = '{{ Frequency }}',
MonitorArnList = '{{ MonitorArnList }}',
Subscribers = '{{ Subscribers }}',
SubscriptionName = '{{ SubscriptionName }}',
ThresholdExpression = '{{ ThresholdExpression }}'
WHERE
region = '{{ region }}' --required
AND SubscriptionArn = '{{ SubscriptionArn }}' --required
RETURNING
subscription_arn;

DELETE examples

Deletes a cost anomaly subscription.

DELETE FROM aws.ce.anomaly_subscriptions
WHERE region = '{{ region }}' --required
;