interface BucketPolicyProps
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.S3.BucketPolicyProps |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awss3#BucketPolicyProps |
Java | software.amazon.awscdk.services.s3.BucketPolicyProps |
Python | aws_cdk.aws_s3.BucketPolicyProps |
TypeScript (source) | aws-cdk-lib » aws_s3 » BucketPolicyProps |
Example
import * as cloudfrontMixins from '@aws-cdk/mixins-preview/aws-cloudfront/mixins';
// Create CloudFront distribution
declare const origin: s3.IBucket;
const distribution = new cloudfront.Distribution(scope, 'Distribution', {
defaultBehavior: {
origin: origins.S3BucketOrigin.withOriginAccessControl(origin),
},
});
// Create destination bucket
const destBucket = new s3.Bucket(scope, 'DeliveryBucket');
// Add permissions to bucket to facilitate log delivery
const bucketPolicy = new s3.BucketPolicy(scope, 'DeliveryBucketPolicy', {
bucket: destBucket,
document: new iam.PolicyDocument(),
});
// Create S3 delivery destination for logs
const destination = new logs.CfnDeliveryDestination(scope, 'Destination', {
destinationResourceArn: destBucket.bucketArn,
name: 'unique-destination-name',
deliveryDestinationType: 'S3',
});
distribution
.with(cloudfrontMixins.CfnDistributionLogsMixin.CONNECTION_LOGS.toDestination(destination));
Properties
| Name | Type | Description |
|---|---|---|
| bucket | IBucket | The Amazon S3 bucket that the policy applies to. |
| document? | Policy | Policy document to apply to the bucket. |
| removal | Removal | Policy to apply when the policy is removed from this stack. |
bucket
Type:
IBucket
The Amazon S3 bucket that the policy applies to.
document?
Type:
Policy
(optional, default: A new empty PolicyDocument will be created.)
Policy document to apply to the bucket.
removalPolicy?
Type:
Removal
(optional, default: RemovalPolicy.DESTROY.)
Policy to apply when the policy is removed from this stack.

.NET
Go
Java
Python
TypeScript (