Skip to content
v2.278.0

SubnetMapping Struct ​

Specifies a subnet for a load balancer.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_elasticloadbalancingv2 as elbv2 } from 'aws-cdk-lib';

declare const sourceNatIpv6Prefix: elbv2.SourceNatIpv6Prefix;
declare const subnet: ec2.Subnet;
const subnetMapping: elbv2.SubnetMapping = {
  subnet: subnet,

  // the properties below are optional
  allocationId: 'allocationId',
  ipv6Address: 'ipv6Address',
  privateIpv4Address: 'privateIpv4Address',
  sourceNatIpv6Prefix: sourceNatIpv6Prefix,
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2
from aws_cdk import aws_elasticloadbalancingv2 as elbv2

# source_nat_ipv6_prefix: elbv2.SourceNatIpv6Prefix
# subnet: ec2.Subnet

subnet_mapping = elbv2.SubnetMapping(
    subnet=subnet,

    # the properties below are optional
    allocation_id="allocationId",
    ipv6_address="ipv6Address",
    private_ipv4_address="privateIpv4Address",
    source_nat_ipv6_prefix=source_nat_ipv6_prefix
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.elasticloadbalancingv2.*;

SourceNatIpv6Prefix sourceNatIpv6Prefix;
Subnet subnet;

SubnetMapping subnetMapping = SubnetMapping.builder()
        .subnet(subnet)

        // the properties below are optional
        .allocationId("allocationId")
        .ipv6Address("ipv6Address")
        .privateIpv4Address("privateIpv4Address")
        .sourceNatIpv6Prefix(sourceNatIpv6Prefix)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ElasticLoadBalancingV2;

SourceNatIpv6Prefix sourceNatIpv6Prefix;
Subnet subnet;

var subnetMapping = new SubnetMapping {
    Subnet = subnet,

    // the properties below are optional
    AllocationId = "allocationId",
    Ipv6Address = "ipv6Address",
    PrivateIpv4Address = "privateIpv4Address",
    SourceNatIpv6Prefix = sourceNatIpv6Prefix
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var sourceNatIpv6Prefix SourceNatIpv6Prefix
var subnet Subnet

subnetMapping := &SubnetMapping{
	Subnet: subnet,

	// the properties below are optional
	AllocationId: jsii.String("allocationId"),
	Ipv6Address: jsii.String("ipv6Address"),
	PrivateIpv4Address: jsii.String("privateIpv4Address"),
	SourceNatIpv6Prefix: sourceNatIpv6Prefix,
}

Properties ​

allocationIdoptionalstringallocation_idoptionalstrallocationIdoptionalStringAllocationIdoptionalstringAllocationIdoptional*string #
The allocation ID of the Elastic IP address for an internet-facing load balancer.

Default: undefined - AWS default is to allocate a new IP address for internet-facing load balancers

ipv6Addressoptionalstringipv6_addressoptionalstripv6AddressoptionalStringIpv6AddressoptionalstringIpv6Addressoptional*string #
The IPv6 address.

Default: undefined - AWS default is to allocate an IPv6 address from the subnet's pool

privateIpv4Addressoptionalstringprivate_ipv4_addressoptionalstrprivateIpv4AddressoptionalStringPrivateIpv4AddressoptionalstringPrivateIpv4Addressoptional*string #
The private IPv4 address for an internal load balancer.

Default: undefined - AWS default is to allocate a private IPv4 address from the subnet's pool

sourceNatIpv6PrefixoptionalSourceNatIpv6Prefixsource_nat_ipv6_prefixoptionalSourceNatIpv6PrefixsourceNatIpv6PrefixoptionalSourceNatIpv6PrefixSourceNatIpv6PrefixoptionalSourceNatIpv6PrefixSourceNatIpv6PrefixoptionalSourceNatIpv6Prefix #
The IPv6 prefix to use for source NAT for a dual-stack network load balancer with UDP listeners.

Default: undefined - AWS default is SourceNatIpv6Prefix.autoAssigned() for IPv6 load balancers

Specify an IPv6 prefix (/80 netmask) from the subnet CIDR block or SourceNatIpv6Prefix.autoAssigned() to use an IPv6 prefix selected at random from the subnet CIDR block.

subnetISubnetsubnetISubnetsubnetISubnetSubnetISubnetSubnetISubnet required #
The subnet.