UNPKG

@pulumi/aws

Version:

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

246 lines • 9.22 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.AnomalySubscription = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * 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 * * Using `pulumi import`, import `aws_ce_anomaly_subscription` using the `id`. For example: * * ```sh * $ pulumi import aws:costexplorer/anomalySubscription:AnomalySubscription example AnomalySubscriptionARN * ``` */ 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, id, state, opts) { return new AnomalySubscription(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === AnomalySubscription.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["accountId"] = state ? state.accountId : undefined; resourceInputs["arn"] = state ? state.arn : undefined; resourceInputs["frequency"] = state ? state.frequency : undefined; resourceInputs["monitorArnLists"] = state ? state.monitorArnLists : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["subscribers"] = state ? state.subscribers : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAll"] = state ? state.tagsAll : undefined; resourceInputs["thresholdExpression"] = state ? state.thresholdExpression : undefined; } else { const args = argsOrState; if ((!args || args.frequency === undefined) && !opts.urn) { throw new Error("Missing required property 'frequency'"); } if ((!args || args.monitorArnLists === undefined) && !opts.urn) { throw new Error("Missing required property 'monitorArnLists'"); } if ((!args || args.subscribers === undefined) && !opts.urn) { throw new Error("Missing required property 'subscribers'"); } resourceInputs["accountId"] = args ? args.accountId : undefined; resourceInputs["frequency"] = args ? args.frequency : undefined; resourceInputs["monitorArnLists"] = args ? args.monitorArnLists : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["subscribers"] = args ? args.subscribers : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["thresholdExpression"] = args ? args.thresholdExpression : undefined; resourceInputs["arn"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(AnomalySubscription.__pulumiType, name, resourceInputs, opts); } } exports.AnomalySubscription = AnomalySubscription; /** @internal */ AnomalySubscription.__pulumiType = 'aws:costexplorer/anomalySubscription:AnomalySubscription'; //# sourceMappingURL=anomalySubscription.js.map