sparse-intern-71089
09/28/2020, 7:38 PMbillowy-army-68599
ec2.GetSubnetIds
https://github.com/pulumi/examples/blob/fd422a115ca1602eed9a895ab4ed748185d798cc/aws-go-eks/main.go#L24gifted-student-18589
09/28/2020, 8:11 PMimport * 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;
rich-exabyte-94739
09/28/2020, 8:13 PMGetSubnetIdsArgs
only accepts a string from what I can see in the source:
// 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"`
}
rich-exabyte-94739
09/28/2020, 8:13 PM