This message was deleted.
# general
s
This message was deleted.
b
g
maybe this helps @rich-exabyte-94739, I use this to create Lambda functions that are in a VPC, and that can access the internet (JS)
Copy code
import * as aws from "@pulumi/aws";

class Vpc {
    vpc: aws.ec2.Vpc;
    subnets: {
        private: aws.ec2.Subnet[];
        public: aws.ec2.Subnet[];
    };
    constructor() {
        // Create VPC.
        const vpc = new aws.ec2.Vpc("webiny", {
            cidrBlock: "10.0.0.0/16"
        });

        // Create one public and two private subnets.
        const publicSubnet = new aws.ec2.Subnet("public", {
            vpcId: vpc.id,
            cidrBlock: "10.0.0.0/24"
        });

        const privateSubnet1 = new aws.ec2.Subnet("private-subnet-1", {
            vpcId: vpc.id,
            cidrBlock: "10.0.1.0/24"
        });

        const privateSubnet2 = new aws.ec2.Subnet("private-subnet-2", {
            vpcId: vpc.id,
            cidrBlock: "10.0.2.0/24"
        });

        // Create Internet gateway.
        const internetGateway = new aws.ec2.InternetGateway("internet-gateway", {
            vpcId: vpc.id
        });

        // Create NAT gateway.
        const elasticIpAllocation = new aws.ec2.Eip("nat-gateway-elastic-ip", {
            vpc: true
        });

        const natGateway = new aws.ec2.NatGateway("nat-gateway", {
            allocationId: elasticIpAllocation.id,
            subnetId: publicSubnet.id
        });

        // Create a route table for both subnets.
        const publicSubnetRouteTable = new aws.ec2.RouteTable("public", {
            vpcId: vpc.id,
            routes: [
                {
                    cidrBlock: "0.0.0.0/0",
                    gatewayId: internetGateway.id
                }
            ]
        });

        const privateSubnetRouteTable = new aws.ec2.RouteTable("private", {
            vpcId: vpc.id,
            routes: [
                {
                    cidrBlock: "0.0.0.0/0",
                    natGatewayId: natGateway.id
                }
            ]
        });

        // Create route table associations - links between subnets and route tables.
        new aws.ec2.RouteTableAssociation("public-subnet-route-table-association", {
            subnetId: publicSubnet.id,
            routeTableId: publicSubnetRouteTable.id
        });

        new aws.ec2.RouteTableAssociation("private-subnet-1-route-table-association", {
            subnetId: privateSubnet1.id,
            routeTableId: privateSubnetRouteTable.id
        });

        new aws.ec2.RouteTableAssociation("private-subnet-2-route-table-association", {
            subnetId: privateSubnet2.id,
            routeTableId: privateSubnetRouteTable.id
        });

        this.vpc = vpc;
        this.subnets = {
            public: [publicSubnet],
            private: [privateSubnet1, privateSubnet2]
        };
    }
}

const vpc = new Vpc();
export default vpc;
r
Thanks! The arg value for
GetSubnetIdsArgs
only accepts a string from what I can see in the source:
Copy code
// A collection of arguments for invoking getSubnetIds.
type GetSubnetIdsArgs struct {
	// Custom filter block as described below.
	Filters []GetSubnetIdsFilter `pulumi:"filters"`
	// A map of tags, each pair of which must exactly match
	// a pair on the desired subnets.
	Tags map[string]string `pulumi:"tags"`
	// The VPC ID that you want to filter from.
	VpcId string `pulumi:"vpcId"`
}
Appreciate the JS example, thanks!