BaseConstruct
Source: src/constructs/base-construct.ts
Purpose: Base class that exposes environment context and safe naming helpers for branch‑based and environment deployments.
Properties
branch?: string— cleaned branch name fromGIT_BRANCH_REF(undefined for main/develop/tags)environment: string— environment name fromENVIRONMENT(defaults todev)account: string— AWS account of the current stackregion: string— AWS region of the current stack
Methods
unique(name: string): string— Generates a unique, environment/branch‑suffixed resource name (max 64 chars), viacreateEnvResourceName.
Usage
import { BaseConstruct } from '../constructs';
class MyFeatureConstruct extends BaseConstruct {
constructor(scope: Construct, id: string) {
super(scope, id);
// Use environment/account/region or branch for logic or naming
const bucketName = this.unique(`data-${this.account}`);
// ...create resources
}
}
NetworkConstruct
Source: src/constructs/network-construct.ts
Purpose: Creates an opinionated VPC with public/private/isolated subnets, S3 and DynamoDB gateway endpoints, VPC Flow Logs to an encrypted S3 bucket with safe naming.
Behavior
- VPC CIDR varies by environment:
dev -> 172.16.0.0/16,test -> 172.17.0.0/16, otherwise172.18.0.0/16. - NAT gateways:
production = 3, others= 1. - Flow logs: Stored in S3, bucket is encrypted, public access blocked, and named via
this.unique('vpc-flow-logs-<account>'). - Subnets: three groups (public, private with egress, isolated) across 3 AZs,
/20each.
Exports
vpc: ec2.Vpc— The created VPC instance.
Usage
import { NetworkConstruct } from '../constructs';
// inside a Stack
const network = new NetworkConstruct(this, 'Network');
// network.vpc is available for connecting other resources