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.

      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 - 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 to
      invalid @link
      BucketEncryption.KMS
      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". An error will be emitted if encryption is set to "Unencrypted" or "Managed".
      Returns:
      this
    • enforceSsl

      @Stability(Stable) public BucketProps.Builder enforceSsl(Boolean enforceSsl)
      Sets the value of
      invalid @link
      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
    • notificationsHandlerRole

      @Stability(Stable) public BucketProps.Builder notificationsHandlerRole(IRole notificationsHandlerRole)
      Parameters:
      notificationsHandlerRole - The role to be used by the notifications handler.
      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
    • transferAcceleration

      @Stability(Stable) public BucketProps.Builder transferAcceleration(Boolean transferAcceleration)
      Parameters:
      transferAcceleration - Whether this bucket should have transfer acceleration turned on or not.
      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