import * as aws from "@pulumi/aws" ; import * as pulumi from "@pulumi/pulumi" ; import * as x from ".." ; import * as utils from "../utils" ; export class NatGateway extends pulumi . ComponentResource implements x . ec2 . SubnetRouteProvider { public readonly natGatewayName : string ; public readonly vpc : x . ec2 . Vpc ; public readonly elasticIP : aws . ec2 . Eip | undefined ; public readonly natGateway : aws . ec2 . NatGateway ; constructor ( name , vpc , args , opts ? ) ; constructor ( name , vpc , args , opts ? ) ; constructor ( name , vpc , args , opts = { } ) { super ( "awsx:x:ec2:NatGateway" , name , { } , { parent : vpc , ... opts } ) ; this . vpc = vpc ; this . natGatewayName = name ; if ( isExistingNatGatewayArgs ( args ) ) { this . natGateway = args . natGateway ; } else { this . elasticIP = new aws . ec2 . Eip ( name , { vpc : true , tags : { Name : name } , } , { parent : this } ) ; const subnetId = x . ec2 . Subnet . isSubnetInstance ( args . subnet ) ? args . subnet . id : args . subnet ; this . natGateway = new aws . ec2 . NatGateway ( name , { ... args , subnetId , allocationId : this . elasticIP . id , } , { parent : this } ) ; } this . registerOutputs ( ) ; } public route ( name , opts ) { return { destinationCidrBlock : "0.0.0.0/0" , natGatewayId : this . natGateway . id , } ; } } export interface NatGatewayArgs { /**
     * The subnet the NatGateway should be placed in.
     */ subnet : x . ec2 . SubnetOrId ; /**
     * A mapping of tags to assign to the resource.
     */ tags ? : pulumi . Input < { [ key ] : any ; } > ; } export interface ExistingNatGatewayArgs { natGateway : aws . ec2 . NatGateway ; } function isExistingNatGatewayArgs ( obj ) { return ! ! ( < ExistingNatGatewayArgs > obj ) . natGateway ; }