This message was deleted.
# aws
s
This message was deleted.
v
if you’re using typescript (which im guessing you are due to json.stringify reference) you can create an object which is of type iam.PolicyDocument and looks much tidier and easier to work with than json stringify… see example :
Copy code
const examplePolicyDocument: iam.PolicyDocument = {
  Version: '2012-10-17',
  Statement: [
    {
      Effect: 'Allow',
      Action: ['s3:GetBucketAcl', 's3:ListBucket', 's3:PutObject'],
      Resource: [pulumi.interpolate`${bucket.arn}`, pulumi.interpolate`${bucket.arn}/*`],
    },
  ],
};
and you can use like this:
Copy code
new iam.RolePolicy(
  'exampleRolePolicy',
  {
    role: exampleRole.id,
    policy: examplePolicyDocument,
  },
);
p
oh i see its defined as a type, and not a resource in the pulumi/aws lib
l
FYI @victorious-church-57397: pulumi.interpolate`${bucket.arn}` can be rewritten as
bucket.arn
.
v
The bucket in question is imported from a different file so had to use interpolate
l
If
bucket
is an object and
bucket.arn
is an ARN, then you don't need interpolate.
interpolate
is just a convenience function for
s.apply(s => s.toString())
With interpolation added, obviously 🙂
v
Yeah, aware of that cheers mate but was getting an error suggesting that we used interpolate so just followed the docs! Normally just use the object where I can
👍 1