Skip to content
v2.275.0

PolicyDocumentProps Struct ​

Properties for a new PolicyDocument.

Example ​

ts
const topic = new sns.Topic(this, 'Topic');
const policyDocument = new iam.PolicyDocument({
  assignSids: true,
  statements: [
    new iam.PolicyStatement({
      actions: ["sns:Publish"],
      principals: [new iam.ServicePrincipal('s3.amazonaws.com')],
      resources: [topic.topicArn],
    }),
  ],
});

const topicPolicy = new sns.TopicPolicy(this, 'Policy', {
  topics: [topic],
  policyDocument,
  enforceSSL: true,
});

Properties ​

assignSidsoptionalbooleanassign_sidsoptionalboolassignSidsoptionalBooleanAssignSidsoptionalboolAssignSidsoptional*bool= false#
Automatically assign Statement Ids to all statements.
minimizeoptionalbooleanminimizeoptionalboolminimizeoptionalBooleanMinimizeoptionalboolMinimizeoptional*bool#
Try to minimize the policy by merging statements.

Default: false, unless the feature flag @aws-cdk/aws-iam:minimizePolicies is set

notes

To avoid overrunning the maximum policy size, combine statements if they produce the same result. Merging happens according to the following rules:

  • The Effect of both statements is the same
  • Neither of the statements have a 'Sid'
  • Combine Principals if the rest of the statement is exactly the same.
  • Combine Resources if the rest of the statement is exactly the same.
  • Combine Actions if the rest of the statement is exactly the same.
  • We will never combine NotPrincipals, NotResources or NotActions, because doing so would change the meaning of the policy document.
statementsoptionalPolicyStatement[]statementsoptionaltyping.List[PolicyStatement]statementsoptionalList<PolicyStatement>StatementsoptionalPolicyStatement[]Statementsoptional*[]PolicyStatement#
Initial statements to add to the policy document.

Default: No statements