This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as aws from "@pulumi/aws"; | |
const baseTags = { | |
"Project": "Demo" | |
}; | |
let azs = aws.getAvailabilityZones(); | |
let getAz = async function (index: number): Promise<string> { | |
return (await azs).names[index]; | |
}; | |
const vpc = new aws.ec2.Vpc("vpc", { | |
cidrBlock: "10.0.0.0/16", | |
enableDnsHostnames: true, | |
enableDnsSupport: true, | |
tags: baseTags | |
}); | |
const privateSubnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"].map((cidr, index) => { | |
return new aws.ec2.Subnet(`subnet${index}`, { | |
availabilityZone: getAz(index), | |
cidrBlock: cidr, | |
mapPublicIpOnLaunch: false, | |
vpcId: vpc.id, | |
tags: Object.assign({"Name": `Private Subnet ${index + 1}`}, baseTags) | |
}); | |
}); | |
export const vpcId = vpc.id; | |
export const privateSubnetIds = privateSubnets.map((subnet) => subnet.id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment