This message was deleted.
# general
s
This message was deleted.
1
w
In project B you can use https://www.pulumi.com/registry/packages/aws/api-docs/ec2/getsubnets/ to get the subnets for the VPC using the
vpc-id
in the filter.
s
I suppose I will also need a filter to get only public or private subnets, right?
Maybe something like:`{ name: 'type', value: ['public'] }` ?
w
For the getSubnets function, you are limited to the filters supported by AWS: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSubnets.html
👍 1
The other option is to provide the subnet IDs as otuputs from stack A.
And skip the getSubnets() call
s
Yeah, I also did that, but it is not working:
Copy code
module.exports = {
  publicSubnetIds: pulumi.output(vpc.publicSubnetIds)
}
and inside project B i have:
Copy code
const publicSubnetIds = mainStack.getOutput('publicSubnetIds');
const dbSubnetGroup = new aws.rds.SubnetGroup('db-subnet-group', {
  subnetIds: publicSubnetIds
});
I don't know what I'm doing wrong
w
I think the fundamental issue is that the
publicSubnetIds
stack output is read in as an object and so needs to be processed a bit before being used in subnetgroup declaration. In stackB if you do something like
Copy code
module.exports = {
  publicSubnetIdsFromA: pulumi.output(mainStack.getOutput("publicSubnetIds"))
}
you’ll see the subnet IDs made it over to stack b. But to use them as in the subnetgroup declaration requires some type casting or something (that I haven’t figured out yet).
Actually, this works for me:
Copy code
const stackA = new pulumi.StackReference("MitchGerdisch/quick-test/dev")
const pulumiSubnetIdsFromA = pulumi.output(stackA.getOutput("pulumiSubnetIds"))
const dbSubnetGroup = new aws.rds.SubnetGroup('db-subnet-group', {
  subnetIds: pulumiSubnetIdsFromA
});
Actually, it works as well without the
pulumi.output()
bit:
Copy code
const stackA = new pulumi.StackReference("MitchGerdisch/quick-test/dev")
const pulumiSubnetIdsFromA = stackA.getOutput("pulumiSubnetIds")
const dbSubnetGroup = new aws.rds.SubnetGroup('db-subnet-group', {
  subnetIds: pulumiSubnetIdsFromA
});
s
🎉 Yeah, it actually works now, I am so dumb, I specified incorrect stack name inside stackReference 🤦‍♂️ @witty-candle-66007 Thank you soo much for your help! 🙌
w
🙂 Glad you got it working.
🙌 1