AwsVpc

Service-level AWS VPC component.

Remarks

This is the primary component resource for VPC orchestration and supports exactly one capability per instance:

  • vpc: creates a VPC from direct arguments with either ipv4IpamPoolId or ipv4CidrBlock.
  • ipamVpc: resolves ipv4IpamPoolId via ${namespace}:env stack tags and then creates the VPC.
  • peering: creates a requester-side peering connection between two typed VPC references.
  • endpoint: creates one private gateway or interface endpoint with an explicit policy.

The vpc and ipamVpc capabilities apply deterministic VPC Name tags and apply subnet Name tags only when callers provide stable keyed availability zones and subnet specifications. The peering and endpoint capabilities apply the same default tags to their respective resources and do not create routes, VPCs, or subnets.

When options.provider is supplied, it is forwarded to every provider resource and lookup in the selected capability. Cross-account or cross-region peerings require separate accepter-side orchestration with an explicitly configured provider.

Naming:

  • Root: type token ${namespace}:aws:AwsVpc; capability literal vpc; logical identity is the required, plain-string args.name; root logical name is ${env}-${projectHash}-vpc-<sanitised name>.
  • Child path: parent AwsVpc, provider-authored awsx.ec2.Vpc; readable tuple [args.name]; logical name is ${env}-${projectHash}-<sanitised name>. AWSX owns the VPC and its internal child logical names.
  • Child path: parent AwsVpc, aws.ec2.Tag for the VPC Name tag; readable tuple [args.name]; logical name is ${env}-${projectHash}-<sanitised name>.
  • Child path: parent AwsVpc, aws.ec2.Tag for every subnet Name tag; candidate tuple is [args.name, args.<capability>.availabilityZones map key, args.<capability>.subnetSpecs map key]. All VPC and subnet tag paths share one aws.ec2.Tag collision preflight before any tag resource is constructed.
  • Provider classification: awsx.ec2.Vpc has no component-controlled provider name; its AWSX identifier is provider-generated and left unset. The VPC Name tag uses stackAndPurpose via buildAwsNameFromLiteralCamelCasePurpose: ${env}-${projectHash}-${args.name}. The VPC Name tag has an AWS limit of 256 characters, so no purpose cap is required.
  • Provider classification: subnet-spec name is semantic AWSX input forwarded unchanged. Subnet Name tags use stackRegionPurpose via buildAwsNameFromLiteralCamelCasePurpose: ${env}-${projectHash}-<compact availability-zone code>-<subnet purpose>; the 256-character tag-value limit needs no purpose cap. The purpose is args.<capability>.subnetSpecs.<key>.name, or its stable map key when unnamed. AWSX default subnets are not individually tagged because they have no consumer-provided keyed identity.
  • Root: peering has capability literal peering; endpoint has capability literal endpoint; both reuse the required, plain-string args.name and therefore have respective root logical names ${env}-${projectHash}-peering-<sanitised name> and ${env}-${projectHash}-endpoint-<sanitised name>.
  • Child paths: aws.ec2.VpcPeeringConnection and aws.ec2.VpcEndpoint respectively use the readable tuple [args.name]. Their provider-visible Name tag uses stackAndPurpose with ${env}-${projectHash}-${args.name}. The tag-value limit is 256 characters, so no purpose cap is required. Endpoint service names are semantic AWS identifiers forwarded unchanged.

Example

CODE
import * as awsx from '@pulumi/awsx';
import { AwsVpc } from '@jobcloud/aws-vpc';

const directVpc = new AwsVpc({
  name: 'application',
  vpc: {
    ipv4CidrBlock: '198.51.100.0/24',
    subnetStrategy: awsx.ec2.SubnetAllocationStrategy.Auto,
    natGateways: {
      strategy: awsx.ec2.NatGatewayStrategy.None,
    },
    availabilityZones: {
      euw1a: 'eu-west-1a',
      euw1b: 'eu-west-1b',
    },
    subnetSpecs: {
      transitGateway: {
        type: awsx.ec2.SubnetType.Private,
        name: 'transitGateway',
        cidrBlocks: ['198.51.100.0/28', '198.51.100.16/28'],
      },
    },
    internetGatewayEnabled: false,
  },
});

const stackAwareVpc = new AwsVpc({
  name: 'shared',
  ipamVpc: {
    availabilityZones: {
      euw1a: 'eu-west-1a',
      euw1b: 'eu-west-1b',
    },
    subnetStrategy: awsx.ec2.SubnetAllocationStrategy.Auto,
  },
});

const peering = new AwsVpc({
  name: 'applicationShared',
  peering: { vpc: directVpc, peerVpc: stackAwareVpc },
});

