aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 6.05 kB
JavaScript
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Connections=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var peer_1=()=>{var tmp=require("./peer");return peer_1=()=>tmp,tmp};class Connections{constructor(props={}){this._securityGroups=new ReactiveList,this._securityGroupRules=new ReactiveList,this.skip=!1,this.remoteRule=!1;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_ConnectionsProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Connections),error}this.connections=this,this._securityGroups.push(...props.securityGroups||[]),this._securityGroupRules.push(...this._securityGroups.asArray()),props.peer&&this._securityGroupRules.push(props.peer),this.defaultPort=props.defaultPort}get securityGroups(){return this._securityGroups.asArray()}addSecurityGroup(...securityGroups){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_ISecurityGroup(securityGroups)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addSecurityGroup),error}for(const securityGroup of securityGroups)this._securityGroups.push(securityGroup),this._securityGroupRules.push(securityGroup)}allowTo(other,portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other),jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowTo),error}if(this.skip)return;const remoteRule=this.remoteRule;this._securityGroups.forEachAndForever(securityGroup=>{other.connections._securityGroupRules.forEachAndForever(rule=>{securityGroup.addEgressRule(rule,portRange,description,remoteRule)})}),this.skip=!0,other.connections.remoteRule=!0;try{other.connections.allowFrom(this,portRange,description)}finally{this.skip=!1,other.connections.remoteRule=!1}}allowFrom(other,portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other),jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowFrom),error}if(this.skip)return;const remoteRule=this.remoteRule;this._securityGroups.forEachAndForever(securityGroup=>{other.connections._securityGroupRules.forEachAndForever(rule=>{securityGroup.addIngressRule(rule,portRange,description,remoteRule)})}),this.skip=!0,other.connections.remoteRule=!0;try{other.connections.allowTo(this,portRange,description)}finally{this.skip=!1,other.connections.remoteRule=!1}}allowInternally(portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowInternally),error}this._securityGroups.forEachAndForever(securityGroup=>{this._securityGroupRules.forEachAndForever(rule=>{securityGroup.addIngressRule(rule,portRange,description),securityGroup.addEgressRule(rule,portRange,description)})})}allowToAnyIpv4(portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowToAnyIpv4),error}this.allowTo(peer_1().Peer.anyIpv4(),portRange,description)}allowFromAnyIpv4(portRange,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_Port(portRange)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowFromAnyIpv4),error}this.allowFrom(peer_1().Peer.anyIpv4(),portRange,description)}allowDefaultPortFrom(other,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowDefaultPortFrom),error}if(!this.defaultPort)throw new Error("Cannot call allowDefaultPortFrom(): this resource has no default port");this.allowFrom(other,this.defaultPort,description)}allowDefaultPortInternally(description){if(!this.defaultPort)throw new Error("Cannot call allowDefaultPortInternally(): this resource has no default port");this.allowInternally(this.defaultPort,description)}allowDefaultPortFromAnyIpv4(description){if(!this.defaultPort)throw new Error("Cannot call allowDefaultPortFromAnyIpv4(): this resource has no default port");this.allowFromAnyIpv4(this.defaultPort,description)}allowToDefaultPort(other,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowToDefaultPort),error}if(other.connections.defaultPort===void 0)throw new Error("Cannot call allowToDefaultPort(): other resource has no default port");this.allowTo(other,other.connections.defaultPort,description)}allowDefaultPortTo(other,description){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IConnectable(other)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.allowDefaultPortTo),error}if(!this.defaultPort)throw new Error("Cannot call allowDefaultPortTo(): this resource has no default port");this.allowTo(other,this.defaultPort,description)}}exports.Connections=Connections,_a=JSII_RTTI_SYMBOL_1,Connections[_a]={fqn:"aws-cdk-lib.aws_ec2.Connections",version:"2.185.0"};class ReactiveList{constructor(){this.elements=new Array,this.listeners=new Array}push(...xs){this.elements.push(...xs);for(const listener of this.listeners)for(const x of xs)listener(x)}forEachAndForever(listener){for(const element of this.elements)listener(element);this.listeners.push(listener)}asArray(){return this.elements.slice()}get length(){return this.elements.length}}