# CfnBucketPolicyProps

Properties for defining a `CfnBucketPolicy`.

Extends: CfnBucketPolicyProps
Used as props by: CfnBucketPolicy

- Source: Generated code
- Type last changed: v2.227.0 · 21 Nov 2025

## Example

```ts
const bucketName = "amzn-s3-demo-bucket";
const accessLogsBucket = new s3.Bucket(this, 'AccessLogsBucket', {
  objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_ENFORCED,
  bucketName,
});

// Creating a bucket policy using L1
const bucketPolicy = new s3.CfnBucketPolicy(this, "BucketPolicy", {
  bucket: bucketName,
  policyDocument: {
    Statement: [
      {
        Action: 's3:*',
        Effect: 'Deny',
        Principal: {
          AWS: '*',
        },
        Resource: [
          accessLogsBucket.bucketArn,
          `${accessLogsBucket.bucketArn}/*`
        ],
      },
    ],
    Version: '2012-10-17',
  },
});

// 'serverAccessLogsBucket' will create a new L2 bucket policy
// to allow log delivery and overwrite the L1 bucket policy.
const bucket = new s3.Bucket(this, 'MyBucket', {
  serverAccessLogsBucket: accessLogsBucket,
  serverAccessLogsPrefix: 'logs',
});
```

## Properties

- `bucket`: string | [IBucketRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_s3.IBucketRef.html) (required) — The name of the Amazon S3 bucket to which the policy applies.

- `policyDocument`: any (required) — A policy document containing permissions to add to the specified bucket.

  In IAM, you must provide policy documents in JSON format. However, in CloudFormation you can provide the policy in JSON or YAML format because CloudFormation converts YAML to JSON before submitting it to IAM. For more information, see the AWS::IAM::Policy [PolicyDocument](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-policy.html#cfn-iam-policy-policydocument) resource description in this guide and [Access Policy Language Overview](https://docs.aws.amazon.com/AmazonS3/latest/dev/access-policy-language-overview.html) in the *Amazon S3 User Guide* .
