https://pulumi.com logo
Title
f

flat-car-33421

12/08/2020, 10:06 PM
Apologies if this is not the right channel for such queries ... i am trying to create VPC, Security Group and EC2 Instances using pulumi-javascript, however, my EC2 instance is failing with error "security group id and subnet is a different network" i am creating VPC then Security Group by passing the VPC object and then i using both SG.id and VPC.subnetids in Instance creation: let ec2_1 = new aws.ec2.Instance("webserver-www-1", {     instanceType: size,     vpcSecurityGroupIds: [sg.id],     ami: ami.id,     subnetId: vpc.publicSubnetIds[0],     userData: userData1, }); however, when i print the vpc.publicSubnetIds[0], it s coming as [object promise] .. i am not sure how to get the value from vpc.publicSubnetIds? Thanks for the help in advance ...
1
g

gentle-diamond-70147

12/08/2020, 10:08 PM
is
vpc
from the
awsx
package?
f

flat-car-33421

12/08/2020, 10:08 PM
yes
g

gentle-diamond-70147

12/08/2020, 10:09 PM
I suspect you need to use that like this:
subnetId: pulumi.output(vpc.publicSubnetIds)[0],
As it was, I think it comes through as
undefined
which means AWS tries to put it in the default VPC which would be a different vpc.
f

flat-car-33421

12/08/2020, 10:13 PM
perfect... instances now created successfully 🙂
I think it would be good to mention this in the example code.
g

gentle-diamond-70147

12/08/2020, 10:15 PM
Indeed! Do you mind sharing where you saw that example code?
f

flat-car-33421

12/08/2020, 10:17 PM
just combined both together with some additional parameters to create e2e deployment example.
g

gentle-diamond-70147

12/09/2020, 12:03 AM
Thanks. I’ll get them updated.