UNPKG

@pulumi/aws

Version:

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

252 lines • 8.97 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 * * ### 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 */ 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, { ...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?.accountId; resourceInputs["arn"] = state?.arn; resourceInputs["frequency"] = state?.frequency; resourceInputs["monitorArnLists"] = state?.monitorArnLists; resourceInputs["name"] = state?.name; resourceInputs["subscribers"] = state?.subscribers; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["thresholdExpression"] = state?.thresholdExpression; } else { const args = argsOrState; if (args?.frequency === undefined && !opts.urn) { throw new Error("Missing required property 'frequency'"); } if (args?.monitorArnLists === undefined && !opts.urn) { throw new Error("Missing required property 'monitorArnLists'"); } if (args?.subscribers === undefined && !opts.urn) { throw new Error("Missing required property 'subscribers'"); } resourceInputs["accountId"] = args?.accountId; resourceInputs["frequency"] = args?.frequency; resourceInputs["monitorArnLists"] = args?.monitorArnLists; resourceInputs["name"] = args?.name; resourceInputs["subscribers"] = args?.subscribers; resourceInputs["tags"] = args?.tags; resourceInputs["thresholdExpression"] = args?.thresholdExpression; 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