early-musician-41645
10/03/2019, 10:04 PMconst zone = aws.route53.Zone.get("external-dns", ingress.externalDnsHostedZoneId);
let domain: string = zone.name.apply(z => z.replace(/\.$/, ''));
let zoneId: string = zone.zoneId.apply(z => z);
leads to:
error TS2322: Type 'Output<string>' is not assignable to type 'string'.
Any tips? How do I cast Output<string>
to string
?cool-egg-852
10/03/2019, 10:06 PMstring
to Output<string>
.pulumi.interpolate`${zone.name.replace(...)}`
white-balloon-205
How do I castYou unfortunately do not. AntoOutput<string>
?string
Output<string>
is a value which may not have a string available yet (it may not until the resource gets created).
So you need to use .apply
on it - and within that callback you pass to apply you will get passed the actual string value (when it's available) and can transform it into some other value. But you then need to pass the resulting Ouput<somethingelse>
to something else that accepts an Output
.
There is a fair bit of content on this topic at https://www.pulumi.com/docs/intro/concepts/programming-model/#outputs.
What does the code look like that is trying to uselet zoneId: string = zone.zoneId.apply(z => z);
zoneId
? The solution here is to change that code.early-musician-41645
10/03/2019, 10:11 PMprivate getRolePolicy(zoneId: string) {
return JSON.stringify({
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Action: [
"route53:ChangeResourceRecordSets"
],
Resource: [
`arn:aws:route53:::hostedzone/${zoneId}`
]
},
{
Effect: "Allow",
Action: [
"route53:ListHostedZones",
"route53:ListResourceRecordSets"
],
Resource: [
"*"
]
}
]
});
}
pulumi.all([...]).apply({...});