Skip to content

Commit

Permalink
feat: create VPC and subnets
Browse files Browse the repository at this point in the history
  • Loading branch information
wolverian committed Sep 11, 2024
1 parent c7b3749 commit dd411e9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
22 changes: 20 additions & 2 deletions infra/bin/infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,30 @@ import "source-map-support/register";
import * as cdk from "aws-cdk-lib";
import { InfraStack } from "../lib/infra-stack";

// CIDR allocation strategy:
// Top: 10.15.0.0/16
// VPCs: 10.15.0.0/18, 10.15.64.0/18, 10.15.128.0/18, 10.15.192.0/18 (16382 addresses)
// Subnets: ...

const accounts = {
dev: { account: "682033502734", region: "eu-west-1" },
dev: {
account: "682033502734",
region: "eu-west-1",
},
network: {
cidrs: {
dev: "10.15.0.0/18",
},
maxAzs: {
dev: 2,
},
},
};

const app = new cdk.App();

new InfraStack(app, "InfraStack", {
const devStack = new InfraStack(app, "InfraStack", {
env: accounts.dev,
cidrBlock: accounts.network.cidrs.dev,
maxAzs: accounts.network.maxAzs.dev,
});
7 changes: 7 additions & 0 deletions infra/cdk.context.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"availability-zones:account=682033502734:region=eu-west-1": [
"eu-west-1a",
"eu-west-1b",
"eu-west-1c"
]
}
13 changes: 12 additions & 1 deletion infra/lib/infra-stack.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import * as cdk from "aws-cdk-lib";
import { Construct } from "constructs";
import * as ec2 from "aws-cdk-lib/aws-ec2";

export interface InfraStackProps extends cdk.StackProps {
cidrBlock: string;
maxAzs: number;
}

export class InfraStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
constructor(scope: Construct, id: string, props: InfraStackProps) {
super(scope, id, props);

const vpc = new ec2.Vpc(this, "Vpc", {
ipAddresses: ec2.IpAddresses.cidr(props.cidrBlock),
maxAzs: props.maxAzs,
});
}
}

0 comments on commit dd411e9

Please sign in to comment.