UNPKG

@pulumi/aws

Version:

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

180 lines • 8.63 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, Object.assign(Object.assign({}, 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 ? state.arn : undefined; resourceInputs["cloudwatchAlarms"] = state ? state.cloudwatchAlarms : undefined; resourceInputs["cloudwatchLogs"] = state ? state.cloudwatchLogs : undefined; resourceInputs["cloudwatchMetrics"] = state ? state.cloudwatchMetrics : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["dynamodbs"] = state ? state.dynamodbs : undefined; resourceInputs["dynamodbv2s"] = state ? state.dynamodbv2s : undefined; resourceInputs["elasticsearch"] = state ? state.elasticsearch : undefined; resourceInputs["enabled"] = state ? state.enabled : undefined; resourceInputs["errorAction"] = state ? state.errorAction : undefined; resourceInputs["firehoses"] = state ? state.firehoses : undefined; resourceInputs["https"] = state ? state.https : undefined; resourceInputs["iotAnalytics"] = state ? state.iotAnalytics : undefined; resourceInputs["iotEvents"] = state ? state.iotEvents : undefined; resourceInputs["kafkas"] = state ? state.kafkas : undefined; resourceInputs["kineses"] = state ? state.kineses : undefined; resourceInputs["lambdas"] = state ? state.lambdas : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["republishes"] = state ? state.republishes : undefined; resourceInputs["s3"] = state ? state.s3 : undefined; resourceInputs["sns"] = state ? state.sns : undefined; resourceInputs["sql"] = state ? state.sql : undefined; resourceInputs["sqlVersion"] = state ? state.sqlVersion : undefined; resourceInputs["sqs"] = state ? state.sqs : undefined; resourceInputs["stepFunctions"] = state ? state.stepFunctions : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAll"] = state ? state.tagsAll : undefined; resourceInputs["timestreams"] = state ? state.timestreams : undefined; } else { const args = argsOrState; if ((!args || args.enabled === undefined) && !opts.urn) { throw new Error("Missing required property 'enabled'"); } if ((!args || args.sql === undefined) && !opts.urn) { throw new Error("Missing required property 'sql'"); } if ((!args || args.sqlVersion === undefined) && !opts.urn) { throw new Error("Missing required property 'sqlVersion'"); } resourceInputs["cloudwatchAlarms"] = args ? args.cloudwatchAlarms : undefined; resourceInputs["cloudwatchLogs"] = args ? args.cloudwatchLogs : undefined; resourceInputs["cloudwatchMetrics"] = args ? args.cloudwatchMetrics : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["dynamodbs"] = args ? args.dynamodbs : undefined; resourceInputs["dynamodbv2s"] = args ? args.dynamodbv2s : undefined; resourceInputs["elasticsearch"] = args ? args.elasticsearch : undefined; resourceInputs["enabled"] = args ? args.enabled : undefined; resourceInputs["errorAction"] = args ? args.errorAction : undefined; resourceInputs["firehoses"] = args ? args.firehoses : undefined; resourceInputs["https"] = args ? args.https : undefined; resourceInputs["iotAnalytics"] = args ? args.iotAnalytics : undefined; resourceInputs["iotEvents"] = args ? args.iotEvents : undefined; resourceInputs["kafkas"] = args ? args.kafkas : undefined; resourceInputs["kineses"] = args ? args.kineses : undefined; resourceInputs["lambdas"] = args ? args.lambdas : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["republishes"] = args ? args.republishes : undefined; resourceInputs["s3"] = args ? args.s3 : undefined; resourceInputs["sns"] = args ? args.sns : undefined; resourceInputs["sql"] = args ? args.sql : undefined; resourceInputs["sqlVersion"] = args ? args.sqlVersion : undefined; resourceInputs["sqs"] = args ? args.sqs : undefined; resourceInputs["stepFunctions"] = args ? args.stepFunctions : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["timestreams"] = args ? args.timestreams : undefined; 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