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 Details

    • Builder

      public Builder()
  • Method Details

    • accessControl

      @Stability(Stable) public BucketProps.Builder accessControl(BucketAccessControl accessControl)
      Parameters:
      accessControl - Specifies a canned ACL that grants predefined permissions to the bucket.
      Returns:
      this
    • autoDeleteObjects

      @Stability(Stable) public BucketProps.Builder autoDeleteObjects(Boolean autoDeleteObjects)
      Parameters:
      autoDeleteObjects - Whether all objects should be automatically deleted when the bucket is removed from the stack or when the stack is deleted. Requires the removalPolicy to be set to RemovalPolicy.DESTROY.

      Warning if you have deployed a bucket with autoDeleteObjects: true, switching this to false in a CDK version before 1.126.0 will lead to all objects in the bucket being deleted. Be sure to update your bucket resources by deploying with CDK version 1.126.0 or later before switching this value to false.

      Setting autoDeleteObjects to true on a bucket will add s3: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 for s3:PutObject to prevent race conditions with external bucket writers.

      Returns:
      this
    • blockPublicAccess

      @Stability(Stable) public BucketProps.Builder blockPublicAccess(BlockPublicAccess blockPublicAccess)
      Parameters:
      blockPublicAccess - The block public access configuration of this bucket.
      Returns:
      this
    • bucketKeyEnabled

      @Stability(Stable) public BucketProps.Builder bucketKeyEnabled(Boolean bucketKeyEnabled)
      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

      @Stability(Stable) public BucketProps.Builder bucketName(String bucketName)
      Sets the value of BucketProps.getBucketName()
      Parameters:
      bucketName - Physical name of this bucket.
      Returns:
      this
    • cors

      @Stability(Stable) public BucketProps.Builder cors(List<? extends CorsRule> cors)
      Sets the value of BucketProps.getCors()
      Parameters:
      cors - The CORS configuration of this bucket.
      Returns:
      this
    • encryption

      @Stability(Stable) public BucketProps.Builder encryption(BucketEncryption encryption)
      Sets the value of BucketProps.getEncryption()
      Parameters:
      encryption - The kind of server-side encryption to apply to this bucket. If you choose KMS, you can specify a KMS key via encryptionKey. If encryption key is not specified, a key will automatically be created.
      Returns:
      this
    • encryptionKey

      @Stability(Stable) public BucketProps.Builder encryptionKey(IKey encryptionKey)
      Parameters:
      encryptionKey - External KMS key to use for bucket encryption. The encryption property must be either not specified or set to KMS or DSSE. An error will be emitted if encryption is set to UNENCRYPTED or S3_MANAGED.
      Returns:
      this
    • enforceSsl

      @Stability(Stable) public BucketProps.Builder enforceSsl(Boolean enforceSsl)
      Sets the value of BucketProps#getEnforceSsl
      Parameters:
      enforceSsl - Enforces SSL for requests. S3.5 of the AWS Foundational Security Best Practices Regarding S3.
      Returns:
      this
    • eventBridgeEnabled

      @Stability(Stable) public BucketProps.Builder eventBridgeEnabled(Boolean eventBridgeEnabled)
      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)
      Parameters:
      intelligentTieringConfigurations - Inteligent Tiering Configurations.
      Returns:
      this
    • inventories

      @Stability(Stable) public BucketProps.Builder inventories(List<? extends Inventory> inventories)
      Parameters:
      inventories - The inventory configuration of the bucket.
      Returns:
      this
    • lifecycleRules

      @Stability(Stable) public BucketProps.Builder lifecycleRules(List<? extends LifecycleRule> lifecycleRules)
      Parameters:
      lifecycleRules - Rules that define how Amazon S3 manages objects during their lifetime.
      Returns:
      this
    • metrics

      @Stability(Stable) public BucketProps.Builder metrics(List<? extends BucketMetrics> metrics)
      Sets the value of BucketProps.getMetrics()
      Parameters:
      metrics - The metrics configuration of this bucket.
      Returns:
      this
    • minimumTlsVersion

      @Stability(Stable) public BucketProps.Builder minimumTlsVersion(Number minimumTlsVersion)
      Sets the value of BucketProps#getMinimumTlsVersion
      Parameters:
      minimumTlsVersion - Enforces minimum TLS version for requests. Requires enforceSSL to be enabled.
      Returns:
      this
    • notificationsHandlerRole

      @Stability(Stable) public BucketProps.Builder notificationsHandlerRole(IRole notificationsHandlerRole)
      Parameters:
      notificationsHandlerRole - The role to be used by the notifications handler.
      Returns:
      this
    • notificationsSkipDestinationValidation

      @Stability(Stable) public BucketProps.Builder notificationsSkipDestinationValidation(Boolean notificationsSkipDestinationValidation)
      Parameters:
      notificationsSkipDestinationValidation - Skips notification validation of Amazon SQS, Amazon SNS, and Lambda destinations.
      Returns:
      this
    • objectLockDefaultRetention

      @Stability(Stable) public BucketProps.Builder objectLockDefaultRetention(ObjectLockRetention objectLockDefaultRetention)
      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

      @Stability(Stable) public BucketProps.Builder objectLockEnabled(Boolean objectLockEnabled)
      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

      @Stability(Stable) public BucketProps.Builder objectOwnership(ObjectOwnership objectOwnership)
      Parameters:
      objectOwnership - The objectOwnership of the bucket.
      Returns:
      this
    • publicReadAccess

      @Stability(Stable) public BucketProps.Builder publicReadAccess(Boolean publicReadAccess)
      Parameters:
      publicReadAccess - Grants public read access to all objects in the bucket. Similar to calling bucket.grantPublicAccess()
      Returns:
      this
    • removalPolicy

      @Stability(Stable) public BucketProps.Builder removalPolicy(RemovalPolicy removalPolicy)
      Parameters:
      removalPolicy - Policy to apply when the bucket is removed from this stack.
      Returns:
      this
    • serverAccessLogsBucket

      @Stability(Stable) public BucketProps.Builder serverAccessLogsBucket(IBucket serverAccessLogsBucket)
      Parameters:
      serverAccessLogsBucket - Destination bucket for the server access logs.
      Returns:
      this
    • serverAccessLogsPrefix

      @Stability(Stable) public BucketProps.Builder serverAccessLogsPrefix(String serverAccessLogsPrefix)
      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)
      Parameters:
      targetObjectKeyFormat - Optional key format for log objects.
      Returns:
      this
    • transferAcceleration

      @Stability(Stable) public BucketProps.Builder transferAcceleration(Boolean transferAcceleration)
      Parameters:
      transferAcceleration - Whether this bucket should have transfer acceleration turned on or not.
      Returns:
      this
    • transitionDefaultMinimumObjectSize

      @Stability(Stable) public BucketProps.Builder transitionDefaultMinimumObjectSize(TransitionDefaultMinimumObjectSize transitionDefaultMinimumObjectSize)
      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 custom objectSizeGreaterThan or objectSizeLessThan for lifecycleRules property. Custom filters always take precedence over the default transition behavior.
      Returns:
      this
    • versioned

      @Stability(Stable) public BucketProps.Builder versioned(Boolean versioned)
      Sets the value of BucketProps.getVersioned()
      Parameters:
      versioned - Whether this bucket should have versioning turned on or not.
      Returns:
      this
    • websiteErrorDocument

      @Stability(Stable) public BucketProps.Builder websiteErrorDocument(String websiteErrorDocument)
      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

      @Stability(Stable) public BucketProps.Builder websiteIndexDocument(String websiteIndexDocument)
      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

      @Stability(Stable) public BucketProps.Builder websiteRedirect(RedirectTarget websiteRedirect)
      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)
      Parameters:
      websiteRoutingRules - Rules that define when a redirect is applied and the redirect behavior.
      Returns:
      this
    • build

      @Stability(Stable) public BucketProps build()
      Builds the configured instance.
      Specified by:
      build in interface software.amazon.jsii.Builder<BucketProps>
      Returns:
      a new instance of BucketProps
      Throws:
      NullPointerException - if any required attribute was not provided