https://pulumi.com logo
#general
Title
# general
a

aloof-leather-66267

03/06/2023, 10:07 PM
Is there any way to expand an
Output<Resource[]>
to create child resources based on each
Resource
, without creating resources inside a
.apply()
? https://github.com/pulumi/pulumi/issues/5392#issuecomment-1203668256
l

little-cartoon-10569

03/06/2023, 10:15 PM
No. Were the resources created based on another array, maybe of names or something? You could use that as your starting point. This is the same problem as with awsx.ec2.Vpc: your code cannot know how many subnets will be created, you need to work with Promises or Outputs. Even though you may have hardcoded public and private subnets, three AZs (therefore 6 subnets), you cannot have non-future references to those known 6 items.
a

aloof-leather-66267

03/06/2023, 10:18 PM
Got it. I'm specifically asking about
gcp.certificatemanager.DnsAuthorization
. It returns an
Output<DnsAuthorizationDnsResourceRecord[]>
, and then for each
DnsAuthorizationDnsResourceRecord
we need to create a matching DNS record. It seems like the way to do it is with
.apply()
, even though that causes the previews to be wrong. https://www.pulumi.com/registry/packages/gcp/api-docs/certificatemanager/dnsauthorization/#state_dnsresourcerecords_nodejs
e

echoing-dinner-19531

03/07/2023, 10:12 AM
Yeh you have to do this inside Apply at the moment. You might want to use
--target
to just create the certificate manager and then do a preview for the other resources that should then be correct.
2 Views