const endpoint = new AwsVpc({
  name: 'ecrApi',
  endpoint: {
    vpc: directVpc,
    type: 'interface',
    serviceName: 'com.amazonaws.eu-west-1.ecr.api',
    subnetIds: directVpc.privateSubnetIds!,
    securityGroupIds: ['sg-0123456789abcdef0'],
    policy: { path: 'policies/ecr-endpoint.json' },
  },
});

Constructors

new AwsVpc( args: AwsVpcArgs, options?: ComponentResourceOptions, ): AwsVpc

Parameters

  • args (AwsVpcArgs) — Service-level VPC capability inputs with a stable name.
  • options (ComponentResourceOptions, optional) — Optional settings controlling resource behaviour.

Returns

AwsVpc

Hierarchy

  • ComponentResource
  • AwsVpc

Properties

eips: Output<Eip[]> | undefined

readonly

Elastic IPs used by NAT gateways.

endpoint: VpcEndpoint | undefined

readonly

VPC endpoint created by the endpoint capability.

endpointArgs: AwsVpcEndpointArgs | undefined

readonly

Optional VPC endpoint capability inputs used for this instance.

internetGateway: Output<InternetGateway> | undefined

readonly

Internet gateway created for the VPC.

ipamVpcArgs: AwsVpcIpamArgs | undefined

readonly

Optional IPAM VPC capability inputs used for this instance.

ipv4CidrBlock: Output<string | undefined>

readonly

Resolved IPv4 VPC CIDR block when direct CIDR mode is used.

ipv4IpamPoolId: Output<string | undefined>

readonly

Resolved IPv4 IPAM pool ID when IPAM mode is used.

isolatedSubnetIds: Output<string[]> | undefined

readonly

Isolated subnet IDs.

name: string

readonly

Provider-visible Name tag value built with stackAndPurpose.

peeringArgs: AwsVpcPeeringArgs | undefined

readonly

Optional VPC peering capability inputs used for this instance.

peeringConnection: VpcPeeringConnection | undefined

readonly

Requester-side VPC peering connection created by the peering capability.

privateSubnetIds: Output<string[]> | undefined

readonly

Private subnet IDs.

publicSubnetIds: Output<string[]> | undefined

readonly

Public subnet IDs.

routes: Output<Route[]> | undefined

readonly

Routes created for the VPC.

routeTableAssociations: Output<RouteTableAssociation[]> | undefined

readonly

Route table associations created for the VPC.

routeTables: Output<RouteTable[]> | undefined

readonly

Route tables created for the VPC.

urn: Output<string>

readonly

Inherited from urn

The stable logical URN used to distinctly address a resource, both before and after deployments.

vpc: Vpc | undefined

readonly

The AWSX VPC resource created by the vpc or ipamVpc capability.

vpcArgs: AwsVpcDirectArgs | undefined

readonly

Optional direct VPC capability inputs used for this instance.

vpcId: Output<string>

readonly

The VPC ID created by the VPC capability or referenced by the peering/endpoint capability.

Methods

getData(): Promise<any>

protectedasync

Inherited from getData

Retrieves the data produces by initialize. The data is immediately available in a derived class's constructor after the super(...) call to ComponentResource.

Returns

  • Promise<any>

getProvider(moduleMember: string): ProviderResource | undefined

Inherited from getProvider

Returns the provider for the given module member, if one exists.

Parameters

  • moduleMember (string)

Returns

  • ProviderResource | undefined

initialize( args: Inputs, opts?: ComponentResourceOptions, name?: string, type?: string, ): Promise<any>

protectedasync

Inherited from initialize

Can be overridden by a subclass to asynchronously initialize data for this component automatically when constructed. The data will be available immediately for subclass constructors to use. To access the data use getData.

Parameters

  • args (Inputs)
  • opts (ComponentResourceOptions, optional)
  • name (string, optional)
  • type (string, optional)

Returns

  • Promise<any>

registerOutputs( outputs?: Inputs | Promise<Inputs> | Output<Inputs>, ): void

protected

Inherited from registerOutputs

Registers synthetic outputs that a component has initialized, usually by allocating other child sub-resources and propagating their resulting property values.

Component resources can call this at the end of their constructor to indicate that they are done creating child resources. This is not strictly necessary as this will automatically be called after the initialize method completes.

Parameters

  • outputs (Inputs | Promise<Inputs> | Output<Inputs>, optional)

Returns

  • void

Static Methods

isInstance(obj: any): obj is ComponentResource<any>

static

Inherited from isInstance

Returns true if the given object is a CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

Parameters

  • obj (any)

Returns

  • obj is ComponentResource<any>