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
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.104.0 (build e79254c)",
date="2024-11-06T23:25:16.199Z")
@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 classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.s3.IBucket
IBucket.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
Bucket
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Bucket
(software.amazon.jsii.JsiiObjectRef objRef) Bucket
(software.constructs.Construct scope, String id, BucketProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCorsRule
(CorsRule rule) Adds a cross-origin access configuration for objects in an Amazon S3 bucket.void
addInventory
(Inventory inventory) Add an inventory configuration.void
Add a lifecycle rule to the bucket.void
addMetric
(BucketMetrics metric) Adds a metrics configuration for the CloudWatch request metrics from the bucket.static IBucket
fromBucketArn
(software.constructs.Construct scope, String id, String bucketArn) static IBucket
fromBucketAttributes
(software.constructs.Construct scope, String id, BucketAttributes attrs) Creates a Bucket construct that represents an external bucket.static IBucket
fromBucketName
(software.constructs.Construct scope, String id, String bucketName) static IBucket
fromCfnBucket
(CfnBucket cfnBucket) Create a mutableIBucket
based on a low-levelCfnBucket
.protected Boolean
Indicates 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 Boolean
Whether 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.protected void
setAutoCreatePolicy
(Boolean value) Indicates if a bucket resource policy should automatically created upon the first call toaddToResourcePolicy
.protected void
setDisallowPublicAccess
(Boolean value) Whether to disallow public access.void
setPolicy
(BucketPolicy value) The resource policy associated with this bucket.static void
validateBucketName
(String physicalName) Thrown an exception if the given bucket name is not valid.static void
validateBucketName
(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, addToResourcePolicy, arnForObjects, enableEventBridgeNotification, getNotificationsHandlerRole, getNotificationsSkipDestinationValidation, getObjectOwnership, grantDelete, grantDelete, grantPublicAccess, grantPut, grantPut, grantPutAcl, grantPutAcl, grantRead, grantRead, grantReadWrite, grantReadWrite, grantWrite, grantWrite, grantWrite, onCloudTrailEvent, onCloudTrailEvent, onCloudTrailPutObject, onCloudTrailPutObject, onCloudTrailWriteObject, onCloudTrailWriteObject, s3UrlForObject, s3UrlForObject, setNotificationsHandlerRole, setNotificationsSkipDestinationValidation, setObjectOwnership, transferAccelerationUrlForObject, transferAccelerationUrlForObject, transferAccelerationUrlForObject, urlForObject, urlForObject, virtualHostedUrlForObject, virtualHostedUrlForObject, virtualHostedUrlForObject
Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResource
Methods inherited from class software.constructs.Construct
getNode, isConstruct, toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.constructs.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
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
- ABucketAttributes
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
Create a mutableIBucket
based 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:
getBucketArn
in interfaceIBucket
- Specified by:
getBucketArn
in classBucketBase
-
getBucketDomainName
The IPv4 DNS name of the specified bucket.- Specified by:
getBucketDomainName
in interfaceIBucket
- Specified by:
getBucketDomainName
in classBucketBase
-
getBucketDualStackDomainName
The IPv6 DNS name of the specified bucket.- Specified by:
getBucketDualStackDomainName
in interfaceIBucket
- Specified by:
getBucketDualStackDomainName
in classBucketBase
-
getBucketName
The name of the bucket.- Specified by:
getBucketName
in interfaceIBucket
- Specified by:
getBucketName
in classBucketBase
-
getBucketRegionalDomainName
The regional domain name of the specified bucket.- Specified by:
getBucketRegionalDomainName
in interfaceIBucket
- Specified by:
getBucketRegionalDomainName
in classBucketBase
-
getBucketWebsiteDomainName
The Domain name of the static website.- Specified by:
getBucketWebsiteDomainName
in interfaceIBucket
- Specified by:
getBucketWebsiteDomainName
in classBucketBase
-
getBucketWebsiteUrl
The URL of the static website.- Specified by:
getBucketWebsiteUrl
in interfaceIBucket
- Specified by:
getBucketWebsiteUrl
in classBucketBase
-
getEncryptionKey
Optional KMS encryption key associated with this bucket.- Specified by:
getEncryptionKey
in interfaceIBucket
- Specified by:
getEncryptionKey
in classBucketBase
-
getIsWebsite
If this bucket has been configured for static website hosting.- Specified by:
getIsWebsite
in interfaceIBucket
- Specified by:
getIsWebsite
in classBucketBase
-
getAutoCreatePolicy
Indicates if a bucket resource policy should automatically created upon the first call toaddToResourcePolicy
.- Specified by:
getAutoCreatePolicy
in classBucketBase
-
setAutoCreatePolicy
Indicates if a bucket resource policy should automatically created upon the first call toaddToResourcePolicy
.- Specified by:
setAutoCreatePolicy
in classBucketBase
-
getDisallowPublicAccess
Whether to disallow public access.- Specified by:
getDisallowPublicAccess
in classBucketBase
-
setDisallowPublicAccess
Whether to disallow public access.- Specified by:
setDisallowPublicAccess
in classBucketBase
-
getPolicy
The resource policy associated with this bucket.If
autoCreatePolicy
is true, aBucketPolicy
will be created upon the first call to addToResourcePolicy(s).- Specified by:
getPolicy
in interfaceIBucket
- Specified by:
getPolicy
in classBucketBase
-
setPolicy
The resource policy associated with this bucket.If
autoCreatePolicy
is true, aBucketPolicy
will be created upon the first call to addToResourcePolicy(s).- Specified by:
setPolicy
in interfaceIBucket
- Specified by:
setPolicy
in classBucketBase
-