class BlockPublicAccess
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.S3.BlockPublicAccess |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awss3#BlockPublicAccess |
Java | software.amazon.awscdk.services.s3.BlockPublicAccess |
Python | aws_cdk.aws_s3.BlockPublicAccess |
TypeScript (source) | aws-cdk-lib » aws_s3 » BlockPublicAccess |
Example
import { RemovalPolicy } from 'aws-cdk-lib';
new s3.Bucket(scope, 'Bucket', {
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
encryption: s3.BucketEncryption.S3_MANAGED,
enforceSSL: true,
versioned: true,
removalPolicy: RemovalPolicy.RETAIN,
});
Initializer
new BlockPublicAccess(options: BlockPublicAccessOptions)
Parameters
- options
BlockPublic Access Options
Properties
| Name | Type | Description |
|---|---|---|
| block | boolean | |
| block | boolean | |
| ignore | boolean | |
| restrict | boolean | |
| static BLOCK_ACLS | Block | |
| static BLOCK_ACLS_ONLY | Block | Use this option if you want to only block the ACLs, using this will set blockPublicPolicy and restrictPublicBuckets to false. |
| static BLOCK_ALL | Block | Use this option if you want to ensure every public access method is blocked. |
blockPublicAcls?
Type:
boolean
(optional)
blockPublicPolicy?
Type:
boolean
(optional)
ignorePublicAcls?
Type:
boolean
(optional)
restrictPublicBuckets?
Type:
boolean
(optional)
static BLOCK_ACLS
⚠️ Deprecated: Use BLOCK_ACLS_ONLY instead.
Type:
Block
static BLOCK_ACLS_ONLY
Type:
Block
Use this option if you want to only block the ACLs, using this will set blockPublicPolicy and restrictPublicBuckets to false.
static BLOCK_ALL
Type:
Block
Use this option if you want to ensure every public access method is blocked.
However keep in mind that this is the default state of an S3 bucket, and leaving blockPublicAccess undefined would also work.

.NET
Go
Java
Python
TypeScript (