Class BucketProps.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<BucketProps>
- Enclosing interface:
- BucketProps
BucketProps
-
Constructor Summary
-
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()
minimumTlsVersion
(Number minimumTlsVersion) Sets the value ofBucketProps#getMinimumTlsVersion
notificationsHandlerRole
(IRole notificationsHandlerRole) Sets the value ofBucketProps.getNotificationsHandlerRole()
notificationsSkipDestinationValidation
(Boolean notificationsSkipDestinationValidation) Sets the value ofBucketProps.getNotificationsSkipDestinationValidation()
objectLockDefaultRetention
(ObjectLockRetention objectLockDefaultRetention) Sets the value ofBucketProps.getObjectLockDefaultRetention()
objectLockEnabled
(Boolean objectLockEnabled) Sets the value ofBucketProps.getObjectLockEnabled()
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()
targetObjectKeyFormat
(TargetObjectKeyFormat targetObjectKeyFormat) Sets the value ofBucketProps.getTargetObjectKeyFormat()
transferAcceleration
(Boolean transferAcceleration) Sets the value ofBucketProps.getTransferAcceleration()
transitionDefaultMinimumObjectSize
(TransitionDefaultMinimumObjectSize transitionDefaultMinimumObjectSize) Sets the value ofBucketProps.getTransitionDefaultMinimumObjectSize()
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
.Setting
autoDeleteObjects
to true on a bucket will adds3:PutBucketPolicy
to the bucket policy. This is because during bucket deletion, the custom resource provider needs to update the bucket policy by adding a deny policy fors3:PutObject
to prevent race conditions with external bucket writers.- 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
- Whether Amazon S3 should use its own intermediary key to generate data keys. Only relevant when using KMS for encryption.- If not enabled, every object GET and PUT will cause an API call to KMS (with the attendant cost implications of that).
- If enabled, S3 will use its own time-limited key instead.
Only relevant, when Encryption is not set to
BucketEncryption.UNENCRYPTED
.- 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. Theencryption
property must be either not specified or set toKMS
orDSSE
. An error will be emitted ifencryption
is set toUNENCRYPTED
orS3_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
-
minimumTlsVersion
Sets the value ofBucketProps#getMinimumTlsVersion
- Parameters:
minimumTlsVersion
- Enforces minimum TLS version for requests. RequiresenforceSSL
to be enabled.- 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
-
notificationsSkipDestinationValidation
@Stability(Stable) public BucketProps.Builder notificationsSkipDestinationValidation(Boolean notificationsSkipDestinationValidation) Sets the value ofBucketProps.getNotificationsSkipDestinationValidation()
- Parameters:
notificationsSkipDestinationValidation
- Skips notification validation of Amazon SQS, Amazon SNS, and Lambda destinations.- Returns:
this
-
objectLockDefaultRetention
@Stability(Stable) public BucketProps.Builder objectLockDefaultRetention(ObjectLockRetention objectLockDefaultRetention) Sets the value ofBucketProps.getObjectLockDefaultRetention()
- Parameters:
objectLockDefaultRetention
- The default retention mode and rules for S3 Object Lock. Default retention can be configured after a bucket is created if the bucket already has object lock enabled. Enabling object lock for existing buckets is not supported.- Returns:
this
-
objectLockEnabled
Sets the value ofBucketProps.getObjectLockEnabled()
- Parameters:
objectLockEnabled
- Enable object lock on the bucket. Enabling object lock for existing buckets is not supported. Object lock must be enabled when the bucket is created.- 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
-
targetObjectKeyFormat
@Stability(Stable) public BucketProps.Builder targetObjectKeyFormat(TargetObjectKeyFormat targetObjectKeyFormat) Sets the value ofBucketProps.getTargetObjectKeyFormat()
- Parameters:
targetObjectKeyFormat
- Optional key format for log objects.- Returns:
this
-
transferAcceleration
Sets the value ofBucketProps.getTransferAcceleration()
- Parameters:
transferAcceleration
- Whether this bucket should have transfer acceleration turned on or not.- Returns:
this
-
transitionDefaultMinimumObjectSize
@Stability(Stable) public BucketProps.Builder transitionDefaultMinimumObjectSize(TransitionDefaultMinimumObjectSize transitionDefaultMinimumObjectSize) Sets the value ofBucketProps.getTransitionDefaultMinimumObjectSize()
- Parameters:
transitionDefaultMinimumObjectSize
- Indicates which default minimum object size behavior is applied to the lifecycle configuration. To customize the minimum object size for any transition you can add a filter that specifies a customobjectSizeGreaterThan
orobjectSizeLessThan
forlifecycleRules
property. Custom filters always take precedence over the default transition behavior.- 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
-