UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

327 lines (326 loc) • 11.6 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Provides a CE Anomaly Subscription. * * ## Example Usage * * ### Basic Example * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = new aws.costexplorer.AnomalyMonitor("test", { * name: "AWSServiceMonitor", * monitorType: "DIMENSIONAL", * monitorDimension: "SERVICE", * }); * const testAnomalySubscription = new aws.costexplorer.AnomalySubscription("test", { * name: "DAILYSUBSCRIPTION", * frequency: "DAILY", * monitorArnLists: [test.arn], * subscribers: [{ * type: "EMAIL", * address: "abc@example.com", * }], * thresholdExpression: { * dimension: { * key: "ANOMALY_TOTAL_IMPACT_ABSOLUTE", * matchOptions: ["GREATER_THAN_OR_EQUAL"], * values: ["100"], * }, * }, * }); * ``` * * ### Threshold Expression Example * * ### Using a Percentage Threshold * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = new aws.costexplorer.AnomalySubscription("test", { * name: "AWSServiceMonitor", * frequency: "DAILY", * monitorArnLists: [testAwsCeAnomalyMonitor.arn], * subscribers: [{ * type: "EMAIL", * address: "abc@example.com", * }], * thresholdExpression: { * dimension: { * key: "ANOMALY_TOTAL_IMPACT_PERCENTAGE", * matchOptions: ["GREATER_THAN_OR_EQUAL"], * values: ["100"], * }, * }, * }); * ``` * * ### Using an `and` Expression * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = new aws.costexplorer.AnomalySubscription("test", { * name: "AWSServiceMonitor", * frequency: "DAILY", * monitorArnLists: [testAwsCeAnomalyMonitor.arn], * subscribers: [{ * type: "EMAIL", * address: "abc@example.com", * }], * thresholdExpression: { * ands: [ * { * dimension: { * key: "ANOMALY_TOTAL_IMPACT_ABSOLUTE", * matchOptions: ["GREATER_THAN_OR_EQUAL"], * values: ["100"], * }, * }, * { * dimension: { * key: "ANOMALY_TOTAL_IMPACT_PERCENTAGE", * matchOptions: ["GREATER_THAN_OR_EQUAL"], * values: ["50"], * }, * }, * ], * }, * }); * ``` * * ### SNS Example * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const costAnomalyUpdates = new aws.sns.Topic("cost_anomaly_updates", {name: "CostAnomalyUpdates"}); * const snsTopicPolicy = pulumi.all([costAnomalyUpdates.arn, costAnomalyUpdates.arn]).apply(([costAnomalyUpdatesArn, costAnomalyUpdatesArn1]) => aws.iam.getPolicyDocumentOutput({ * policyId: "__default_policy_ID", * statements: [ * { * sid: "AWSAnomalyDetectionSNSPublishingPermissions", * actions: ["SNS:Publish"], * effect: "Allow", * principals: [{ * type: "Service", * identifiers: ["costalerts.amazonaws.com"], * }], * resources: [costAnomalyUpdatesArn], * }, * { * sid: "__default_statement_ID", * actions: [ * "SNS:Subscribe", * "SNS:SetTopicAttributes", * "SNS:RemovePermission", * "SNS:Receive", * "SNS:Publish", * "SNS:ListSubscriptionsByTopic", * "SNS:GetTopicAttributes", * "SNS:DeleteTopic", * "SNS:AddPermission", * ], * conditions: [{ * test: "StringEquals", * variable: "AWS:SourceOwner", * values: [accountId], * }], * effect: "Allow", * principals: [{ * type: "AWS", * identifiers: ["*"], * }], * resources: [costAnomalyUpdatesArn1], * }, * ], * })); * const _default = new aws.sns.TopicPolicy("default", { * arn: costAnomalyUpdates.arn, * policy: snsTopicPolicy.apply(snsTopicPolicy => snsTopicPolicy.json), * }); * const anomalyMonitor = new aws.costexplorer.AnomalyMonitor("anomaly_monitor", { * name: "AWSServiceMonitor", * monitorType: "DIMENSIONAL", * monitorDimension: "SERVICE", * }); * const realtimeSubscription = new aws.costexplorer.AnomalySubscription("realtime_subscription", { * name: "RealtimeAnomalySubscription", * frequency: "IMMEDIATE", * monitorArnLists: [anomalyMonitor.arn], * subscribers: [{ * type: "SNS", * address: costAnomalyUpdates.arn, * }], * }, { * dependsOn: [_default], * }); * ``` * * ## Import * * ### Identity Schema * * #### Required * * - `arn` (String) Amazon Resource Name (ARN) of the Cost Explorer anomaly subscription. * * Using `pulumi import`, import `aws_ce_anomaly_subscription` using the `id`. For example: * * console * * % pulumi import aws_ce_anomaly_subscription.example AnomalySubscriptionARN */ export declare class AnomalySubscription extends pulumi.CustomResource { /** * Get an existing AnomalySubscription resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input<pulumi.ID>, state?: AnomalySubscriptionState, opts?: pulumi.CustomResourceOptions): AnomalySubscription; /** * Returns true if the given object is an instance of AnomalySubscription. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is AnomalySubscription; /** * The unique identifier for the AWS account in which the anomaly subscription ought to be created. */ readonly accountId: pulumi.Output<string>; /** * ARN of the anomaly subscription. */ readonly arn: pulumi.Output<string>; /** * The frequency that anomaly reports are sent. Valid Values: `DAILY` | `IMMEDIATE` | `WEEKLY`. */ readonly frequency: pulumi.Output<string>; /** * A list of cost anomaly monitors. */ readonly monitorArnLists: pulumi.Output<string[]>; /** * The name for the subscription. */ readonly name: pulumi.Output<string>; /** * A subscriber configuration. Multiple subscribers can be defined. */ readonly subscribers: pulumi.Output<outputs.costexplorer.AnomalySubscriptionSubscriber[]>; /** * A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. */ readonly tagsAll: pulumi.Output<{ [key: string]: string; }>; /** * An Expression object used to specify the anomalies that you want to generate alerts for. See Threshold Expression. */ readonly thresholdExpression: pulumi.Output<outputs.costexplorer.AnomalySubscriptionThresholdExpression>; /** * Create a AnomalySubscription resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: AnomalySubscriptionArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering AnomalySubscription resources. */ export interface AnomalySubscriptionState { /** * The unique identifier for the AWS account in which the anomaly subscription ought to be created. */ accountId?: pulumi.Input<string>; /** * ARN of the anomaly subscription. */ arn?: pulumi.Input<string>; /** * The frequency that anomaly reports are sent. Valid Values: `DAILY` | `IMMEDIATE` | `WEEKLY`. */ frequency?: pulumi.Input<string>; /** * A list of cost anomaly monitors. */ monitorArnLists?: pulumi.Input<pulumi.Input<string>[]>; /** * The name for the subscription. */ name?: pulumi.Input<string>; /** * A subscriber configuration. Multiple subscribers can be defined. */ subscribers?: pulumi.Input<pulumi.Input<inputs.costexplorer.AnomalySubscriptionSubscriber>[]>; /** * A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. */ tagsAll?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * An Expression object used to specify the anomalies that you want to generate alerts for. See Threshold Expression. */ thresholdExpression?: pulumi.Input<inputs.costexplorer.AnomalySubscriptionThresholdExpression>; } /** * The set of arguments for constructing a AnomalySubscription resource. */ export interface AnomalySubscriptionArgs { /** * The unique identifier for the AWS account in which the anomaly subscription ought to be created. */ accountId?: pulumi.Input<string>; /** * The frequency that anomaly reports are sent. Valid Values: `DAILY` | `IMMEDIATE` | `WEEKLY`. */ frequency: pulumi.Input<string>; /** * A list of cost anomaly monitors. */ monitorArnLists: pulumi.Input<pulumi.Input<string>[]>; /** * The name for the subscription. */ name?: pulumi.Input<string>; /** * A subscriber configuration. Multiple subscribers can be defined. */ subscribers: pulumi.Input<pulumi.Input<inputs.costexplorer.AnomalySubscriptionSubscriber>[]>; /** * A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * An Expression object used to specify the anomalies that you want to generate alerts for. See Threshold Expression. */ thresholdExpression?: pulumi.Input<inputs.costexplorer.AnomalySubscriptionThresholdExpression>; }