sparse-intern-71089
02/25/2019, 9:15 PMwhite-balloon-205
"‘func’ is not allowed to make resources."That's actually technically not true - it is possible and will generally work for the callback to create new resources. But it is discouraged, as it can lead to the results of
pulumi preview
being wrong, as the apply
callback will not get run during a preview (because the real outputs values aren't yet known until the resources are deployed), and therefore any resources created in the callback will not be seen during the preview
.
I'm not sure I fully follow the second part of your question about nameServers
. In general, it should be very very rare to have to create resources inside an apply
- instead you should be able to create the resource and pass in the output value as an input to the resource. If you share an example of where you are needing to do this we could suggest an alternative.cold-coat-35200
02/26/2019, 7:13 AMpulumi.Output<string[]>
not a pulumi.Output<string>[]
, latter is iterable without apply, but the former not, so if I want to create a resource for every nameserver, I can only do that in inside apply, e.g.:
let pubZone = new aws.route53.Zone(`${stackName}-r53-pub-zone`, {
name: pubDomain,
forceDestroy: true
})
pubZone.nameServers.apply(nameservers => {
nameservers.forEach((nameserver, index) => {
new cloudflare.DNSRecord(`${stackName}-r53-pub-zone-ns-${index}`, {
domain: mainDomain,
type: 'NS',
name: pubDomain.substring(0, pubDomain.indexOf(mainDomain) - 1),
content: nameserver,
ttl: dnsTTL,
proxied: false
})
})
})
where content
is a pulumi.Input<string>
. I can't see a way to do this outside of apply without modifying our custom resource or is it possible to transform the nameserver output to a pulumi.Output<string>[]
?cold-coat-35200
02/26/2019, 11:30 AMwhite-balloon-205
apply
.
The fact that preview
can not accurately predict what will get created is fairly clear here - you do not in fact know how many of these (if any) you will end up needing to create until part of the deployment has happened (enough to return the actual array of nameServers
. So Pulumi lets you express this, but the preview may not include any changes to resources that are created (or later removed) from within the apply
.cold-coat-35200
02/26/2019, 9:22 PMorange-tailor-85423
02/28/2019, 5:39 PMorange-tailor-85423
02/28/2019, 5:40 PMcold-coat-35200
03/01/2019, 9:20 AMchilly-photographer-60932
03/01/2019, 7:37 PMorange-tailor-85423
03/01/2019, 7:39 PMcold-coat-35200
03/02/2019, 11:41 AMdeleteBeforeReplace
on DNSRecord resources is recommended, because Cloudflare does not allow to create the same record twice.
Third, cloudflare library using a very old got
library (6.x, newest is 9.x) which does not pass back the error text, returned from Cloudflare api, so if any problem happens, you will see a 400 error and nothing else. I can't do anything about it.