Apologies if this is not the right channel for suc...
# aws
f
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
is
vpc
from the
awsx
package?
f
yes
g
I suspect you need to use that like this:
Copy code
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
perfect... instances now created successfully 🙂
I think it would be good to mention this in the example code.
g
Indeed! Do you mind sharing where you saw that example code?
f
just combined both together with some additional parameters to create e2e deployment example.
g
Thanks. I’ll get them updated.