package awsec2 import ( _init_ "github.com/aws/aws-cdk-go/awscdk/v2/jsii" _jsii_ "github.com/aws/jsii-runtime-go/runtime" "github.com/aws/aws-cdk-go/awscdk/v2" "github.com/aws/aws-cdk-go/awscdk/v2/awsec2/internal" "github.com/aws/constructs-go/constructs/v10" ) // Define an AWS Virtual Private Cloud. // // See the package-level documentation of this package for an overview // of the various dimensions in which you can configure your VPC. // // For example: // // ```ts // const vpc = new ec2.Vpc(this, 'TheVPC', { // ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'), // }) // // // Iterate the private subnets // const selection = vpc.selectSubnets({ // subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS // }); // // for (const subnet of selection.subnets) { // // ... // } // ```. // // Example: // import "github.com/aws/aws-cdk-go/awscdk" // // // vpc := ec2.NewVpc(this, jsii.String("Vpc"), &VpcProps{ // IpAddresses: ec2.IpAddresses_Cidr(jsii.String("10.0.0.0/16")), // }) // // vpcConnector := apprunner.NewVpcConnector(this, jsii.String("VpcConnector"), &VpcConnectorProps{ // Vpc: Vpc, // VpcSubnets: vpc.selectSubnets(&SubnetSelection{ // SubnetType: ec2.SubnetType_PUBLIC, // }), // VpcConnectorName: jsii.String("MyVpcConnector"), // }) // // apprunner.NewService(this, jsii.String("Service"), &ServiceProps{ // Source: apprunner.Source_FromEcrPublic(&EcrPublicProps{ // ImageConfiguration: &ImageConfiguration{ // Port: jsii.Number(8000), // }, // ImageIdentifier: jsii.String("public.ecr.aws/aws-containers/hello-app-runner:latest"), // }), // VpcConnector: VpcConnector, // }) // type Vpc interface { awscdk.Resource IVpc // AZs for this VPC. AvailabilityZones() *[]*string // Indicates if instances launched in this VPC will have public DNS hostnames. DnsHostnamesEnabled() *bool // Indicates if DNS support is enabled for this VPC. DnsSupportEnabled() *bool // The environment this resource belongs to. // // For resources that are created and managed by the CDK // (generally, those created by creating new class instances like Role, Bucket, etc.), // this is always the same as the environment of the stack they belong to; // however, for imported resources // (those obtained from static methods like fromRoleArn, fromBucketName, etc.), // that might be different than the stack they were imported into. Env() *awscdk.ResourceEnvironment // If this is set to true, don't error out on trying to select subnets. IncompleteSubnetDefinition() *bool SetIncompleteSubnetDefinition(val *bool) // Dependencies for internet connectivity. InternetConnectivityEstablished() constructs.IDependable // Internet Gateway for the VPC. // // Note that in case the VPC is configured only // with ISOLATED subnets, this attribute will be `undefined`. InternetGatewayId() *string // List of isolated subnets in this VPC. IsolatedSubnets() *[]ISubnet // The tree node. Node() constructs.Node // Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource. // // This value will resolve to one of the following: // - a concrete value (e.g. `"my-awesome-bucket"`) // - `undefined`, when a name should be generated by CloudFormation // - a concrete name generated automatically during synthesis, in // cross-environment scenarios. PhysicalName() *string // List of private subnets in this VPC. PrivateSubnets() *[]ISubnet // List of public subnets in this VPC. PublicSubnets() *[]ISubnet // The stack in which this resource is defined. Stack() awscdk.Stack // Arn of this VPC. VpcArn() *string // CIDR range for this VPC. VpcCidrBlock() *string VpcCidrBlockAssociations() *[]*string VpcDefaultNetworkAcl() *string VpcDefaultSecurityGroup() *string // Identifier for this VPC. VpcId() *string VpcIpv6CidrBlocks() *[]*string // Returns the id of the VPN Gateway (if enabled). VpnGatewayId() *string // Adds a new client VPN endpoint to this VPC. AddClientVpnEndpoint(id *string, options *ClientVpnEndpointOptions) ClientVpnEndpoint // Adds a new flow log to this VPC. AddFlowLog(id *string, options *FlowLogOptions) FlowLog // Adds a new gateway endpoint to this VPC. AddGatewayEndpoint(id *string, options *GatewayVpcEndpointOptions) GatewayVpcEndpoint // Adds a new interface endpoint to this VPC. AddInterfaceEndpoint(id *string, options *InterfaceVpcEndpointOptions) InterfaceVpcEndpoint // Adds a new VPN connection to this VPC. AddVpnConnection(id *string, options *VpnConnectionOptions) VpnConnection // Apply the given removal policy to this resource. // // The Removal Policy controls what happens to this resource when it stops // being managed by CloudFormation, either because you've removed it from the // CDK application or because you've made a change that requires the resource // to be replaced. // // The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS // account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). ApplyRemovalPolicy(policy awscdk.RemovalPolicy) // Adds a VPN Gateway to this VPC. EnableVpnGateway(options *EnableVpnGatewayOptions) GeneratePhysicalName() *string // Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. `bucket.bucketArn`). // // Normally, this token will resolve to `arnAttr`, but if the resource is // referenced across environments, `arnComponents` will be used to synthesize // a concrete ARN with the resource's physical name. Make sure to reference // `this.physicalName` in `arnComponents`. GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string // Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. `bucket.bucketName`). // // Normally, this token will resolve to `nameAttr`, but if the resource is // referenced across environments, it will be resolved to `this.physicalName`, // which will be a concrete name. GetResourceNameAttribute(nameAttr *string) *string // Return the subnets appropriate for the placement strategy. SelectSubnetObjects(selection *SubnetSelection) *[]ISubnet // Returns IDs of selected subnets. SelectSubnets(selection *SubnetSelection) *SelectedSubnets // Returns a string representation of this construct. ToString() *string } // The jsii proxy struct for Vpc type jsiiProxy_Vpc struct { internal.Type__awscdkResource jsiiProxy_IVpc } func (j *jsiiProxy_Vpc) AvailabilityZones() *[]*string { var returns *[]*string _jsii_.Get( j, "availabilityZones", &returns, ) return returns } func (j *jsiiProxy_Vpc) DnsHostnamesEnabled() *bool { var returns *bool _jsii_.Get( j, "dnsHostnamesEnabled", &returns, ) return returns } func (j *jsiiProxy_Vpc) DnsSupportEnabled() *bool { var returns *bool _jsii_.Get( j, "dnsSupportEnabled", &returns, ) return returns } func (j *jsiiProxy_Vpc) Env() *awscdk.ResourceEnvironment { var returns *awscdk.ResourceEnvironment _jsii_.Get( j, "env", &returns, ) return returns } func (j *jsiiProxy_Vpc) IncompleteSubnetDefinition() *bool { var returns *bool _jsii_.Get( j, "incompleteSubnetDefinition", &returns, ) return returns } func (j *jsiiProxy_Vpc) InternetConnectivityEstablished() constructs.IDependable { var returns constructs.IDependable _jsii_.Get( j, "internetConnectivityEstablished", &returns, ) return returns } func (j *jsiiProxy_Vpc) InternetGatewayId() *string { var returns *string _jsii_.Get( j, "internetGatewayId", &returns, ) return returns } func (j *jsiiProxy_Vpc) IsolatedSubnets() *[]ISubnet { var returns *[]ISubnet _jsii_.Get( j, "isolatedSubnets", &returns, ) return returns } func (j *jsiiProxy_Vpc) Node() constructs.Node { var returns constructs.Node _jsii_.Get( j, "node", &returns, ) return returns } func (j *jsiiProxy_Vpc) PhysicalName() *string { var returns *string _jsii_.Get( j, "physicalName", &returns, ) return returns } func (j *jsiiProxy_Vpc) PrivateSubnets() *[]ISubnet { var returns *[]ISubnet _jsii_.Get( j, "privateSubnets", &returns, ) return returns } func (j *jsiiProxy_Vpc) PublicSubnets() *[]ISubnet { var returns *[]ISubnet _jsii_.Get( j, "publicSubnets", &returns, ) return returns } func (j *jsiiProxy_Vpc) Stack() awscdk.Stack { var returns awscdk.Stack _jsii_.Get( j, "stack", &returns, ) return returns } func (j *jsiiProxy_Vpc) VpcArn() *string { var returns *string _jsii_.Get( j, "vpcArn", &returns, ) return returns } func (j *jsiiProxy_Vpc) VpcCidrBlock() *string { var returns *string _jsii_.Get( j, "vpcCidrBlock", &returns, ) return returns } func (j *jsiiProxy_Vpc) VpcCidrBlockAssociations() *[]*string { var returns *[]*string _jsii_.Get( j, "vpcCidrBlockAssociations", &returns, ) return returns } func (j *jsiiProxy_Vpc) VpcDefaultNetworkAcl() *string { var returns *string _jsii_.Get( j, "vpcDefaultNetworkAcl", &returns, ) return returns } func (j *jsiiProxy_Vpc) VpcDefaultSecurityGroup() *string { var returns *string _jsii_.Get( j, "vpcDefaultSecurityGroup", &returns, ) return returns } func (j *jsiiProxy_Vpc) VpcId() *string { var returns *string _jsii_.Get( j, "vpcId", &returns, ) return returns } func (j *jsiiProxy_Vpc) VpcIpv6CidrBlocks() *[]*string { var returns *[]*string _jsii_.Get( j, "vpcIpv6CidrBlocks", &returns, ) return returns } func (j *jsiiProxy_Vpc) VpnGatewayId() *string { var returns *string _jsii_.Get( j, "vpnGatewayId", &returns, ) return returns } // Vpc creates a VPC that spans a whole region. // // It will automatically divide the provided VPC CIDR range, and create public and private subnets per Availability Zone. // Network routing for the public subnets will be configured to allow outbound access directly via an Internet Gateway. // Network routing for the private subnets will be configured to allow outbound access via a set of resilient NAT Gateways (one per AZ). func NewVpc(scope constructs.Construct, id *string, props *VpcProps) Vpc { _init_.Initialize() if err := validateNewVpcParameters(scope, id, props); err != nil { panic(err) } j := jsiiProxy_Vpc{} _jsii_.Create( "aws-cdk-lib.aws_ec2.Vpc", []interface{}{scope, id, props}, &j, ) return &j } // Vpc creates a VPC that spans a whole region. // // It will automatically divide the provided VPC CIDR range, and create public and private subnets per Availability Zone. // Network routing for the public subnets will be configured to allow outbound access directly via an Internet Gateway. // Network routing for the private subnets will be configured to allow outbound access via a set of resilient NAT Gateways (one per AZ). func NewVpc_Override(v Vpc, scope constructs.Construct, id *string, props *VpcProps) { _init_.Initialize() _jsii_.Create( "aws-cdk-lib.aws_ec2.Vpc", []interface{}{scope, id, props}, v, ) } func (j *jsiiProxy_Vpc)SetIncompleteSubnetDefinition(val *bool) { if err := j.validateSetIncompleteSubnetDefinitionParameters(val); err != nil { panic(err) } _jsii_.Set( j, "incompleteSubnetDefinition", val, ) } // Import an existing VPC by querying the AWS environment this stack is deployed to. // // This function only needs to be used to use VPCs not defined in your CDK // application. If you are looking to share a VPC between stacks, you can // pass the `Vpc` object between stacks and use it as normal. // // Calling this method will lead to a lookup when the CDK CLI is executed. // You can therefore not use any values that will only be available at // CloudFormation execution time (i.e., Tokens). // // The VPC information will be cached in `cdk.context.json` and the same VPC // will be used on future runs. To refresh the lookup, you will have to // evict the value from the cache using the `cdk context` command. See // https://docs.aws.amazon.com/cdk/latest/guide/context.html for more information. func Vpc_FromLookup(scope constructs.Construct, id *string, options *VpcLookupOptions) IVpc { _init_.Initialize() if err := validateVpc_FromLookupParameters(scope, id, options); err != nil { panic(err) } var returns IVpc _jsii_.StaticInvoke( "aws-cdk-lib.aws_ec2.Vpc", "fromLookup", []interface{}{scope, id, options}, &returns, ) return returns } // Import a VPC by supplying all attributes directly. // // NOTE: using `fromVpcAttributes()` with deploy-time parameters (like a `Fn.importValue()` or // `CfnParameter` to represent a list of subnet IDs) sometimes accidentally works. It happens // to work for constructs that need a list of subnets (like `AutoScalingGroup` and `eks.Cluster`) // but it does not work for constructs that need individual subnets (like // `Instance`). See https://github.com/aws/aws-cdk/issues/4118 for more // information. // // Prefer to use `Vpc.fromLookup()` instead. func Vpc_FromVpcAttributes(scope constructs.Construct, id *string, attrs *VpcAttributes) IVpc { _init_.Initialize() if err := validateVpc_FromVpcAttributesParameters(scope, id, attrs); err != nil { panic(err) } var returns IVpc _jsii_.StaticInvoke( "aws-cdk-lib.aws_ec2.Vpc", "fromVpcAttributes", []interface{}{scope, id, attrs}, &returns, ) return returns } // Checks if `x` is a construct. // // Use this method instead of `instanceof` to properly detect `Construct` // instances, even when the construct library is symlinked. // // Explanation: in JavaScript, multiple copies of the `constructs` library on // disk are seen as independent, completely different libraries. As a // consequence, the class `Construct` in each copy of the `constructs` library // is seen as a different class, and an instance of one class will not test as // `instanceof` the other class. `npm install` will not create installations // like this, but users may manually symlink construct libraries together or // use a monorepo tool: in those cases, multiple copies of the `constructs` // library can be accidentally installed, and `instanceof` will behave // unpredictably. It is safest to avoid using `instanceof`, and using // this type-testing method instead. // // Returns: true if `x` is an object created from a class which extends `Construct`. func Vpc_IsConstruct(x interface{}) *bool { _init_.Initialize() if err := validateVpc_IsConstructParameters(x); err != nil { panic(err) } var returns *bool _jsii_.StaticInvoke( "aws-cdk-lib.aws_ec2.Vpc", "isConstruct", []interface{}{x}, &returns, ) return returns } // Returns true if the construct was created by CDK, and false otherwise. func Vpc_IsOwnedResource(construct constructs.IConstruct) *bool { _init_.Initialize() if err := validateVpc_IsOwnedResourceParameters(construct); err != nil { panic(err) } var returns *bool _jsii_.StaticInvoke( "aws-cdk-lib.aws_ec2.Vpc", "isOwnedResource", []interface{}{construct}, &returns, ) return returns } // Check whether the given construct is a Resource. func Vpc_IsResource(construct constructs.IConstruct) *bool { _init_.Initialize() if err := validateVpc_IsResourceParameters(construct); err != nil { panic(err) } var returns *bool _jsii_.StaticInvoke( "aws-cdk-lib.aws_ec2.Vpc", "isResource", []interface{}{construct}, &returns, ) return returns } func Vpc_DEFAULT_CIDR_RANGE() *string { _init_.Initialize() var returns *string _jsii_.StaticGet( "aws-cdk-lib.aws_ec2.Vpc", "DEFAULT_CIDR_RANGE", &returns, ) return returns } func Vpc_DEFAULT_SUBNETS() *[]*SubnetConfiguration { _init_.Initialize() var returns *[]*SubnetConfiguration _jsii_.StaticGet( "aws-cdk-lib.aws_ec2.Vpc", "DEFAULT_SUBNETS", &returns, ) return returns } func Vpc_DEFAULT_SUBNETS_NO_NAT() *[]*SubnetConfiguration { _init_.Initialize() var returns *[]*SubnetConfiguration _jsii_.StaticGet( "aws-cdk-lib.aws_ec2.Vpc", "DEFAULT_SUBNETS_NO_NAT", &returns, ) return returns } func (v *jsiiProxy_Vpc) AddClientVpnEndpoint(id *string, options *ClientVpnEndpointOptions) ClientVpnEndpoint { if err := v.validateAddClientVpnEndpointParameters(id, options); err != nil { panic(err) } var returns ClientVpnEndpoint _jsii_.Invoke( v, "addClientVpnEndpoint", []interface{}{id, options}, &returns, ) return returns } func (v *jsiiProxy_Vpc) AddFlowLog(id *string, options *FlowLogOptions) FlowLog { if err := v.validateAddFlowLogParameters(id, options); err != nil { panic(err) } var returns FlowLog _jsii_.Invoke( v, "addFlowLog", []interface{}{id, options}, &returns, ) return returns } func (v *jsiiProxy_Vpc) AddGatewayEndpoint(id *string, options *GatewayVpcEndpointOptions) GatewayVpcEndpoint { if err := v.validateAddGatewayEndpointParameters(id, options); err != nil { panic(err) } var returns GatewayVpcEndpoint _jsii_.Invoke( v, "addGatewayEndpoint", []interface{}{id, options}, &returns, ) return returns } func (v *jsiiProxy_Vpc) AddInterfaceEndpoint(id *string, options *InterfaceVpcEndpointOptions) InterfaceVpcEndpoint { if err := v.validateAddInterfaceEndpointParameters(id, options); err != nil { panic(err) } var returns InterfaceVpcEndpoint _jsii_.Invoke( v, "addInterfaceEndpoint", []interface{}{id, options}, &returns, ) return returns } func (v *jsiiProxy_Vpc) AddVpnConnection(id *string, options *VpnConnectionOptions) VpnConnection { if err := v.validateAddVpnConnectionParameters(id, options); err != nil { panic(err) } var returns VpnConnection _jsii_.Invoke( v, "addVpnConnection", []interface{}{id, options}, &returns, ) return returns } func (v *jsiiProxy_Vpc) ApplyRemovalPolicy(policy awscdk.RemovalPolicy) { if err := v.validateApplyRemovalPolicyParameters(policy); err != nil { panic(err) } _jsii_.InvokeVoid( v, "applyRemovalPolicy", []interface{}{policy}, ) } func (v *jsiiProxy_Vpc) EnableVpnGateway(options *EnableVpnGatewayOptions) { if err := v.validateEnableVpnGatewayParameters(options); err != nil { panic(err) } _jsii_.InvokeVoid( v, "enableVpnGateway", []interface{}{options}, ) } func (v *jsiiProxy_Vpc) GeneratePhysicalName() *string { var returns *string _jsii_.Invoke( v, "generatePhysicalName", nil, // no parameters &returns, ) return returns } func (v *jsiiProxy_Vpc) GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string { if err := v.validateGetResourceArnAttributeParameters(arnAttr, arnComponents); err != nil { panic(err) } var returns *string _jsii_.Invoke( v, "getResourceArnAttribute", []interface{}{arnAttr, arnComponents}, &returns, ) return returns } func (v *jsiiProxy_Vpc) GetResourceNameAttribute(nameAttr *string) *string { if err := v.validateGetResourceNameAttributeParameters(nameAttr); err != nil { panic(err) } var returns *string _jsii_.Invoke( v, "getResourceNameAttribute", []interface{}{nameAttr}, &returns, ) return returns } func (v *jsiiProxy_Vpc) SelectSubnetObjects(selection *SubnetSelection) *[]ISubnet { if err := v.validateSelectSubnetObjectsParameters(selection); err != nil { panic(err) } var returns *[]ISubnet _jsii_.Invoke( v, "selectSubnetObjects", []interface{}{selection}, &returns, ) return returns } func (v *jsiiProxy_Vpc) SelectSubnets(selection *SubnetSelection) *SelectedSubnets { if err := v.validateSelectSubnetsParameters(selection); err != nil { panic(err) } var returns *SelectedSubnets _jsii_.Invoke( v, "selectSubnets", []interface{}{selection}, &returns, ) return returns } func (v *jsiiProxy_Vpc) ToString() *string { var returns *string _jsii_.Invoke( v, "toString", nil, // no parameters &returns, ) return returns }