UNPKG

@pulumi/aws

Version:

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

180 lines • 7.53 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.TopicRule = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Creates and manages an AWS IoT topic rule. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const mytopic = new aws.sns.Topic("mytopic", {name: "mytopic"}); * const myerrortopic = new aws.sns.Topic("myerrortopic", {name: "myerrortopic"}); * const rule = new aws.iot.TopicRule("rule", { * name: "MyRule", * description: "Example rule", * enabled: true, * sql: "SELECT * FROM 'topic/test'", * sqlVersion: "2016-03-23", * sns: [{ * messageFormat: "RAW", * roleArn: role.arn, * targetArn: mytopic.arn, * }], * errorAction: { * sns: { * messageFormat: "RAW", * roleArn: role.arn, * targetArn: myerrortopic.arn, * }, * }, * }); * const assumeRole = aws.iam.getPolicyDocument({ * statements: [{ * effect: "Allow", * principals: [{ * type: "Service", * identifiers: ["iot.amazonaws.com"], * }], * actions: ["sts:AssumeRole"], * }], * }); * const myrole = new aws.iam.Role("myrole", { * name: "myrole", * assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json), * }); * const mypolicy = aws.iam.getPolicyDocumentOutput({ * statements: [{ * effect: "Allow", * actions: ["sns:Publish"], * resources: [mytopic.arn], * }], * }); * const mypolicyRolePolicy = new aws.iam.RolePolicy("mypolicy", { * name: "mypolicy", * role: myrole.id, * policy: mypolicy.apply(mypolicy => mypolicy.json), * }); * ``` * * ## Import * * Using `pulumi import`, import IoT Topic Rules using the `name`. For example: * * ```sh * $ pulumi import aws:iot/topicRule:TopicRule rule <name> * ``` */ class TopicRule extends pulumi.CustomResource { /** * Get an existing TopicRule 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 TopicRule(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of TopicRule. 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'] === TopicRule.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["arn"] = state?.arn; resourceInputs["cloudwatchAlarms"] = state?.cloudwatchAlarms; resourceInputs["cloudwatchLogs"] = state?.cloudwatchLogs; resourceInputs["cloudwatchMetrics"] = state?.cloudwatchMetrics; resourceInputs["description"] = state?.description; resourceInputs["dynamodbs"] = state?.dynamodbs; resourceInputs["dynamodbv2s"] = state?.dynamodbv2s; resourceInputs["elasticsearch"] = state?.elasticsearch; resourceInputs["enabled"] = state?.enabled; resourceInputs["errorAction"] = state?.errorAction; resourceInputs["firehoses"] = state?.firehoses; resourceInputs["https"] = state?.https; resourceInputs["iotAnalytics"] = state?.iotAnalytics; resourceInputs["iotEvents"] = state?.iotEvents; resourceInputs["kafkas"] = state?.kafkas; resourceInputs["kineses"] = state?.kineses; resourceInputs["lambdas"] = state?.lambdas; resourceInputs["name"] = state?.name; resourceInputs["region"] = state?.region; resourceInputs["republishes"] = state?.republishes; resourceInputs["s3"] = state?.s3; resourceInputs["sns"] = state?.sns; resourceInputs["sql"] = state?.sql; resourceInputs["sqlVersion"] = state?.sqlVersion; resourceInputs["sqs"] = state?.sqs; resourceInputs["stepFunctions"] = state?.stepFunctions; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["timestreams"] = state?.timestreams; } else { const args = argsOrState; if (args?.enabled === undefined && !opts.urn) { throw new Error("Missing required property 'enabled'"); } if (args?.sql === undefined && !opts.urn) { throw new Error("Missing required property 'sql'"); } if (args?.sqlVersion === undefined && !opts.urn) { throw new Error("Missing required property 'sqlVersion'"); } resourceInputs["cloudwatchAlarms"] = args?.cloudwatchAlarms; resourceInputs["cloudwatchLogs"] = args?.cloudwatchLogs; resourceInputs["cloudwatchMetrics"] = args?.cloudwatchMetrics; resourceInputs["description"] = args?.description; resourceInputs["dynamodbs"] = args?.dynamodbs; resourceInputs["dynamodbv2s"] = args?.dynamodbv2s; resourceInputs["elasticsearch"] = args?.elasticsearch; resourceInputs["enabled"] = args?.enabled; resourceInputs["errorAction"] = args?.errorAction; resourceInputs["firehoses"] = args?.firehoses; resourceInputs["https"] = args?.https; resourceInputs["iotAnalytics"] = args?.iotAnalytics; resourceInputs["iotEvents"] = args?.iotEvents; resourceInputs["kafkas"] = args?.kafkas; resourceInputs["kineses"] = args?.kineses; resourceInputs["lambdas"] = args?.lambdas; resourceInputs["name"] = args?.name; resourceInputs["region"] = args?.region; resourceInputs["republishes"] = args?.republishes; resourceInputs["s3"] = args?.s3; resourceInputs["sns"] = args?.sns; resourceInputs["sql"] = args?.sql; resourceInputs["sqlVersion"] = args?.sqlVersion; resourceInputs["sqs"] = args?.sqs; resourceInputs["stepFunctions"] = args?.stepFunctions; resourceInputs["tags"] = args?.tags; resourceInputs["timestreams"] = args?.timestreams; resourceInputs["arn"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(TopicRule.__pulumiType, name, resourceInputs, opts); } } exports.TopicRule = TopicRule; /** @internal */ TopicRule.__pulumiType = 'aws:iot/topicRule:TopicRule'; //# sourceMappingURL=topicRule.js.map