fierce-cpu-94517
07/16/2019, 1:42 PMexport const vpc = new awsx.ec2.Vpc("vpc", {
numberOfAvailabilityZones: 3,
});
I'm struggling to find a way to grab the private subnet so that I can use it to create an EC2 instance.
This is what I came to thus far:
const privateSubnets = pulumi.output(vpc.privateSubnets).apply(
subnets => subnets.filter(x => x.subnet.availabilityZone == pulumi.output("us-east-1a"))
);
export const server = new aws.ec2.Instance("server", {
instanceType: aws.ec2.C5InstanceLarge,
vpcSecurityGroupIds: [ vpc.sgInternal.id ],
subnetId: privateSubnets.apply(x => x[0].id),
ami: "ami-;02507631a9f7bc956",
});
I'm getting the following error:
$ pulumi up
Previewing update (xxx):
Type Name Plan Info
pulumi:pulumi:Stack xxx 1 error; 5 messages
Diagnostics:
pulumi:pulumi:Stack (xxx):
TypeError: Cannot read property 'id' of undefined
at exports.server.aws.ec2.Instance.subnetId.privateSubnets.apply.x (ec2.ts:24:46)
at OutputImpl.<anonymous> (node_modules/@pulumi/pulumi/output.js:104:47)
at Generator.next (<anonymous>)
at fulfilled (node_modules/@pulumi/pulumi/output.js:17:58)
gentle-diamond-70147
07/16/2019, 3:32 PMconst server = new aws.ec2.Instance("web-server", {
// ...
subnetId: vpc.privateSubnetsIds[0], // reference the subnet created by awsx
});
fierce-cpu-94517
07/16/2019, 3:48 PMus-east-1a
?gentle-diamond-70147
07/16/2019, 3:51 PMfierce-cpu-94517
07/16/2019, 3:58 PMus-east-1a
that I need to attach to the instance. that's why I used a filter on the subnet collection.subnets => subnets.filter(x => x.subnet.availabilityZone == ebs.availabilityZone)
vpc.privateSubnets[0].subnet.availabilityZone
when configuring the EBS volume AZ