Min
Min

Reputation: 538

How to add sid in addToPolicy method in CDK typescript

How to add sid in addToPolicy method in CDK typescript. For example, my current code is:

// Add Policy statement
    iamRole.addToPolicy( new iam.PolicyStatement({
      effect: iam.Effect.ALLOW,
      actions: ["s3:GetObject"],
      resources: ['arn:aws:s3:::'+ flowlogBucket.bucketName + '/*']
    }));

How would I add sid to this policy statement ?

Upvotes: 2

Views: 1096

Answers (1)

Min
Min

Reputation: 538

I do not think there is a way to add sid using addToPolicy method. I made it work by changing my code like this:

const testStatement = new iam.PolicyStatement({
      effect: iam.Effect.ALLOW,
      actions: ["s3:GetObject"],
      resources: ['arn:aws:s3:::'+ flowlogBucket.bucketName + '/*']
    });
testStatement.sid = 'sidName';

iamRole.addToPolicy(testStatement);

Upvotes: 1

Related Questions