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 eitheripv4IpamPoolIdoripv4CidrBlock.ipamVpc: resolvesipv4IpamPoolIdvia${namespace}:envstack 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 literalvpc; logical identity is the required, plain-stringargs.name; root logical name is${env}-${projectHash}-vpc-<sanitised name>. - Child path: parent
AwsVpc, provider-authoredawsx.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.Tagfor the VPC Name tag; readable tuple [args.name]; logical name is${env}-${projectHash}-<sanitised name>. - Child path: parent
AwsVpc,aws.ec2.Tagfor every subnet Name tag; candidate tuple is [args.name,args.<capability>.availabilityZonesmap key,args.<capability>.subnetSpecsmap key]. All VPC and subnet tag paths share oneaws.ec2.Tagcollision preflight before any tag resource is constructed. - Provider classification:
awsx.ec2.Vpchas no component-controlled providername; its AWSX identifier is provider-generated and left unset. The VPC Name tag usesstackAndPurposeviabuildAwsNameFromLiteralCamelCasePurpose:${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
nameis semantic AWSX input forwarded unchanged. Subnet Name tags usestackRegionPurposeviabuildAwsNameFromLiteralCamelCasePurpose:${env}-${projectHash}-<compact availability-zone code>-<subnet purpose>; the 256-character tag-value limit needs no purpose cap. The purpose isargs.<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:
peeringhas capability literalpeering;endpointhas capability literalendpoint; both reuse the required, plain-stringargs.nameand therefore have respective root logical names${env}-${projectHash}-peering-<sanitised name>and${env}-${projectHash}-endpoint-<sanitised name>. - Child paths:
aws.ec2.VpcPeeringConnectionandaws.ec2.VpcEndpointrespectively use the readable tuple [args.name]. Their provider-visible Name tag usesstackAndPurposewith${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
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
ComponentResourceAwsVpc
Properties
eips: Output<Eip[]> | undefined
Elastic IPs used by NAT gateways.
endpoint: VpcEndpoint | undefined
VPC endpoint created by the endpoint capability.
endpointArgs: AwsVpcEndpointArgs | undefined
Optional VPC endpoint capability inputs used for this instance.
internetGateway: Output<InternetGateway> | undefined
Internet gateway created for the VPC.
ipamVpcArgs: AwsVpcIpamArgs | undefined
Optional IPAM VPC capability inputs used for this instance.
ipv4CidrBlock: Output<string | undefined>
Resolved IPv4 VPC CIDR block when direct CIDR mode is used.
ipv4IpamPoolId: Output<string | undefined>
Resolved IPv4 IPAM pool ID when IPAM mode is used.
isolatedSubnetIds: Output<string[]> | undefined
Isolated subnet IDs.
name: string
Provider-visible Name tag value built with stackAndPurpose.
peeringArgs: AwsVpcPeeringArgs | undefined
Optional VPC peering capability inputs used for this instance.
peeringConnection: VpcPeeringConnection | undefined
Requester-side VPC peering connection created by the peering capability.
privateSubnetIds: Output<string[]> | undefined
Private subnet IDs.
publicSubnetIds: Output<string[]> | undefined
Public subnet IDs.
routes: Output<Route[]> | undefined
Routes created for the VPC.
routeTableAssociations: Output<RouteTableAssociation[]> | undefined
Route table associations created for the VPC.
routeTables: Output<RouteTable[]> | undefined
Route tables created for the VPC.
urn: Output<string>
Inherited from urn
The stable logical URN used to distinctly address a resource, both before and after deployments.
vpc: Vpc | undefined
The AWSX VPC resource created by the vpc or ipamVpc capability.
vpcArgs: AwsVpcDirectArgs | undefined
Optional direct VPC capability inputs used for this instance.
vpcId: Output<string>
The VPC ID created by the VPC capability or referenced by the peering/endpoint capability.
Methods
getData(): Promise<any>
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>
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
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>
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>