software.amazon.awscdk.services.ec2.alpha.NatGatewayProps Maven / Gradle / Ivy
Show all versions of ec2-alpha Show documentation
package software.amazon.awscdk.services.ec2.alpha;
/**
* (experimental) Properties to define a NAT gateway.
*
* Example:
*
*
* VpcV2 myVpc = new VpcV2(this, "Vpc");
* RouteTable routeTable = RouteTable.Builder.create(this, "RouteTable")
* .vpc(myVpc)
* .build();
* SubnetV2 subnet = SubnetV2.Builder.create(this, "Subnet")
* .vpc(myVpc)
* .availabilityZone("eu-west-2a")
* .ipv4CidrBlock(new IpCidr("10.0.0.0/24"))
* .subnetType(SubnetType.PRIVATE_ISOLATED)
* .build();
* NatGateway natgw = NatGateway.Builder.create(this, "NatGW")
* .subnet(subnet)
* .vpc(myVpc)
* .connectivityType(NatConnectivityType.PRIVATE)
* .privateIpAddress("10.0.0.42")
* .build();
* Route.Builder.create(this, "NatGwRoute")
* .routeTable(routeTable)
* .destination("0.0.0.0/0")
* .target(Map.of("gateway", natgw))
* .build();
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.102.0 (build e354887)", date = "2024-09-10T01:10:18.082Z")
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.ec2.alpha.$Module.class, fqn = "@aws-cdk/aws-ec2-alpha.NatGatewayProps")
@software.amazon.jsii.Jsii.Proxy(NatGatewayProps.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface NatGatewayProps extends software.amazon.jsii.JsiiSerializable {
/**
* (experimental) The subnet in which the NAT gateway is located.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@org.jetbrains.annotations.NotNull software.amazon.awscdk.services.ec2.ISubnet getSubnet();
/**
* (experimental) AllocationID of Elastic IP address that's associated with the NAT gateway.
*
* This property is required for a public NAT
* gateway and cannot be specified with a private NAT gateway.
*
* Default: attr.allocationID of a new Elastic IP created by default
* //TODO: ADD L2 for elastic ip
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getAllocationId() {
return null;
}
/**
* (experimental) Indicates whether the NAT gateway supports public or private connectivity.
*
* Default: public
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.ec2.alpha.NatConnectivityType getConnectivityType() {
return null;
}
/**
* (experimental) The maximum amount of time to wait before forcibly releasing the IP addresses if connections are still in progress.
*
* Default: 350 seconds
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.Duration getMaxDrainDuration() {
return null;
}
/**
* (experimental) The resource name of the NAT gateway.
*
* Default: none
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getNatGatewayName() {
return null;
}
/**
* (experimental) The private IPv4 address to assign to the NAT gateway.
*
* If you don't provide an
* address, a private IPv4 address will be automatically assigned.
*
* Default: none
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getPrivateIpAddress() {
return null;
}
/**
* (experimental) Secondary EIP allocation IDs.
*
* Default: none
*
* @see https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html#nat-gateway-creating
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getSecondaryAllocationIds() {
return null;
}
/**
* (experimental) The number of secondary private IPv4 addresses you want to assign to the NAT gateway.
*
* SecondaryPrivateIpAddressCount
and SecondaryPrivateIpAddresses
cannot be
* set at the same time.
*
* Default: none
*
* @see https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html#nat-gateway-creating
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.Number getSecondaryPrivateIpAddressCount() {
return null;
}
/**
* (experimental) Secondary private IPv4 addresses.
*
* SecondaryPrivateIpAddressCount
and SecondaryPrivateIpAddresses
cannot be
* set at the same time.
*
* Default: none
*
* @see https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html#nat-gateway-creating
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getSecondaryPrivateIpAddresses() {
return null;
}
/**
* (experimental) The ID of the VPC in which the NAT gateway is located.
*
* Default: none
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.ec2.alpha.IVpcV2 getVpc() {
return null;
}
/**
* @return a {@link Builder} of {@link NatGatewayProps}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link NatGatewayProps}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
software.amazon.awscdk.services.ec2.ISubnet subnet;
java.lang.String allocationId;
software.amazon.awscdk.services.ec2.alpha.NatConnectivityType connectivityType;
software.amazon.awscdk.Duration maxDrainDuration;
java.lang.String natGatewayName;
java.lang.String privateIpAddress;
java.util.List secondaryAllocationIds;
java.lang.Number secondaryPrivateIpAddressCount;
java.util.List secondaryPrivateIpAddresses;
software.amazon.awscdk.services.ec2.alpha.IVpcV2 vpc;
/**
* Sets the value of {@link NatGatewayProps#getSubnet}
* @param subnet The subnet in which the NAT gateway is located. This parameter is required.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder subnet(software.amazon.awscdk.services.ec2.ISubnet subnet) {
this.subnet = subnet;
return this;
}
/**
* Sets the value of {@link NatGatewayProps#getAllocationId}
* @param allocationId AllocationID of Elastic IP address that's associated with the NAT gateway.
* This property is required for a public NAT
* gateway and cannot be specified with a private NAT gateway.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder allocationId(java.lang.String allocationId) {
this.allocationId = allocationId;
return this;
}
/**
* Sets the value of {@link NatGatewayProps#getConnectivityType}
* @param connectivityType Indicates whether the NAT gateway supports public or private connectivity.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder connectivityType(software.amazon.awscdk.services.ec2.alpha.NatConnectivityType connectivityType) {
this.connectivityType = connectivityType;
return this;
}
/**
* Sets the value of {@link NatGatewayProps#getMaxDrainDuration}
* @param maxDrainDuration The maximum amount of time to wait before forcibly releasing the IP addresses if connections are still in progress.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder maxDrainDuration(software.amazon.awscdk.Duration maxDrainDuration) {
this.maxDrainDuration = maxDrainDuration;
return this;
}
/**
* Sets the value of {@link NatGatewayProps#getNatGatewayName}
* @param natGatewayName The resource name of the NAT gateway.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder natGatewayName(java.lang.String natGatewayName) {
this.natGatewayName = natGatewayName;
return this;
}
/**
* Sets the value of {@link NatGatewayProps#getPrivateIpAddress}
* @param privateIpAddress The private IPv4 address to assign to the NAT gateway.
* If you don't provide an
* address, a private IPv4 address will be automatically assigned.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder privateIpAddress(java.lang.String privateIpAddress) {
this.privateIpAddress = privateIpAddress;
return this;
}
/**
* Sets the value of {@link NatGatewayProps#getSecondaryAllocationIds}
* @param secondaryAllocationIds Secondary EIP allocation IDs.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder secondaryAllocationIds(java.util.List secondaryAllocationIds) {
this.secondaryAllocationIds = secondaryAllocationIds;
return this;
}
/**
* Sets the value of {@link NatGatewayProps#getSecondaryPrivateIpAddressCount}
* @param secondaryPrivateIpAddressCount The number of secondary private IPv4 addresses you want to assign to the NAT gateway.
* SecondaryPrivateIpAddressCount
and SecondaryPrivateIpAddresses
cannot be
* set at the same time.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder secondaryPrivateIpAddressCount(java.lang.Number secondaryPrivateIpAddressCount) {
this.secondaryPrivateIpAddressCount = secondaryPrivateIpAddressCount;
return this;
}
/**
* Sets the value of {@link NatGatewayProps#getSecondaryPrivateIpAddresses}
* @param secondaryPrivateIpAddresses Secondary private IPv4 addresses.
* SecondaryPrivateIpAddressCount
and SecondaryPrivateIpAddresses
cannot be
* set at the same time.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder secondaryPrivateIpAddresses(java.util.List secondaryPrivateIpAddresses) {
this.secondaryPrivateIpAddresses = secondaryPrivateIpAddresses;
return this;
}
/**
* Sets the value of {@link NatGatewayProps#getVpc}
* @param vpc The ID of the VPC in which the NAT gateway is located.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder vpc(software.amazon.awscdk.services.ec2.alpha.IVpcV2 vpc) {
this.vpc = vpc;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link NatGatewayProps}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public NatGatewayProps build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link NatGatewayProps}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements NatGatewayProps {
private final software.amazon.awscdk.services.ec2.ISubnet subnet;
private final java.lang.String allocationId;
private final software.amazon.awscdk.services.ec2.alpha.NatConnectivityType connectivityType;
private final software.amazon.awscdk.Duration maxDrainDuration;
private final java.lang.String natGatewayName;
private final java.lang.String privateIpAddress;
private final java.util.List secondaryAllocationIds;
private final java.lang.Number secondaryPrivateIpAddressCount;
private final java.util.List secondaryPrivateIpAddresses;
private final software.amazon.awscdk.services.ec2.alpha.IVpcV2 vpc;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.subnet = software.amazon.jsii.Kernel.get(this, "subnet", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.ISubnet.class));
this.allocationId = software.amazon.jsii.Kernel.get(this, "allocationId", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.connectivityType = software.amazon.jsii.Kernel.get(this, "connectivityType", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.alpha.NatConnectivityType.class));
this.maxDrainDuration = software.amazon.jsii.Kernel.get(this, "maxDrainDuration", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.Duration.class));
this.natGatewayName = software.amazon.jsii.Kernel.get(this, "natGatewayName", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.privateIpAddress = software.amazon.jsii.Kernel.get(this, "privateIpAddress", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.secondaryAllocationIds = software.amazon.jsii.Kernel.get(this, "secondaryAllocationIds", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)));
this.secondaryPrivateIpAddressCount = software.amazon.jsii.Kernel.get(this, "secondaryPrivateIpAddressCount", software.amazon.jsii.NativeType.forClass(java.lang.Number.class));
this.secondaryPrivateIpAddresses = software.amazon.jsii.Kernel.get(this, "secondaryPrivateIpAddresses", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)));
this.vpc = software.amazon.jsii.Kernel.get(this, "vpc", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.alpha.IVpcV2.class));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.subnet = java.util.Objects.requireNonNull(builder.subnet, "subnet is required");
this.allocationId = builder.allocationId;
this.connectivityType = builder.connectivityType;
this.maxDrainDuration = builder.maxDrainDuration;
this.natGatewayName = builder.natGatewayName;
this.privateIpAddress = builder.privateIpAddress;
this.secondaryAllocationIds = builder.secondaryAllocationIds;
this.secondaryPrivateIpAddressCount = builder.secondaryPrivateIpAddressCount;
this.secondaryPrivateIpAddresses = builder.secondaryPrivateIpAddresses;
this.vpc = builder.vpc;
}
@Override
public final software.amazon.awscdk.services.ec2.ISubnet getSubnet() {
return this.subnet;
}
@Override
public final java.lang.String getAllocationId() {
return this.allocationId;
}
@Override
public final software.amazon.awscdk.services.ec2.alpha.NatConnectivityType getConnectivityType() {
return this.connectivityType;
}
@Override
public final software.amazon.awscdk.Duration getMaxDrainDuration() {
return this.maxDrainDuration;
}
@Override
public final java.lang.String getNatGatewayName() {
return this.natGatewayName;
}
@Override
public final java.lang.String getPrivateIpAddress() {
return this.privateIpAddress;
}
@Override
public final java.util.List getSecondaryAllocationIds() {
return this.secondaryAllocationIds;
}
@Override
public final java.lang.Number getSecondaryPrivateIpAddressCount() {
return this.secondaryPrivateIpAddressCount;
}
@Override
public final java.util.List getSecondaryPrivateIpAddresses() {
return this.secondaryPrivateIpAddresses;
}
@Override
public final software.amazon.awscdk.services.ec2.alpha.IVpcV2 getVpc() {
return this.vpc;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
data.set("subnet", om.valueToTree(this.getSubnet()));
if (this.getAllocationId() != null) {
data.set("allocationId", om.valueToTree(this.getAllocationId()));
}
if (this.getConnectivityType() != null) {
data.set("connectivityType", om.valueToTree(this.getConnectivityType()));
}
if (this.getMaxDrainDuration() != null) {
data.set("maxDrainDuration", om.valueToTree(this.getMaxDrainDuration()));
}
if (this.getNatGatewayName() != null) {
data.set("natGatewayName", om.valueToTree(this.getNatGatewayName()));
}
if (this.getPrivateIpAddress() != null) {
data.set("privateIpAddress", om.valueToTree(this.getPrivateIpAddress()));
}
if (this.getSecondaryAllocationIds() != null) {
data.set("secondaryAllocationIds", om.valueToTree(this.getSecondaryAllocationIds()));
}
if (this.getSecondaryPrivateIpAddressCount() != null) {
data.set("secondaryPrivateIpAddressCount", om.valueToTree(this.getSecondaryPrivateIpAddressCount()));
}
if (this.getSecondaryPrivateIpAddresses() != null) {
data.set("secondaryPrivateIpAddresses", om.valueToTree(this.getSecondaryPrivateIpAddresses()));
}
if (this.getVpc() != null) {
data.set("vpc", om.valueToTree(this.getVpc()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("@aws-cdk/aws-ec2-alpha.NatGatewayProps"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
NatGatewayProps.Jsii$Proxy that = (NatGatewayProps.Jsii$Proxy) o;
if (!subnet.equals(that.subnet)) return false;
if (this.allocationId != null ? !this.allocationId.equals(that.allocationId) : that.allocationId != null) return false;
if (this.connectivityType != null ? !this.connectivityType.equals(that.connectivityType) : that.connectivityType != null) return false;
if (this.maxDrainDuration != null ? !this.maxDrainDuration.equals(that.maxDrainDuration) : that.maxDrainDuration != null) return false;
if (this.natGatewayName != null ? !this.natGatewayName.equals(that.natGatewayName) : that.natGatewayName != null) return false;
if (this.privateIpAddress != null ? !this.privateIpAddress.equals(that.privateIpAddress) : that.privateIpAddress != null) return false;
if (this.secondaryAllocationIds != null ? !this.secondaryAllocationIds.equals(that.secondaryAllocationIds) : that.secondaryAllocationIds != null) return false;
if (this.secondaryPrivateIpAddressCount != null ? !this.secondaryPrivateIpAddressCount.equals(that.secondaryPrivateIpAddressCount) : that.secondaryPrivateIpAddressCount != null) return false;
if (this.secondaryPrivateIpAddresses != null ? !this.secondaryPrivateIpAddresses.equals(that.secondaryPrivateIpAddresses) : that.secondaryPrivateIpAddresses != null) return false;
return this.vpc != null ? this.vpc.equals(that.vpc) : that.vpc == null;
}
@Override
public final int hashCode() {
int result = this.subnet.hashCode();
result = 31 * result + (this.allocationId != null ? this.allocationId.hashCode() : 0);
result = 31 * result + (this.connectivityType != null ? this.connectivityType.hashCode() : 0);
result = 31 * result + (this.maxDrainDuration != null ? this.maxDrainDuration.hashCode() : 0);
result = 31 * result + (this.natGatewayName != null ? this.natGatewayName.hashCode() : 0);
result = 31 * result + (this.privateIpAddress != null ? this.privateIpAddress.hashCode() : 0);
result = 31 * result + (this.secondaryAllocationIds != null ? this.secondaryAllocationIds.hashCode() : 0);
result = 31 * result + (this.secondaryPrivateIpAddressCount != null ? this.secondaryPrivateIpAddressCount.hashCode() : 0);
result = 31 * result + (this.secondaryPrivateIpAddresses != null ? this.secondaryPrivateIpAddresses.hashCode() : 0);
result = 31 * result + (this.vpc != null ? this.vpc.hashCode() : 0);
return result;
}
}
}