Class Bucket

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IResource, IBucket, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-24T21:00:36.293Z") @Stability(Stable) public class Bucket extends BucketBase
An S3 bucket with associated policy objects.

This bucket does not yet have all features that exposed by the underlying BucketResource.

Example:

 import software.amazon.awscdk.RemovalPolicy;
 Bucket.Builder.create(scope, "Bucket")
         .blockPublicAccess(BlockPublicAccess.BLOCK_ALL)
         .encryption(BucketEncryption.S3_MANAGED)
         .enforceSSL(true)
         .versioned(true)
         .removalPolicy(RemovalPolicy.RETAIN)
         .build();
 
  • Constructor Details

    • Bucket

      protected Bucket(software.amazon.jsii.JsiiObjectRef objRef)
    • Bucket

      protected Bucket(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Bucket

      @Stability(Stable) public Bucket(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable BucketProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props -
    • Bucket

      @Stability(Stable) public Bucket(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
  • Method Details

    • fromBucketArn

      @Stability(Stable) @NotNull public static IBucket fromBucketArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String bucketArn)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      bucketArn - This parameter is required.
    • fromBucketAttributes

      @Stability(Stable) @NotNull public static IBucket fromBucketAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull BucketAttributes attrs)
      Creates a Bucket construct that represents an external bucket.

      Parameters:
      scope - The parent creating construct (usually this). This parameter is required.
      id - The construct's name. This parameter is required.
      attrs - A BucketAttributes object. This parameter is required.
    • fromBucketName

      @Stability(Stable) @NotNull public static IBucket fromBucketName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String bucketName)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      bucketName - This parameter is required.
    • fromCfnBucket

      @Stability(Stable) @NotNull public static IBucket fromCfnBucket(@NotNull CfnBucket cfnBucket)
      Create a mutable IBucket based on a low-level CfnBucket.

      Parameters:
      cfnBucket - This parameter is required.
    • validateBucketName

      @Stability(Stable) public static void validateBucketName(@NotNull String physicalName)
      Thrown an exception if the given bucket name is not valid.

      Parameters:
      physicalName - name of the bucket. This parameter is required.
    • addCorsRule

      @Stability(Stable) public void addCorsRule(@NotNull CorsRule rule)
      Adds a cross-origin access configuration for objects in an Amazon S3 bucket.

      Parameters:
      rule - The CORS configuration rule to add. This parameter is required.
    • addInventory

      @Stability(Stable) public void addInventory(@NotNull Inventory inventory)
      Add an inventory configuration.

      Parameters:
      inventory - configuration to add. This parameter is required.
    • addLifecycleRule

      @Stability(Stable) public void addLifecycleRule(@NotNull LifecycleRule rule)
      Add a lifecycle rule to the bucket.

      Parameters:
      rule - The rule to add. This parameter is required.
    • addMetric

      @Stability(Stable) public void addMetric(@NotNull BucketMetrics metric)
      Adds a metrics configuration for the CloudWatch request metrics from the bucket.

      Parameters:
      metric - The metric configuration to add. This parameter is required.
    • getBucketArn

      @Stability(Stable) @NotNull public String getBucketArn()
      The ARN of the bucket.
      Specified by:
      getBucketArn in interface IBucket
      Specified by:
      getBucketArn in class BucketBase
    • getBucketDomainName

      @Stability(Stable) @NotNull public String getBucketDomainName()
      The IPv4 DNS name of the specified bucket.
      Specified by:
      getBucketDomainName in interface IBucket
      Specified by:
      getBucketDomainName in class BucketBase
    • getBucketDualStackDomainName

      @Stability(Stable) @NotNull public String getBucketDualStackDomainName()
      The IPv6 DNS name of the specified bucket.
      Specified by:
      getBucketDualStackDomainName in interface IBucket
      Specified by:
      getBucketDualStackDomainName in class BucketBase
    • getBucketName

      @Stability(Stable) @NotNull public String getBucketName()
      The name of the bucket.
      Specified by:
      getBucketName in interface IBucket
      Specified by:
      getBucketName in class BucketBase
    • getBucketRegionalDomainName

      @Stability(Stable) @NotNull public String getBucketRegionalDomainName()
      The regional domain name of the specified bucket.
      Specified by:
      getBucketRegionalDomainName in interface IBucket
      Specified by:
      getBucketRegionalDomainName in class BucketBase
    • getBucketWebsiteDomainName

      @Stability(Stable) @NotNull public String getBucketWebsiteDomainName()
      The Domain name of the static website.
      Specified by:
      getBucketWebsiteDomainName in interface IBucket
      Specified by:
      getBucketWebsiteDomainName in class BucketBase
    • getBucketWebsiteUrl

      @Stability(Stable) @NotNull public String getBucketWebsiteUrl()
      The URL of the static website.
      Specified by:
      getBucketWebsiteUrl in interface IBucket
      Specified by:
      getBucketWebsiteUrl in class BucketBase
    • getEncryptionKey

      @Stability(Stable) @Nullable public IKey getEncryptionKey()
      Optional KMS encryption key associated with this bucket.
      Specified by:
      getEncryptionKey in interface IBucket
      Specified by:
      getEncryptionKey in class BucketBase
    • getIsWebsite

      @Stability(Stable) @Nullable public Boolean getIsWebsite()
      If this bucket has been configured for static website hosting.
      Specified by:
      getIsWebsite in interface IBucket
      Specified by:
      getIsWebsite in class BucketBase
    • getAutoCreatePolicy

      @Stability(Stable) @NotNull protected Boolean getAutoCreatePolicy()
      Indicates if a bucket resource policy should automatically created upon the first call to addToResourcePolicy.
      Specified by:
      getAutoCreatePolicy in class BucketBase
    • setAutoCreatePolicy

      @Stability(Stable) protected void setAutoCreatePolicy(@NotNull Boolean value)
      Indicates if a bucket resource policy should automatically created upon the first call to addToResourcePolicy.
      Specified by:
      setAutoCreatePolicy in class BucketBase
    • getDisallowPublicAccess

      @Stability(Stable) @Nullable protected Boolean getDisallowPublicAccess()
      Whether to disallow public access.
      Specified by:
      getDisallowPublicAccess in class BucketBase
    • setDisallowPublicAccess

      @Stability(Stable) protected void setDisallowPublicAccess(@Nullable Boolean value)
      Whether to disallow public access.
      Specified by:
      setDisallowPublicAccess in class BucketBase
    • getPolicy

      @Stability(Stable) @Nullable public BucketPolicy getPolicy()
      The resource policy associated with this bucket.

      If autoCreatePolicy is true, a BucketPolicy will be created upon the first call to addToResourcePolicy(s).

      Specified by:
      getPolicy in interface IBucket
      Specified by:
      getPolicy in class BucketBase
    • setPolicy

      @Stability(Stable) public void setPolicy(@Nullable BucketPolicy value)
      The resource policy associated with this bucket.

      If autoCreatePolicy is true, a BucketPolicy will be created upon the first call to addToResourcePolicy(s).

      Specified by:
      setPolicy in interface IBucket
      Specified by:
      setPolicy in class BucketBase