Class BucketProps.Builder
java.lang.Object
software.amazon.awscdk.services.s3.BucketProps.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<BucketProps>
- Enclosing interface:
- BucketProps
@Stability(Stable)
public static final class BucketProps.Builder
extends Object
implements software.amazon.jsii.Builder<BucketProps>
A builder for
BucketProps
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccessControl
(BucketAccessControl accessControl) Sets the value ofBucketProps.getAccessControl()
autoDeleteObjects
(Boolean autoDeleteObjects) Sets the value ofBucketProps.getAutoDeleteObjects()
blockPublicAccess
(BlockPublicAccess blockPublicAccess) Sets the value ofBucketProps.getBlockPublicAccess()
bucketKeyEnabled
(Boolean bucketKeyEnabled) Sets the value ofBucketProps.getBucketKeyEnabled()
bucketName
(String bucketName) Sets the value ofBucketProps.getBucketName()
build()
Builds the configured instance.Sets the value ofBucketProps.getCors()
encryption
(BucketEncryption encryption) Sets the value ofBucketProps.getEncryption()
encryptionKey
(IKey encryptionKey) Sets the value ofBucketProps.getEncryptionKey()
enforceSsl
(Boolean enforceSsl) Sets the value ofBucketProps#getEnforceSsl
eventBridgeEnabled
(Boolean eventBridgeEnabled) Sets the value ofBucketProps.getEventBridgeEnabled()
intelligentTieringConfigurations
(List<? extends IntelligentTieringConfiguration> intelligentTieringConfigurations) Sets the value ofBucketProps.getIntelligentTieringConfigurations()
inventories
(List<? extends Inventory> inventories) Sets the value ofBucketProps.getInventories()
lifecycleRules
(List<? extends LifecycleRule> lifecycleRules) Sets the value ofBucketProps.getLifecycleRules()
metrics
(List<? extends BucketMetrics> metrics) Sets the value ofBucketProps.getMetrics()
notificationsHandlerRole
(IRole notificationsHandlerRole) Sets the value ofBucketProps.getNotificationsHandlerRole()
objectOwnership
(ObjectOwnership objectOwnership) Sets the value ofBucketProps.getObjectOwnership()
publicReadAccess
(Boolean publicReadAccess) Sets the value ofBucketProps.getPublicReadAccess()
removalPolicy
(RemovalPolicy removalPolicy) Sets the value ofBucketProps.getRemovalPolicy()
serverAccessLogsBucket
(IBucket serverAccessLogsBucket) Sets the value ofBucketProps.getServerAccessLogsBucket()
serverAccessLogsPrefix
(String serverAccessLogsPrefix) Sets the value ofBucketProps.getServerAccessLogsPrefix()
transferAcceleration
(Boolean transferAcceleration) Sets the value ofBucketProps.getTransferAcceleration()
Sets the value ofBucketProps.getVersioned()
websiteErrorDocument
(String websiteErrorDocument) Sets the value ofBucketProps.getWebsiteErrorDocument()
websiteIndexDocument
(String websiteIndexDocument) Sets the value ofBucketProps.getWebsiteIndexDocument()
websiteRedirect
(RedirectTarget websiteRedirect) Sets the value ofBucketProps.getWebsiteRedirect()
websiteRoutingRules
(List<? extends RoutingRule> websiteRoutingRules) Sets the value ofBucketProps.getWebsiteRoutingRules()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
accessControl
Sets the value ofBucketProps.getAccessControl()
- Parameters:
accessControl
- Specifies a canned ACL that grants predefined permissions to the bucket.- Returns:
this
-
autoDeleteObjects
Sets the value ofBucketProps.getAutoDeleteObjects()
- Parameters:
autoDeleteObjects
- Whether all objects should be automatically deleted when the bucket is removed from the stack or when the stack is deleted. Requires theremovalPolicy
to be set toRemovalPolicy.DESTROY
.Warning if you have deployed a bucket with
autoDeleteObjects: true
, switching this tofalse
in a CDK version before1.126.0
will lead to all objects in the bucket being deleted. Be sure to update your bucket resources by deploying with CDK version1.126.0
or later before switching this value tofalse
.- Returns:
this
-
blockPublicAccess
@Stability(Stable) public BucketProps.Builder blockPublicAccess(BlockPublicAccess blockPublicAccess) Sets the value ofBucketProps.getBlockPublicAccess()
- Parameters:
blockPublicAccess
- The block public access configuration of this bucket.- Returns:
this
-
bucketKeyEnabled
Sets the value ofBucketProps.getBucketKeyEnabled()
- Parameters:
bucketKeyEnabled
- Specifies whether Amazon S3 should use an S3 Bucket Key with server-side encryption using KMS (SSE-KMS) for new objects in the bucket. Only relevant, when Encryption is set toBucketEncryption.KMS
- Returns:
this
-
bucketName
Sets the value ofBucketProps.getBucketName()
- Parameters:
bucketName
- Physical name of this bucket.- Returns:
this
-
cors
Sets the value ofBucketProps.getCors()
- Parameters:
cors
- The CORS configuration of this bucket.- Returns:
this
-
encryption
Sets the value ofBucketProps.getEncryption()
- Parameters:
encryption
- The kind of server-side encryption to apply to this bucket. If you choose KMS, you can specify a KMS key viaencryptionKey
. If encryption key is not specified, a key will automatically be created.- Returns:
this
-
encryptionKey
Sets the value ofBucketProps.getEncryptionKey()
- Parameters:
encryptionKey
- External KMS key to use for bucket encryption. The 'encryption' property must be either not specified or set to "Kms". An error will be emitted if encryption is set to "Unencrypted" or "Managed".- Returns:
this
-
enforceSsl
Sets the value ofBucketProps#getEnforceSsl
- Parameters:
enforceSsl
- Enforces SSL for requests. S3.5 of the AWS Foundational Security Best Practices Regarding S3.- Returns:
this
-
eventBridgeEnabled
Sets the value ofBucketProps.getEventBridgeEnabled()
- Parameters:
eventBridgeEnabled
- Whether this bucket should send notifications to Amazon EventBridge or not.- Returns:
this
-
intelligentTieringConfigurations
@Stability(Stable) public BucketProps.Builder intelligentTieringConfigurations(List<? extends IntelligentTieringConfiguration> intelligentTieringConfigurations) Sets the value ofBucketProps.getIntelligentTieringConfigurations()
- Parameters:
intelligentTieringConfigurations
- Inteligent Tiering Configurations.- Returns:
this
-
inventories
Sets the value ofBucketProps.getInventories()
- Parameters:
inventories
- The inventory configuration of the bucket.- Returns:
this
-
lifecycleRules
@Stability(Stable) public BucketProps.Builder lifecycleRules(List<? extends LifecycleRule> lifecycleRules) Sets the value ofBucketProps.getLifecycleRules()
- Parameters:
lifecycleRules
- Rules that define how Amazon S3 manages objects during their lifetime.- Returns:
this
-
metrics
Sets the value ofBucketProps.getMetrics()
- Parameters:
metrics
- The metrics configuration of this bucket.- Returns:
this
-
notificationsHandlerRole
@Stability(Stable) public BucketProps.Builder notificationsHandlerRole(IRole notificationsHandlerRole) Sets the value ofBucketProps.getNotificationsHandlerRole()
- Parameters:
notificationsHandlerRole
- The role to be used by the notifications handler.- Returns:
this
-
objectOwnership
Sets the value ofBucketProps.getObjectOwnership()
- Parameters:
objectOwnership
- The objectOwnership of the bucket.- Returns:
this
-
publicReadAccess
Sets the value ofBucketProps.getPublicReadAccess()
- Parameters:
publicReadAccess
- Grants public read access to all objects in the bucket. Similar to callingbucket.grantPublicAccess()
- Returns:
this
-
removalPolicy
Sets the value ofBucketProps.getRemovalPolicy()
- Parameters:
removalPolicy
- Policy to apply when the bucket is removed from this stack.- Returns:
this
-
serverAccessLogsBucket
@Stability(Stable) public BucketProps.Builder serverAccessLogsBucket(IBucket serverAccessLogsBucket) Sets the value ofBucketProps.getServerAccessLogsBucket()
- Parameters:
serverAccessLogsBucket
- Destination bucket for the server access logs.- Returns:
this
-
serverAccessLogsPrefix
Sets the value ofBucketProps.getServerAccessLogsPrefix()
- Parameters:
serverAccessLogsPrefix
- Optional log file prefix to use for the bucket's access logs. If defined without "serverAccessLogsBucket", enables access logs to current bucket with this prefix.- Returns:
this
-
transferAcceleration
Sets the value ofBucketProps.getTransferAcceleration()
- Parameters:
transferAcceleration
- Whether this bucket should have transfer acceleration turned on or not.- Returns:
this
-
versioned
Sets the value ofBucketProps.getVersioned()
- Parameters:
versioned
- Whether this bucket should have versioning turned on or not.- Returns:
this
-
websiteErrorDocument
Sets the value ofBucketProps.getWebsiteErrorDocument()
- Parameters:
websiteErrorDocument
- The name of the error document (e.g. "404.html") for the website.websiteIndexDocument
must also be set if this is set.- Returns:
this
-
websiteIndexDocument
Sets the value ofBucketProps.getWebsiteIndexDocument()
- Parameters:
websiteIndexDocument
- The name of the index document (e.g. "index.html") for the website. Enables static website hosting for this bucket.- Returns:
this
-
websiteRedirect
Sets the value ofBucketProps.getWebsiteRedirect()
- Parameters:
websiteRedirect
- Specifies the redirect behavior of all requests to a website endpoint of a bucket. If you specify this property, you can't specify "websiteIndexDocument", "websiteErrorDocument" nor , "websiteRoutingRules".- Returns:
this
-
websiteRoutingRules
@Stability(Stable) public BucketProps.Builder websiteRoutingRules(List<? extends RoutingRule> websiteRoutingRules) Sets the value ofBucketProps.getWebsiteRoutingRules()
- Parameters:
websiteRoutingRules
- Rules that define when a redirect is applied and the redirect behavior.- Returns:
this
-
build
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<BucketProps>
- Returns:
- a new instance of
BucketProps
- Throws:
NullPointerException
- if any required attribute was not provided
-