import * as aws from "@pulumi/aws" ; import * as pulumi from "@pulumi/pulumi" ; import * as x from ".." ; import * as utils from "../utils" ; export class Subnet extends pulumi . ComponentResource { private readonly __isSubnetInstance = true ; public readonly vpc : x . ec2 . Vpc ; public readonly subnetName : string ; /**
     * Underlying id for the aws subnet.  This should be used over [this.subnet.id] as this
     * Output will only resolve once the route table and all associations are resolved.
     */ public readonly id : pulumi . Output < string > ; public readonly subnet : aws . ec2 . Subnet ; public readonly routeTable : aws . ec2 . RouteTable | undefined ; public readonly routeTableAssociation : aws . ec2 . RouteTableAssociation | undefined ; public readonly routes : aws . ec2 . Route [ ] = [ ] ; constructor ( name , vpc , args , opts ? ) ; constructor ( name , vpc , args , opts ? ) ; constructor ( name , vpc , args , opts = { } ) { super ( "awsx:x:ec2:Subnet" , name , { } , { parent : vpc , ... opts } ) ; this . vpc = vpc ; this . subnetName = name ; if ( isExistingSubnetArgs ( args ) ) { this . subnet = args . subnet ; this . id = args . subnet . id ; } else { const assignIpv6AddressOnCreation = utils . ifUndefined ( args . assignIpv6AddressOnCreation , vpc . vpc . assignGeneratedIpv6CidrBlock ) ; this . subnet = new aws . ec2 . Subnet ( name , { vpcId : vpc . id , ... args , assignIpv6AddressOnCreation , } , { parent : this , ignoreChanges : opts . ignoreChanges , } ) ; this . routeTable = new aws . ec2 . RouteTable ( name , { vpcId : vpc . id , } , { parent : this } ) ; this . routeTableAssociation = new aws . ec2 . RouteTableAssociation ( name , { routeTableId : this . routeTable . id , subnetId : this . subnet . id , } , { parent : this , customTimeouts : { create : "5m" , delete : "5m" , } } ) ; this . id = pulumi . all ( [ this . subnet . id , this . routeTableAssociation . id ] ) . apply ( ( [ id ] ) => id ) ; } this . registerOutputs ( ) ; } internal public static isSubnetInstance ( obj ) { return ! ! ( < Subnet > obj ) . __isSubnetInstance ; } public createRoute ( name , args , opts ? ) ; public createRoute ( name , provider , opts ? ) ; public createRoute ( name , argsOrProvider , opts = { } ) { if ( ! this . routeTable ) { throw new Error ( "Cannot call [createRoute] on a [Subnet] that doesn't have a [RouteTable]" ) ; } opts = { parent : this , customTimeouts : { create : "5m" , delete : "5m" , } , ... opts , } ; const args = isSubnetRouteProvider ( argsOrProvider ) ? argsOrProvider . route ( name , { parent : this } ) : argsOrProvider ; this . routes . push ( new aws . ec2 . Route ( `${ this . subnetName }-${ name }` , { ... args , routeTableId : this . routeTable . id , } , opts ) ) ; } } utils . Capture ( Subnet . prototype ) . createRoute . doNotCapture = true ; export interface SubnetRouteProvider { route ( name , opts ) : RouteArgs ; } function isSubnetRouteProvider ( obj ) { return ( < SubnetRouteProvider > obj ) . route instanceof Function ; } export type SubnetOrId = Subnet | pulumi . Input < string > ; export interface ExistingSubnetArgs { /**
     * Optional existing instance to use to make the awsx Subnet out of.  If this is provided No
     * RouteTable or RouteTableAssociation will be automatically be created.
     */ subnet : aws . ec2 . Subnet ; } function isExistingSubnetArgs ( obj ) { return ! ! ( < ExistingSubnetArgs > obj ) . subnet ; } type RouteArgsShape = utils . Overwrite < aws . ec2 . RouteArgs , { routeTableId ? : never ; } > ; /**
 * The set of arguments for constructing a Route resource.
 */ export interface RouteArgs { /**
     * The destination CIDR block.
     */ destinationCidrBlock ? : pulumi . Input < string > ; /**
     * The destination IPv6 CIDR block.
     */ destinationIpv6CidrBlock ? : pulumi . Input < string > ; /**
     * Identifier of a VPC Egress Only Internet Gateway.
     */ egressOnlyGatewayId ? : pulumi . Input < string > ; /**
     * Identifier of a VPC internet gateway or a virtual private gateway.
     */ gatewayId ? : pulumi . Input < string > ; /**
     * Identifier of an EC2 instance.
     */ instanceId ? : pulumi . Input < string > ; /**
     * Identifier of a VPC NAT gateway.
     */ natGatewayId ? : pulumi . Input < string > ; /**
     * Identifier of an EC2 network interface.
     */ networkInterfaceId ? : pulumi . Input < string > ; /**
     * Identifier of an EC2 Transit Gateway.
     */ transitGatewayId ? : pulumi . Input < string > ; /**
     * Identifier of a VPC peering connection.
     */ vpcPeeringConnectionId ? : pulumi . Input < string > ; } type SubnetArgsShape = utils . Overwrite < aws . ec2 . SubnetArgs , { vpcId ? : never ; } > ; export interface SubnetArgs { /**
     * The CIDR block for the subnet.
     */ cidrBlock : pulumi . Input < string > ; /**
     * Specify true to indicate that network interfaces created in the specified subnet should be
     * assigned an IPv6 address. Default's to `true` if the Vpc this is associated with has
     * `assignGeneratedIpv6CidrBlock: true`. `false` otherwise.
     */ assignIpv6AddressOnCreation ? : pulumi . Input < boolean > ; /**
     * The AZ for the subnet.
     */ availabilityZone ? : pulumi . Input < string > ; /**
     * The AZ ID of the subnet.
     */ availabilityZoneId ? : pulumi . Input < string > ; /**
     * The IPv6 network range for the subnet,
     * in CIDR notation. The subnet size must use a /64 prefix length.
     */ ipv6CidrBlock ? : pulumi . Input < string > ; /**
     * Specify true to indicate that instances launched into the subnet should be assigned a public
     * IP address. Default is `false`.
     */ mapPublicIpOnLaunch ? : pulumi . Input < boolean > ; /**
     * A mapping of tags to assign to the resource.
     */ tags ? : pulumi . Input < aws . Tags > ; /**
     * Ignore changes to any of the specified properties of the Subnet.
     */ ignoreChanges ? : string [ ] ; } const test1 = utils . checkCompat < SubnetArgsShape , SubnetArgs > ( ) ; const test2 = utils . checkCompat < RouteArgsShape , RouteArgs > ( ) ;