sparse-intern-71089
02/14/2023, 12:54 AMbest-summer-38252
02/14/2023, 12:57 AMbest-summer-38252
02/14/2023, 12:58 AMbest-summer-38252
02/14/2023, 12:59 AMsteep-toddler-94095
02/14/2023, 1:00 AM{[`com.cloudflare.api.account.zone.${zoneId}`]: "*"},
enough-caravan-98871
02/14/2023, 1:05 AMbest-summer-38252
02/14/2023, 1:06 AMbest-summer-38252
02/14/2023, 1:07 AMenough-caravan-98871
02/14/2023, 1:08 AMsteep-toddler-94095
02/14/2023, 1:09 AMenough-caravan-98871
02/14/2023, 1:11 AMenough-caravan-98871
02/14/2023, 1:13 AMpulumi.interpolate
for many cases. Because in this instance, it is an object, it seems more difficult. It wont let me use pulumi
functions inside of the `{}' object and it wont let me wrap the entire object.enough-caravan-98871
02/14/2023, 1:16 AMenough-caravan-98871
02/14/2023, 1:21 AMsteep-toddler-94095
02/14/2023, 1:31 AMtoString
method that's called when you attempt to interpolate it, but that method gives you some human readable garbage string. So from the compiler's standpoint, everything's fine. You need the Type of the variable you are interpolating to be a string
, not an Output<string>
. To do that, you can use the apply
method on the value you want to interpolate so that you can interact with its string value as a string:
assuming resources
takes an Input<T>
variable.id.apply(id => ({[`com.blahblah.${id}`]: "*"}))
best-summer-38252
02/14/2023, 1:32 AMbest-summer-38252
02/14/2023, 1:32 AMenough-caravan-98871
02/14/2023, 2:37 AMexport const zoneId = pulumi.concat("com.cloudflare.api.account.zone.", zone.id,);
const testApiToken = new cloudflare.ApiToken("testApiToken", {
expiresOn: "2023-02-19T00:00:00Z",
name: "testApi_token",
notBefore: "2023-02-13T00:00:00Z",
policies: [
{
permissionGroups: [dnsWritePermissionId],
resources: {[`${zoneId}`]: "*",},
//resources: {"com.cloudflare.api.account.zone.13328431d71a7bca194bdf56aea26b35": "*",},
},
],
},{provider: providerApiTokens});
enough-caravan-98871
02/14/2023, 2:39 AMsteep-toddler-94095
02/14/2023, 3:03 AMresources
does not take an Input
. Pulumi `Output`s only make sense as inputs to props that accept an Input
.
just move up where the variable.id.apply
id done. for example, if policies
takes an `Input`:
policies: variable.id.apply(id => [
{
permissionGroups: [dnsWritePermissionId],
resources: {[`com.cloudflare.api.account.zone.${id}`]: "*",},
},
],
enough-caravan-98871
02/14/2023, 3:23 AMsteep-toddler-94095
02/14/2023, 3:26 AMcmd
button and left click on a property, e.g. policies
(or just hover your mouse over the param for a handy popup). You can traverse the type downward from there too.enough-caravan-98871
02/14/2023, 3:31 AMenough-caravan-98871
02/14/2023, 3:48 AMsteep-toddler-94095
02/14/2023, 5:14 PMIt is forcing me to reference the source provider's API documentation moreyou shouldn't need to do this outside very rare situations. Let VS Code help you navigate the codebase with auto-import, auto-hinting, cmd+click discovery, etc. once you get in tune with your IDE, you should find you need to reference documentation less than you did with Terraform, since much of the documentation is in the TypeScript Types.
enough-caravan-98871
02/14/2023, 8:38 PMbest-summer-38252
02/22/2023, 10:48 PM