https://pulumi.com logo
#aws
Title
# aws
f

faint-motherboard-95438

09/15/2020, 4:44 PM
Hi, It’s impossible to
getSubnetIds
in the same run of the
Vpc
creation:
Copy code
Error: invocation of aws:ec2/getSubnetIds:getSubnetIds returned an error: invoking aws:ec2/getSubnetIds:getSubnetIds: no matching subnet found for vpc with id REDACTED
        at /pulumi/projects/node_modules/@pulumi/pulumi/runtime/invoke.js:136:33
        at Http2CallStream.<anonymous> (/pulumi/projects/node_modules/@grpc/grpc-js/src/client.ts:155:9)
        at Http2CallStream.emit (events.js:327:22)
        at Http2CallStream.EventEmitter.emit (domain.js:485:12)
        at /pulumi/projects/node_modules/@grpc/grpc-js/src/call-stream.ts:186:14
        at processTicksAndRejections (internal/process/task_queues.js:79:11)
We’re using
pulumi.all([vpc.id]).apply(([vpcId]) => aws.ec2.getSubnetIds({…}))
but still it fails. Running a
pulumi update
again fix the problem by itself, but we obviously don’t want to have to do that. We are using
awsx.ec2.Vpc
to create the VPC and define some custom subnets.
b

broad-gold-44713

09/15/2020, 5:53 PM
Why not use
Copy code
const vpc = new awsx.ec2.Vpc...
...vpc.subnetIds...
f

faint-motherboard-95438

09/15/2020, 6:15 PM
@broad-gold-44713 not sure what you’re suggesting here.
vpc.subnetIds
does not exist. Maybe you’re referring to one of
vpc.publicSubnetIds
,
vpc.privateSubnetIds
or
vpc.isolatedSubnetIds
but that does not fit our needs. We use
getSubnetIds
because it provides a filtering capability.
b

broad-gold-44713

09/15/2020, 6:17 PM
You're right, my bad.
One other idea, may be separate into two projects with StackReference? I've found things to be a lot more stable and tractable by keeping projects relatively small. Plus much easier to edit state if something does go bad.