What am I doing wrong?
# typescript
m
What am I doing wrong?
l
(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
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
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
interesting, nice trick @little-cartoon-10569
l
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
ok cool, thanks for that!
@little-cartoon-10569 how did you get the formatting colors to show up?
here in slack?
l
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
@little-cartoon-10569 just found all that! Didn't even know that was a thing. Thanks man, I've learned a bunch now 🙂
👍 1