UNPKG

@pulumi/aws

Version:

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

59 lines 2.71 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.EventRuleEventSubscription = void 0; const lambda = require("../lambda"); const eventRule = require("./eventRule"); const eventTarget = require("./eventTarget"); const utils = require("../utils"); class EventRuleEventSubscription extends lambda.EventSubscription { constructor(name, eventRuleOrSchedule, handler, args, opts = {}) { // We previously did not parent the subscription to the eventRule. We now do. Provide an alias // so this doesn't cause resources to be destroyed/recreated for existing stacks. const parent = typeof eventRuleOrSchedule === "string" ? undefined : eventRuleOrSchedule; super("aws:cloudwatch:EventRuleEventSubscription", name, { parent: parent, ...utils.withAlias(opts, { parent: opts.parent }), }); const parentOpts = { parent: this }; if (typeof eventRuleOrSchedule === "string") { this.eventRule = new eventRule.EventRule(name, { scheduleExpression: eventRuleOrSchedule }, parentOpts); } else { this.eventRule = eventRuleOrSchedule; } this.func = lambda.createFunctionFromEventHandler(name, handler, parentOpts); this.permission = new lambda.Permission(name, { action: "lambda:invokeFunction", function: this.func.name, principal: "events.amazonaws.com", sourceArn: this.eventRule.arn, }, parentOpts); this.target = new eventTarget.EventTarget(name, { rule: this.eventRule.name, arn: this.func.arn, targetId: name, eventBusName: this.eventRule.eventBusName.apply(x => x), }, parentOpts); this.registerOutputs(); } } exports.EventRuleEventSubscription = EventRuleEventSubscription; eventRule.EventRule.prototype.onEvent = function (name, handler, args, opts) { return new EventRuleEventSubscription(name, this, handler, args, opts); }; //# sourceMappingURL=eventRuleMixins.js.map