UNPKG

@pulumi/aws

Version:

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

57 lines 2.63 kB
"use strict"; // Copyright 2016-2018, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.TopicEventSubscription = void 0; const lambda = require("../lambda"); const topic = require("./topic"); const topicSubscription = require("./topicSubscription"); const utils = require("../utils"); class TopicEventSubscription extends lambda.EventSubscription { constructor(name, topic, handler, args = {}, opts = {}) { // We previously did not parent the subscription to the topic. We now do. Provide an alias // so this doesn't cause resources to be destroyed/recreated for existing stacks. super("aws:sns:TopicEventSubscription", name, { parent: topic, ...utils.withAlias(opts, { parent: opts.parent }), }); this.topic = topic; const parentOpts = { parent: this }; this.func = lambda.createFunctionFromEventHandler(name, handler, parentOpts); this.permission = new lambda.Permission(name, { action: "lambda:invokeFunction", function: this.func.name, principal: "sns.amazonaws.com", sourceArn: topic.id, }, parentOpts); this.subscription = new topicSubscription.TopicSubscription(name, { topic: topic.id, protocol: "lambda", endpoint: this.func.arn, confirmationTimeoutInMinutes: args.confirmationTimeoutInMinutes, deliveryPolicy: args.deliveryPolicy, endpointAutoConfirms: args.endpointAutoConfirms, filterPolicy: args.filterPolicy, filterPolicyScope: args.filterPolicyScope, rawMessageDelivery: args.rawMessageDelivery, redrivePolicy: args.redrivePolicy, }, parentOpts); this.registerOutputs(); } } exports.TopicEventSubscription = TopicEventSubscription; topic.Topic.prototype.onEvent = function (name, handler, args, opts) { return new TopicEventSubscription(name, this, handler, args, opts); }; //# sourceMappingURL=snsMixins.js.map