Class Bucket
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.s3.BucketBase
software.amazon.awscdk.services.s3.Bucket
- All Implemented Interfaces:
IResource,IBucket,IBucketRef,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.116.0 (build 0eddcff)",
date="2025-10-24T13:34:46.092Z")
@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();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.s3.IBucket
IBucket.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBucket(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedBucket(software.amazon.jsii.JsiiObjectRef objRef) Bucket(software.constructs.Construct scope, String id, BucketProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCorsRule(CorsRule rule) Adds a cross-origin access configuration for objects in an Amazon S3 bucket.voidaddInventory(Inventory inventory) Add an inventory configuration.voidAdd a lifecycle rule to the bucket.voidaddMetric(BucketMetrics metric) Adds a metrics configuration for the CloudWatch request metrics from the bucket.static IBucketfromBucketArn(software.constructs.Construct scope, String id, String bucketArn) static IBucketfromBucketAttributes(software.constructs.Construct scope, String id, BucketAttributes attrs) Creates a Bucket construct that represents an external bucket.static IBucketfromBucketName(software.constructs.Construct scope, String id, String bucketName) static IBucketfromCfnBucket(CfnBucket cfnBucket) Create a mutableIBucketbased on a low-levelCfnBucket.protected BooleanIndicates if a bucket resource policy should automatically created upon the first call toaddToResourcePolicy.The ARN of the bucket.The IPv4 DNS name of the specified bucket.The IPv6 DNS name of the specified bucket.The name of the bucket.The regional domain name of the specified bucket.The Domain name of the static website.The URL of the static website.protected BooleanWhether to disallow public access.Optional KMS encryption key associated with this bucket.If this bucket has been configured for static website hosting.The resource policy associated with this bucket.Role used to set up permissions on this bucket for replication.protected voidsetAutoCreatePolicy(Boolean value) Indicates if a bucket resource policy should automatically created upon the first call toaddToResourcePolicy.protected voidsetDisallowPublicAccess(Boolean value) Whether to disallow public access.voidsetPolicy(BucketPolicy value) The resource policy associated with this bucket.voidsetReplicationRoleArn(String value) Role used to set up permissions on this bucket for replication.static voidvalidateBucketName(String physicalName) Thrown an exception if the given bucket name is not valid.static voidvalidateBucketName(String physicalName, Boolean allowLegacyBucketNaming) Thrown an exception if the given bucket name is not valid.Methods inherited from class software.amazon.awscdk.services.s3.BucketBase
addEventNotification, addObjectCreatedNotification, addObjectRemovedNotification, addReplicationPolicy, addReplicationPolicy, addReplicationPolicy, addToResourcePolicy, arnForObjects, enableEventBridgeNotification, getBucketRef, getNotificationsHandlerRole, getNotificationsSkipDestinationValidation, getObjectOwnership, grantDelete, grantDelete, grantPublicAccess, grantPut, grantPut, grantPutAcl, grantPutAcl, grantRead, grantRead, grantReadWrite, grantReadWrite, grantReplicationPermission, grantWrite, grantWrite, grantWrite, onCloudTrailEvent, onCloudTrailEvent, onCloudTrailPutObject, onCloudTrailPutObject, onCloudTrailWriteObject, onCloudTrailWriteObject, s3UrlForObject, s3UrlForObject, setNotificationsHandlerRole, setNotificationsSkipDestinationValidation, setObjectOwnership, transferAccelerationUrlForObject, transferAccelerationUrlForObject, transferAccelerationUrlForObject, urlForObject, urlForObject, virtualHostedUrlForObject, virtualHostedUrlForObject, virtualHostedUrlForObjectMethods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourceMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
PROPERTY_INJECTION_ID
Uniquely identifies this class.
-
-
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
- 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 (usuallythis). This parameter is required.id- The construct's name. This parameter is required.attrs- ABucketAttributesobject. 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
Create a mutableIBucketbased on a low-levelCfnBucket.- Parameters:
cfnBucket- This parameter is required.
-
validateBucketName
@Stability(Stable) public static void validateBucketName(@NotNull String physicalName, @Nullable Boolean allowLegacyBucketNaming) Thrown an exception if the given bucket name is not valid.- Parameters:
physicalName- name of the bucket. This parameter is required.allowLegacyBucketNaming- allow legacy bucket naming style, default is false.
-
validateBucketName
Thrown an exception if the given bucket name is not valid.- Parameters:
physicalName- name of the bucket. This parameter is required.
-
addCorsRule
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
Add an inventory configuration.- Parameters:
inventory- configuration to add. This parameter is required.
-
addLifecycleRule
Add a lifecycle rule to the bucket.- Parameters:
rule- The rule to add. This parameter is required.
-
addMetric
Adds a metrics configuration for the CloudWatch request metrics from the bucket.- Parameters:
metric- The metric configuration to add. This parameter is required.
-
getBucketArn
The ARN of the bucket.- Specified by:
getBucketArnin interfaceIBucket- Specified by:
getBucketArnin classBucketBase
-
getBucketDomainName
The IPv4 DNS name of the specified bucket.- Specified by:
getBucketDomainNamein interfaceIBucket- Specified by:
getBucketDomainNamein classBucketBase
-
getBucketDualStackDomainName
The IPv6 DNS name of the specified bucket.- Specified by:
getBucketDualStackDomainNamein interfaceIBucket- Specified by:
getBucketDualStackDomainNamein classBucketBase
-
getBucketName
The name of the bucket.- Specified by:
getBucketNamein interfaceIBucket- Specified by:
getBucketNamein classBucketBase
-
getBucketRegionalDomainName
The regional domain name of the specified bucket.- Specified by:
getBucketRegionalDomainNamein interfaceIBucket- Specified by:
getBucketRegionalDomainNamein classBucketBase
-
getBucketWebsiteDomainName
The Domain name of the static website.- Specified by:
getBucketWebsiteDomainNamein interfaceIBucket- Specified by:
getBucketWebsiteDomainNamein classBucketBase
-
getBucketWebsiteUrl
The URL of the static website.- Specified by:
getBucketWebsiteUrlin interfaceIBucket- Specified by:
getBucketWebsiteUrlin classBucketBase
-
getEncryptionKey
Optional KMS encryption key associated with this bucket.- Specified by:
getEncryptionKeyin interfaceIBucket- Specified by:
getEncryptionKeyin classBucketBase
-
getIsWebsite
If this bucket has been configured for static website hosting.- Specified by:
getIsWebsitein interfaceIBucket- Specified by:
getIsWebsitein classBucketBase
-
getAutoCreatePolicy
Indicates if a bucket resource policy should automatically created upon the first call toaddToResourcePolicy.- Specified by:
getAutoCreatePolicyin classBucketBase
-
setAutoCreatePolicy
Indicates if a bucket resource policy should automatically created upon the first call toaddToResourcePolicy.- Specified by:
setAutoCreatePolicyin classBucketBase
-
getDisallowPublicAccess
Whether to disallow public access.- Specified by:
getDisallowPublicAccessin classBucketBase
-
setDisallowPublicAccess
Whether to disallow public access.- Specified by:
setDisallowPublicAccessin classBucketBase
-
getPolicy
The resource policy associated with this bucket.If
autoCreatePolicyis true, aBucketPolicywill be created upon the first call to addToResourcePolicy(s).- Specified by:
getPolicyin interfaceIBucket- Specified by:
getPolicyin classBucketBase
-
setPolicy
The resource policy associated with this bucket.If
autoCreatePolicyis true, aBucketPolicywill be created upon the first call to addToResourcePolicy(s).- Specified by:
setPolicyin interfaceIBucket- Specified by:
setPolicyin classBucketBase
-
getReplicationRoleArn
Role used to set up permissions on this bucket for replication.- Specified by:
getReplicationRoleArnin interfaceIBucket- Specified by:
getReplicationRoleArnin classBucketBase
-
setReplicationRoleArn
Role used to set up permissions on this bucket for replication.- Specified by:
setReplicationRoleArnin interfaceIBucket- Specified by:
setReplicationRoleArnin classBucketBase
-