anomaly_subscriptions
Creates, updates, deletes, gets or lists an anomaly_subscriptions resource.
Overview
| Name | anomaly_subscriptions |
| Type | Resource |
| Id | aws.ce.anomaly_subscriptions |
Fields
The following fields are returned by SELECT queries:
- get_anomaly_subscriptions
| Name | Datatype | Description |
|---|---|---|
account_id | string | Your unique account identifier. (pattern: <code>[\S\s]*</code>) |
frequency | string | The 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_list | array | A list of cost anomaly monitors. |
subscribers | array | A list of subscribers to notify. |
subscription_arn | string | The AnomalySubscription Amazon Resource Name (ARN). (pattern: <code>[\S\s]*</code>) |
subscription_name | string | The name for the subscription. (pattern: <code>[\S\s]*</code>) |
threshold | number (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_expression | object | Use 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:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_anomaly_subscriptions | select | region | Retrieves the cost anomaly subscription objects for your account. You can filter using a list of cost anomaly monitor Amazon Resource Names (ARNs). | |
create_anomaly_subscription | insert | region, AnomalySubscription | 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. | |
update_anomaly_subscription | update | region, SubscriptionArn | 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. | |
delete_anomaly_subscription | delete | region | Deletes 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.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- get_anomaly_subscriptions
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
- create_anomaly_subscription
- Manifest
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
;
# Description fields are for documentation purposes
- name: anomaly_subscriptions
props:
- name: region
value: "{{ region }}"
description: Required parameter for the anomaly_subscriptions resource.
- name: AnomalySubscription
description: |
The cost anomaly subscription object that you want to create.
value:
SubscriptionArn: "{{ SubscriptionArn }}"
AccountId: "{{ AccountId }}"
MonitorArnList:
- "{{ MonitorArnList }}"
Subscribers:
- Address: "{{ Address }}"
Type: "{{ Type }}"
Status: "{{ Status }}"
Threshold: {{ Threshold }}
Frequency: "{{ Frequency }}"
SubscriptionName: "{{ SubscriptionName }}"
ThresholdExpression:
Or:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
And:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Dimensions:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
And:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
And:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Dimensions:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
Not:
Or:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
And:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Not:
Or:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
And:
- Or: "{{ Or }}"
And: "{{ And }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Not:
Or: "{{ Or }}"
And: "{{ And }}"
Not: "{{ Not }}"
Dimensions: "{{ Dimensions }}"
Tags: "{{ Tags }}"
CostCategories: "{{ CostCategories }}"
Dimensions:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values: "{{ Values }}"
MatchOptions: "{{ MatchOptions }}"
Dimensions:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
Dimensions:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
Tags:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
CostCategories:
Key: "{{ Key }}"
Values:
- "{{ Values }}"
MatchOptions:
- "{{ MatchOptions }}"
- name: ResourceTags
description: |
An optional list of tags to associate with the specified AnomalySubscription . You can use resource tags to control access to your subscription using IAM policies. Each tag consists of a key and a value, and each key must be unique for the resource. The following restrictions apply to resource tags: Although the maximum number of array members is 200, you can assign a maximum of 50 user-tags to one resource. The remaining are reserved for Amazon Web Services use The maximum length of a key is 128 characters The maximum length of a value is 256 characters Keys and values can only contain alphanumeric characters, spaces, and any of the following: _.:/=+@- Keys and values are case sensitive Keys and values are trimmed for any leading or trailing whitespaces Don’t use aws: as a prefix for your keys. This prefix is reserved for Amazon Web Services use
value:
- Key: "{{ Key }}"
Value: "{{ Value }}"
UPDATE examples
- update_anomaly_subscription
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
- delete_anomaly_subscription
Deletes a cost anomaly subscription.
DELETE FROM aws.ce.anomaly_subscriptions
WHERE region = '{{ region }}' --required
;