UNPKG

@pulumi/awsx

Version:

[![Actions Status](https://github.com/pulumi/pulumi-awsx/workflows/master/badge.svg)](https://github.com/pulumi/pulumi-awsx/actions) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM version](https://badge.fur

188 lines • 6.94 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. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.IngressSecurityGroupRule = exports.EgressSecurityGroupRule = exports.SecurityGroupRule = exports.AllTraffic = exports.IcmpPorts = exports.AllUdpPorts = exports.UdpPorts = exports.AllTcpPorts = exports.TcpPorts = exports.AnyIPv6Location = exports.AnyIPv4Location = void 0; exports.isSimpleSecurityGroupRuleArgs = isSimpleSecurityGroupRuleArgs; const aws = __importStar(require("@pulumi/aws")); const pulumi = __importStar(require("@pulumi/pulumi")); const utils = __importStar(require("../utils")); class AnyIPv4Location { cidrBlocks = ["0.0.0.0/0"]; } exports.AnyIPv4Location = AnyIPv4Location; class AnyIPv6Location { // From https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html // "::/0" - Allow all outbound IPv6 traffic. ipv6CidrBlocks = ["::/0"]; } exports.AnyIPv6Location = AnyIPv6Location; class TcpPorts { fromPort; protocol = "tcp"; toPort; constructor(fromPort, toPort) { this.fromPort = fromPort; if (toPort !== undefined) { this.toPort = toPort; } } } exports.TcpPorts = TcpPorts; const maxPort = 65535; class AllTcpPorts extends TcpPorts { constructor() { super(0, maxPort); } } exports.AllTcpPorts = AllTcpPorts; class UdpPorts { fromPort; protocol = "udp"; toPort; constructor(fromPort, toPort) { this.fromPort = fromPort; if (toPort !== undefined) { this.toPort = toPort; } } } exports.UdpPorts = UdpPorts; class AllUdpPorts extends UdpPorts { constructor() { super(0, maxPort); } } exports.AllUdpPorts = AllUdpPorts; class IcmpPorts { fromPort; protocol = "icmp"; toPort; constructor(fromPort, toPort) { this.fromPort = fromPort; if (toPort !== undefined) { this.toPort = toPort; } } } exports.IcmpPorts = IcmpPorts; class AllTraffic { protocol = "-1"; fromPort = 0; toPort = 0; } exports.AllTraffic = AllTraffic; class SecurityGroupRule extends pulumi.ComponentResource { securityGroupRule; securityGroup; constructor(type, name, securityGroup, args, opts) { super(type, name, {}, { parent: securityGroup, ...opts }); this.securityGroup = securityGroup; this.securityGroupRule = new aws.ec2.SecurityGroupRule(name, { ...args, securityGroupId: securityGroup.id, }, { parent: this }); this.registerOutputs(); } static egressArgs(destination, ports, description) { return SecurityGroupRule.createArgs(destination, ports, description); } static ingressArgs(source, ports, description) { return SecurityGroupRule.createArgs(source, ports, description); } static createArgs(location, ports, description) { return { ...location, ...ports, toPort: utils.ifUndefined(ports.toPort, ports.fromPort), description, }; } static egress(name, securityGroup, destination, ports, description, opts) { return new EgressSecurityGroupRule(name, securityGroup, SecurityGroupRule.egressArgs(destination, ports, description), opts); } static ingress(name, securityGroup, source, ports, description, opts) { return new IngressSecurityGroupRule(name, securityGroup, SecurityGroupRule.ingressArgs(source, ports, description), opts); } } exports.SecurityGroupRule = SecurityGroupRule; class EgressSecurityGroupRule extends SecurityGroupRule { constructor(name, securityGroup, args, opts = {}) { if (isSimpleSecurityGroupRuleArgs(args)) { args = SecurityGroupRule.egressArgs(args.location, args.ports, args.description); } super("awsx:x:ec2:EgressSecurityGroupRule", name, securityGroup, { ...args, type: "egress", }, opts); securityGroup.egressRules.push(this); } } exports.EgressSecurityGroupRule = EgressSecurityGroupRule; class IngressSecurityGroupRule extends SecurityGroupRule { constructor(name, securityGroup, args, opts = {}) { if (isSimpleSecurityGroupRuleArgs(args)) { args = SecurityGroupRule.ingressArgs(args.location, args.ports, args.description); } super("awsx:x:ec2:IngressSecurityGroupRule", name, securityGroup, { ...args, type: "ingress", }, opts); securityGroup.ingressRules.push(this); } } exports.IngressSecurityGroupRule = IngressSecurityGroupRule; /** @internal */ function isSimpleSecurityGroupRuleArgs(obj) { const args = obj; return args && args.location !== undefined && args.ports !== undefined; } // Make sure our exported args shape is compatible with the overwrite shape we're trying to provide. utils.checkCompat(); const test2 = utils.checkCompat(); const test3 = utils.checkCompat(); //# sourceMappingURL=securityGroupRule.js.map