https://pulumi.com logo
Title
m

mysterious-wolf-74677

04/29/2021, 10:06 PM
What am I doing wrong?
l

little-cartoon-10569

04/29/2021, 10:14 PM
(I think) the problem isn't with the policy, it's with the Resource property.
That arn is an output, so the value when interpolated like that is an error message, which includes newlines.
But the Resource property isn't allowed have newlines.
m

mysterious-wolf-74677

04/29/2021, 10:15 PM
yeah, it looks like that's the issue @little-cartoon-10569 I just started removing code chunks to see what might change the error, and the
"${foobarLogGroup.arn}:*"
is where it's stemming there
l

little-cartoon-10569

04/29/2021, 10:16 PM
You need to interpolate using
apply()
,
pulumi.interpolate
, or .. onesec, there's a nice trick I found a few months back, I'll go hunt it down.
Try this:
Two tricks here: cast to aws.iam.PolicyDocument, which Pulumi converts to JSON for you, later in the process; and pulumi.interpolate``.
If you didn't have the ":*" at the end of the arn, then you wouldn't need to interpolate at all. The cast to aws.iam.PolicyDocument would be enough.
m

mysterious-wolf-74677

04/29/2021, 10:21 PM
interesting, nice trick @little-cartoon-10569
l

little-cartoon-10569

04/29/2021, 10:22 PM
Yea it's quite nice. Even allows the IDE to type check, property-validate and auto-expand / intellisense...
Unfortunately not everywhere that takes a PolicyDocument supports this trick, but RolePolicy does.
m

mysterious-wolf-74677

04/29/2021, 10:24 PM
ok cool, thanks for that!
@little-cartoon-10569 how did you get the formatting colors to show up?
here in slack?
l

little-cartoon-10569

04/29/2021, 10:25 PM
I used a Text Snippet (lightning menu <---) and selected TypeScript.
It also allows collapsing, which is really great if it's a big piece of code. Makes the channel / thread much tidier.
m

mysterious-wolf-74677

04/29/2021, 10:28 PM
@little-cartoon-10569 just found all that! Didn't even know that was a thing. Thanks man, I've learned a bunch now 🙂
👍 1