software.amazon.awscdk.services.ec2.alpha.SubnetV2Props Maven / Gradle / Ivy
Show all versions of ec2-alpha Show documentation
package software.amazon.awscdk.services.ec2.alpha;
/**
* (experimental) Properties to define subnet for VPC.
*
* Example:
*
*
* Stack stack = new Stack();
* 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();
* InternetGateway igw = InternetGateway.Builder.create(this, "IGW")
* .vpc(myVpc)
* .build();
* Route.Builder.create(this, "IgwRoute")
* .routeTable(routeTable)
* .destination("0.0.0.0/0")
* .target(Map.of("gateway", igw))
* .build();
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.102.0 (build e354887)", date = "2024-09-10T01:10:18.088Z")
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.ec2.alpha.$Module.class, fqn = "@aws-cdk/aws-ec2-alpha.SubnetV2Props")
@software.amazon.jsii.Jsii.Proxy(SubnetV2Props.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface SubnetV2Props extends software.amazon.jsii.JsiiSerializable {
/**
* (experimental) Custom AZ for the subnet.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@org.jetbrains.annotations.NotNull java.lang.String getAvailabilityZone();
/**
* (experimental) ipv4 cidr to assign to this subnet.
*
* See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html#cfn-ec2-subnet-cidrblock
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@org.jetbrains.annotations.NotNull software.amazon.awscdk.services.ec2.alpha.IpCidr getIpv4CidrBlock();
/**
* (experimental) The type of Subnet to configure.
*
* The Subnet type will control the ability to route and connect to the
* Internet.
*
* TODO: Add validation check subnetType
when adding resources (e.g. cannot add NatGateway to private)
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@org.jetbrains.annotations.NotNull software.amazon.awscdk.services.ec2.SubnetType getSubnetType();
/**
* (experimental) VPC Prop.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@org.jetbrains.annotations.NotNull software.amazon.awscdk.services.ec2.alpha.IVpcV2 getVpc();
/**
* (experimental) Indicates whether a network interface created in this subnet receives an IPv6 address.
*
* If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.
*
* Default: false
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.Boolean getAssignIpv6AddressOnCreation() {
return null;
}
/**
* (experimental) Ipv6 CIDR Range for subnet.
*
* Default: No Ipv6 address
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.ec2.alpha.IpCidr getIpv6CidrBlock() {
return null;
}
/**
* (experimental) Custom Route for subnet.
*
* Default: Default route table
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.ec2.IRouteTable getRouteTable() {
return null;
}
/**
* (experimental) Subnet name.
*
* Default: none
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getSubnetName() {
return null;
}
/**
* @return a {@link Builder} of {@link SubnetV2Props}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link SubnetV2Props}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
java.lang.String availabilityZone;
software.amazon.awscdk.services.ec2.alpha.IpCidr ipv4CidrBlock;
software.amazon.awscdk.services.ec2.SubnetType subnetType;
software.amazon.awscdk.services.ec2.alpha.IVpcV2 vpc;
java.lang.Boolean assignIpv6AddressOnCreation;
software.amazon.awscdk.services.ec2.alpha.IpCidr ipv6CidrBlock;
software.amazon.awscdk.services.ec2.IRouteTable routeTable;
java.lang.String subnetName;
/**
* Sets the value of {@link SubnetV2Props#getAvailabilityZone}
* @param availabilityZone Custom AZ for the subnet. This parameter is required.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder availabilityZone(java.lang.String availabilityZone) {
this.availabilityZone = availabilityZone;
return this;
}
/**
* Sets the value of {@link SubnetV2Props#getIpv4CidrBlock}
* @param ipv4CidrBlock ipv4 cidr to assign to this subnet. This parameter is required.
* See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html#cfn-ec2-subnet-cidrblock
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder ipv4CidrBlock(software.amazon.awscdk.services.ec2.alpha.IpCidr ipv4CidrBlock) {
this.ipv4CidrBlock = ipv4CidrBlock;
return this;
}
/**
* Sets the value of {@link SubnetV2Props#getSubnetType}
* @param subnetType The type of Subnet to configure. This parameter is required.
* The Subnet type will control the ability to route and connect to the
* Internet.
*
* TODO: Add validation check subnetType
when adding resources (e.g. cannot add NatGateway to private)
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder subnetType(software.amazon.awscdk.services.ec2.SubnetType subnetType) {
this.subnetType = subnetType;
return this;
}
/**
* Sets the value of {@link SubnetV2Props#getVpc}
* @param vpc VPC Prop. This parameter is required.
* @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;
}
/**
* Sets the value of {@link SubnetV2Props#getAssignIpv6AddressOnCreation}
* @param assignIpv6AddressOnCreation Indicates whether a network interface created in this subnet receives an IPv6 address.
* If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder assignIpv6AddressOnCreation(java.lang.Boolean assignIpv6AddressOnCreation) {
this.assignIpv6AddressOnCreation = assignIpv6AddressOnCreation;
return this;
}
/**
* Sets the value of {@link SubnetV2Props#getIpv6CidrBlock}
* @param ipv6CidrBlock Ipv6 CIDR Range for subnet.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder ipv6CidrBlock(software.amazon.awscdk.services.ec2.alpha.IpCidr ipv6CidrBlock) {
this.ipv6CidrBlock = ipv6CidrBlock;
return this;
}
/**
* Sets the value of {@link SubnetV2Props#getRouteTable}
* @param routeTable Custom Route for subnet.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder routeTable(software.amazon.awscdk.services.ec2.IRouteTable routeTable) {
this.routeTable = routeTable;
return this;
}
/**
* Sets the value of {@link SubnetV2Props#getSubnetName}
* @param subnetName Subnet name.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder subnetName(java.lang.String subnetName) {
this.subnetName = subnetName;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link SubnetV2Props}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public SubnetV2Props build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link SubnetV2Props}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements SubnetV2Props {
private final java.lang.String availabilityZone;
private final software.amazon.awscdk.services.ec2.alpha.IpCidr ipv4CidrBlock;
private final software.amazon.awscdk.services.ec2.SubnetType subnetType;
private final software.amazon.awscdk.services.ec2.alpha.IVpcV2 vpc;
private final java.lang.Boolean assignIpv6AddressOnCreation;
private final software.amazon.awscdk.services.ec2.alpha.IpCidr ipv6CidrBlock;
private final software.amazon.awscdk.services.ec2.IRouteTable routeTable;
private final java.lang.String subnetName;
/**
* 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.availabilityZone = software.amazon.jsii.Kernel.get(this, "availabilityZone", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.ipv4CidrBlock = software.amazon.jsii.Kernel.get(this, "ipv4CidrBlock", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.alpha.IpCidr.class));
this.subnetType = software.amazon.jsii.Kernel.get(this, "subnetType", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.SubnetType.class));
this.vpc = software.amazon.jsii.Kernel.get(this, "vpc", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.alpha.IVpcV2.class));
this.assignIpv6AddressOnCreation = software.amazon.jsii.Kernel.get(this, "assignIpv6AddressOnCreation", software.amazon.jsii.NativeType.forClass(java.lang.Boolean.class));
this.ipv6CidrBlock = software.amazon.jsii.Kernel.get(this, "ipv6CidrBlock", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.alpha.IpCidr.class));
this.routeTable = software.amazon.jsii.Kernel.get(this, "routeTable", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.IRouteTable.class));
this.subnetName = software.amazon.jsii.Kernel.get(this, "subnetName", software.amazon.jsii.NativeType.forClass(java.lang.String.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.availabilityZone = java.util.Objects.requireNonNull(builder.availabilityZone, "availabilityZone is required");
this.ipv4CidrBlock = java.util.Objects.requireNonNull(builder.ipv4CidrBlock, "ipv4CidrBlock is required");
this.subnetType = java.util.Objects.requireNonNull(builder.subnetType, "subnetType is required");
this.vpc = java.util.Objects.requireNonNull(builder.vpc, "vpc is required");
this.assignIpv6AddressOnCreation = builder.assignIpv6AddressOnCreation;
this.ipv6CidrBlock = builder.ipv6CidrBlock;
this.routeTable = builder.routeTable;
this.subnetName = builder.subnetName;
}
@Override
public final java.lang.String getAvailabilityZone() {
return this.availabilityZone;
}
@Override
public final software.amazon.awscdk.services.ec2.alpha.IpCidr getIpv4CidrBlock() {
return this.ipv4CidrBlock;
}
@Override
public final software.amazon.awscdk.services.ec2.SubnetType getSubnetType() {
return this.subnetType;
}
@Override
public final software.amazon.awscdk.services.ec2.alpha.IVpcV2 getVpc() {
return this.vpc;
}
@Override
public final java.lang.Boolean getAssignIpv6AddressOnCreation() {
return this.assignIpv6AddressOnCreation;
}
@Override
public final software.amazon.awscdk.services.ec2.alpha.IpCidr getIpv6CidrBlock() {
return this.ipv6CidrBlock;
}
@Override
public final software.amazon.awscdk.services.ec2.IRouteTable getRouteTable() {
return this.routeTable;
}
@Override
public final java.lang.String getSubnetName() {
return this.subnetName;
}
@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("availabilityZone", om.valueToTree(this.getAvailabilityZone()));
data.set("ipv4CidrBlock", om.valueToTree(this.getIpv4CidrBlock()));
data.set("subnetType", om.valueToTree(this.getSubnetType()));
data.set("vpc", om.valueToTree(this.getVpc()));
if (this.getAssignIpv6AddressOnCreation() != null) {
data.set("assignIpv6AddressOnCreation", om.valueToTree(this.getAssignIpv6AddressOnCreation()));
}
if (this.getIpv6CidrBlock() != null) {
data.set("ipv6CidrBlock", om.valueToTree(this.getIpv6CidrBlock()));
}
if (this.getRouteTable() != null) {
data.set("routeTable", om.valueToTree(this.getRouteTable()));
}
if (this.getSubnetName() != null) {
data.set("subnetName", om.valueToTree(this.getSubnetName()));
}
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.SubnetV2Props"));
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;
SubnetV2Props.Jsii$Proxy that = (SubnetV2Props.Jsii$Proxy) o;
if (!availabilityZone.equals(that.availabilityZone)) return false;
if (!ipv4CidrBlock.equals(that.ipv4CidrBlock)) return false;
if (!subnetType.equals(that.subnetType)) return false;
if (!vpc.equals(that.vpc)) return false;
if (this.assignIpv6AddressOnCreation != null ? !this.assignIpv6AddressOnCreation.equals(that.assignIpv6AddressOnCreation) : that.assignIpv6AddressOnCreation != null) return false;
if (this.ipv6CidrBlock != null ? !this.ipv6CidrBlock.equals(that.ipv6CidrBlock) : that.ipv6CidrBlock != null) return false;
if (this.routeTable != null ? !this.routeTable.equals(that.routeTable) : that.routeTable != null) return false;
return this.subnetName != null ? this.subnetName.equals(that.subnetName) : that.subnetName == null;
}
@Override
public final int hashCode() {
int result = this.availabilityZone.hashCode();
result = 31 * result + (this.ipv4CidrBlock.hashCode());
result = 31 * result + (this.subnetType.hashCode());
result = 31 * result + (this.vpc.hashCode());
result = 31 * result + (this.assignIpv6AddressOnCreation != null ? this.assignIpv6AddressOnCreation.hashCode() : 0);
result = 31 * result + (this.ipv6CidrBlock != null ? this.ipv6CidrBlock.hashCode() : 0);
result = 31 * result + (this.routeTable != null ? this.routeTable.hashCode() : 0);
result = 31 * result + (this.subnetName != null ? this.subnetName.hashCode() : 0);
return result;
}
}
}