Vpc - SoftupTechnologies/infrastructure-components GitHub Wiki
Path: /lib/vpc/index.ts
Exports: MyVpc
Required construct packages: @aws-cdk/aws-ec2
The custom construct MyVpc wraps a common configuration for creating a vpc by just giving it some basic requirements, like vpc CIDR block and number of public subnets you need in the vpc.
Usage
import * as cdk from '@aws-cdk/core';
import { MyVpc } from './vpc';
export class ServerlessInfrastructureCdkStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props: StackProps) {
super(scope, id);
const { vpc } = new MyVpc(this, 'MyAwesomeVpc', {
vpcCidr: '10.0.0.0/16',
publicSubnetsNo: 2,
maxAzs: 2,
privateSubnetsNo: 1,
});
}
}
This will create a vpc with 2 AZs (Availabilaty zones), 2 public subnets and 1 subnet for each AZ.
Construct props
Name | Type | Required | Default value | Description |
---|---|---|---|---|
vpcCidr | string | true | undefined | The CIDR block of addresses available in vpc. |
maxAzs | number | false | undefined | Number of Availability Zones (AZ) for the vpc. |
publicSubnetsNo | number | true | undefined | Public subnet number per AZ. |
privateSubnetsNo | number | false | undefined | Private subnet number per AZ. |
isolatedSubnetsNo | number | false | undefined | Isolated subnet number per AZ. |
Properties
Name | Type | Description |
---|---|---|
vpc | ec2.Vpc | Created vpc instance. |