Class CfnBucket

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.CfnElement
software.amazon.awscdk.core.CfnRefElement
software.amazon.awscdk.core.CfnResource
software.amazon.awscdk.services.s3.CfnBucket
All Implemented Interfaces:
software.amazon.awscdk.core.IConstruct, software.amazon.awscdk.core.IDependable, software.amazon.awscdk.core.IInspectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-05-31T18:44:09.203Z") @Stability(Stable) public class CfnBucket extends software.amazon.awscdk.core.CfnResource implements software.amazon.awscdk.core.IInspectable
A CloudFormation `AWS::S3::Bucket`.

The AWS::S3::Bucket resource creates an Amazon S3 bucket in the same AWS Region where you create the AWS CloudFormation stack.

To control how AWS CloudFormation handles the bucket when the stack is deleted, you can set a deletion policy for your bucket. You can choose to retain the bucket or to delete the bucket. For more information, see DeletionPolicy Attribute .

You can only delete empty buckets. Deletion fails for buckets that have contents.

Example:

 CfnInclude cfnTemplate;
 CfnBucket cfnBucket = (CfnBucket)cfnTemplate.getResource("Bucket");
 Role role = Role.Builder.create(this, "Role")
         .assumedBy(new AnyPrincipal())
         .build();
 role.addToPolicy(PolicyStatement.Builder.create()
         .actions(List.of("s3:*"))
         .resources(List.of(cfnBucket.getAttrArn()))
         .build());
 
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnBucket

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

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

      @Stability(Stable) public CfnBucket(@NotNull software.amazon.awscdk.core.Construct scope, @NotNull String id, @Nullable CfnBucketProps props)
      Create a new `AWS::S3::Bucket`.

      Parameters:
      scope - - scope in which this resource is defined. This parameter is required.
      id - - scoped id of the resource. This parameter is required.
      props - - resource properties.
    • CfnBucket

      @Stability(Stable) public CfnBucket(@NotNull software.amazon.awscdk.core.Construct scope, @NotNull String id)
      Create a new `AWS::S3::Bucket`.

      Parameters:
      scope - - scope in which this resource is defined. This parameter is required.
      id - - scoped id of the resource. This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull software.amazon.awscdk.core.TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface software.amazon.awscdk.core.IInspectable
      Parameters:
      inspector - - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class software.amazon.awscdk.core.CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrArn

      @Stability(Stable) @NotNull public String getAttrArn()
      Returns the Amazon Resource Name (ARN) of the specified bucket.

      Example: arn:aws:s3:::DOC-EXAMPLE-BUCKET

    • getAttrDomainName

      @Stability(Stable) @NotNull public String getAttrDomainName()
      Returns the IPv4 DNS name of the specified bucket.

      Example: DOC-EXAMPLE-BUCKET.s3.amazonaws.com

    • getAttrDualStackDomainName

      @Stability(Stable) @NotNull public String getAttrDualStackDomainName()
      Returns the IPv6 DNS name of the specified bucket.

      Example: DOC-EXAMPLE-BUCKET.s3.dualstack.us-east-2.amazonaws.com

      For more information about dual-stack endpoints, see Using Amazon S3 Dual-Stack Endpoints .

    • getAttrRegionalDomainName

      @Stability(Stable) @NotNull public String getAttrRegionalDomainName()
      Returns the regional domain name of the specified bucket.

      Example: DOC-EXAMPLE-BUCKET.s3.us-east-2.amazonaws.com

    • getAttrWebsiteUrl

      @Stability(Stable) @NotNull public String getAttrWebsiteUrl()
      Returns the Amazon S3 website endpoint for the specified bucket.

      Example (IPv4): http://DOC-EXAMPLE-BUCKET.s3-website.us-east-2.amazonaws.com

      Example (IPv6): http://DOC-EXAMPLE-BUCKET.s3.dualstack.us-east-2.amazonaws.com

    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class software.amazon.awscdk.core.CfnResource
    • getTags

      @Stability(Stable) @NotNull public software.amazon.awscdk.core.TagManager getTags()
      An arbitrary set of tags (key-value pairs) for this S3 bucket.
    • getAccelerateConfiguration

      @Stability(Stable) @Nullable public Object getAccelerateConfiguration()
      Configures the transfer acceleration state for an Amazon S3 bucket.

      For more information, see Amazon S3 Transfer Acceleration in the Amazon S3 User Guide .

    • setAccelerateConfiguration

      @Stability(Stable) public void setAccelerateConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Configures the transfer acceleration state for an Amazon S3 bucket.

      For more information, see Amazon S3 Transfer Acceleration in the Amazon S3 User Guide .

    • setAccelerateConfiguration

      @Stability(Stable) public void setAccelerateConfiguration(@Nullable CfnBucket.AccelerateConfigurationProperty value)
      Configures the transfer acceleration state for an Amazon S3 bucket.

      For more information, see Amazon S3 Transfer Acceleration in the Amazon S3 User Guide .

    • getAccessControl

      @Stability(Stable) @Nullable public String getAccessControl()
      A canned access control list (ACL) that grants predefined permissions to the bucket.

      For more information about canned ACLs, see Canned ACL in the Amazon S3 User Guide .

      Be aware that the syntax for this property differs from the information provided in the Amazon S3 User Guide . The AccessControl property is case-sensitive and must be one of the following values: Private, PublicRead, PublicReadWrite, AuthenticatedRead, LogDeliveryWrite, BucketOwnerRead, BucketOwnerFullControl, or AwsExecRead.

    • setAccessControl

      @Stability(Stable) public void setAccessControl(@Nullable String value)
      A canned access control list (ACL) that grants predefined permissions to the bucket.

      For more information about canned ACLs, see Canned ACL in the Amazon S3 User Guide .

      Be aware that the syntax for this property differs from the information provided in the Amazon S3 User Guide . The AccessControl property is case-sensitive and must be one of the following values: Private, PublicRead, PublicReadWrite, AuthenticatedRead, LogDeliveryWrite, BucketOwnerRead, BucketOwnerFullControl, or AwsExecRead.

    • getAnalyticsConfigurations

      @Stability(Stable) @Nullable public Object getAnalyticsConfigurations()
      Specifies the configuration and any analyses for the analytics filter of an Amazon S3 bucket.
    • setAnalyticsConfigurations

      @Stability(Stable) public void setAnalyticsConfigurations(@Nullable software.amazon.awscdk.core.IResolvable value)
      Specifies the configuration and any analyses for the analytics filter of an Amazon S3 bucket.
    • setAnalyticsConfigurations

      @Stability(Stable) public void setAnalyticsConfigurations(@Nullable List<Object> value)
      Specifies the configuration and any analyses for the analytics filter of an Amazon S3 bucket.
    • getBucketEncryption

      @Stability(Stable) @Nullable public Object getBucketEncryption()
      Specifies default encryption for a bucket using server-side encryption with Amazon S3-managed keys (SSE-S3) or AWS KMS-managed keys (SSE-KMS) bucket.

      For information about the Amazon S3 default encryption feature, see Amazon S3 Default Encryption for S3 Buckets in the Amazon S3 User Guide .

    • setBucketEncryption

      @Stability(Stable) public void setBucketEncryption(@Nullable software.amazon.awscdk.core.IResolvable value)
      Specifies default encryption for a bucket using server-side encryption with Amazon S3-managed keys (SSE-S3) or AWS KMS-managed keys (SSE-KMS) bucket.

      For information about the Amazon S3 default encryption feature, see Amazon S3 Default Encryption for S3 Buckets in the Amazon S3 User Guide .

    • setBucketEncryption

      @Stability(Stable) public void setBucketEncryption(@Nullable CfnBucket.BucketEncryptionProperty value)
      Specifies default encryption for a bucket using server-side encryption with Amazon S3-managed keys (SSE-S3) or AWS KMS-managed keys (SSE-KMS) bucket.

      For information about the Amazon S3 default encryption feature, see Amazon S3 Default Encryption for S3 Buckets in the Amazon S3 User Guide .

    • getBucketName

      @Stability(Stable) @Nullable public String getBucketName()
      A name for the bucket.

      If you don't specify a name, AWS CloudFormation generates a unique ID and uses that ID for the bucket name. The bucket name must contain only lowercase letters, numbers, periods (.), and dashes (-) and must follow Amazon S3 bucket restrictions and limitations . For more information, see Rules for naming Amazon S3 buckets in the Amazon S3 User Guide .

      If you specify a name, you can't perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you need to replace the resource, specify a new name.

    • setBucketName

      @Stability(Stable) public void setBucketName(@Nullable String value)
      A name for the bucket.

      If you don't specify a name, AWS CloudFormation generates a unique ID and uses that ID for the bucket name. The bucket name must contain only lowercase letters, numbers, periods (.), and dashes (-) and must follow Amazon S3 bucket restrictions and limitations . For more information, see Rules for naming Amazon S3 buckets in the Amazon S3 User Guide .

      If you specify a name, you can't perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you need to replace the resource, specify a new name.

    • getCorsConfiguration

      @Stability(Stable) @Nullable public Object getCorsConfiguration()
      Describes the cross-origin access configuration for objects in an Amazon S3 bucket.

      For more information, see Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide .

    • setCorsConfiguration

      @Stability(Stable) public void setCorsConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Describes the cross-origin access configuration for objects in an Amazon S3 bucket.

      For more information, see Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide .

    • setCorsConfiguration

      @Stability(Stable) public void setCorsConfiguration(@Nullable CfnBucket.CorsConfigurationProperty value)
      Describes the cross-origin access configuration for objects in an Amazon S3 bucket.

      For more information, see Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide .

    • getIntelligentTieringConfigurations

      @Stability(Stable) @Nullable public Object getIntelligentTieringConfigurations()
      Defines how Amazon S3 handles Intelligent-Tiering storage.
    • setIntelligentTieringConfigurations

      @Stability(Stable) public void setIntelligentTieringConfigurations(@Nullable software.amazon.awscdk.core.IResolvable value)
      Defines how Amazon S3 handles Intelligent-Tiering storage.
    • setIntelligentTieringConfigurations

      @Stability(Stable) public void setIntelligentTieringConfigurations(@Nullable List<Object> value)
      Defines how Amazon S3 handles Intelligent-Tiering storage.
    • getInventoryConfigurations

      @Stability(Stable) @Nullable public Object getInventoryConfigurations()
      Specifies the inventory configuration for an Amazon S3 bucket.

      For more information, see GET Bucket inventory in the Amazon S3 API Reference .

    • setInventoryConfigurations

      @Stability(Stable) public void setInventoryConfigurations(@Nullable software.amazon.awscdk.core.IResolvable value)
      Specifies the inventory configuration for an Amazon S3 bucket.

      For more information, see GET Bucket inventory in the Amazon S3 API Reference .

    • setInventoryConfigurations

      @Stability(Stable) public void setInventoryConfigurations(@Nullable List<Object> value)
      Specifies the inventory configuration for an Amazon S3 bucket.

      For more information, see GET Bucket inventory in the Amazon S3 API Reference .

    • getLifecycleConfiguration

      @Stability(Stable) @Nullable public Object getLifecycleConfiguration()
      Specifies the lifecycle configuration for objects in an Amazon S3 bucket.

      For more information, see Object Lifecycle Management in the Amazon S3 User Guide .

    • setLifecycleConfiguration

      @Stability(Stable) public void setLifecycleConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Specifies the lifecycle configuration for objects in an Amazon S3 bucket.

      For more information, see Object Lifecycle Management in the Amazon S3 User Guide .

    • setLifecycleConfiguration

      @Stability(Stable) public void setLifecycleConfiguration(@Nullable CfnBucket.LifecycleConfigurationProperty value)
      Specifies the lifecycle configuration for objects in an Amazon S3 bucket.

      For more information, see Object Lifecycle Management in the Amazon S3 User Guide .

    • getLoggingConfiguration

      @Stability(Stable) @Nullable public Object getLoggingConfiguration()
      Settings that define where logs are stored.
    • setLoggingConfiguration

      @Stability(Stable) public void setLoggingConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Settings that define where logs are stored.
    • setLoggingConfiguration

      @Stability(Stable) public void setLoggingConfiguration(@Nullable CfnBucket.LoggingConfigurationProperty value)
      Settings that define where logs are stored.
    • getMetricsConfigurations

      @Stability(Stable) @Nullable public Object getMetricsConfigurations()
      Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket.

      If you're updating an existing metrics configuration, note that this is a full replacement of the existing metrics configuration. If you don't include the elements you want to keep, they are erased. For more information, see PutBucketMetricsConfiguration .

    • setMetricsConfigurations

      @Stability(Stable) public void setMetricsConfigurations(@Nullable software.amazon.awscdk.core.IResolvable value)
      Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket.

      If you're updating an existing metrics configuration, note that this is a full replacement of the existing metrics configuration. If you don't include the elements you want to keep, they are erased. For more information, see PutBucketMetricsConfiguration .

    • setMetricsConfigurations

      @Stability(Stable) public void setMetricsConfigurations(@Nullable List<Object> value)
      Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket.

      If you're updating an existing metrics configuration, note that this is a full replacement of the existing metrics configuration. If you don't include the elements you want to keep, they are erased. For more information, see PutBucketMetricsConfiguration .

    • getNotificationConfiguration

      @Stability(Stable) @Nullable public Object getNotificationConfiguration()
      Configuration that defines how Amazon S3 handles bucket notifications.
    • setNotificationConfiguration

      @Stability(Stable) public void setNotificationConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Configuration that defines how Amazon S3 handles bucket notifications.
    • setNotificationConfiguration

      @Stability(Stable) public void setNotificationConfiguration(@Nullable CfnBucket.NotificationConfigurationProperty value)
      Configuration that defines how Amazon S3 handles bucket notifications.
    • getObjectLockConfiguration

      @Stability(Stable) @Nullable public Object getObjectLockConfiguration()
      Places an Object Lock configuration on the specified bucket.

      The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket. For more information, see Locking Objects .

      • The DefaultRetention settings require both a mode and a period.
      • The DefaultRetention period can be either Days or Years but you must select one. You cannot specify Days and Years at the same time.
      • You can only enable Object Lock for new buckets. If you want to turn on Object Lock for an existing bucket, contact AWS Support.

    • setObjectLockConfiguration

      @Stability(Stable) public void setObjectLockConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Places an Object Lock configuration on the specified bucket.

      The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket. For more information, see Locking Objects .

      • The DefaultRetention settings require both a mode and a period.
      • The DefaultRetention period can be either Days or Years but you must select one. You cannot specify Days and Years at the same time.
      • You can only enable Object Lock for new buckets. If you want to turn on Object Lock for an existing bucket, contact AWS Support.

    • setObjectLockConfiguration

      @Stability(Stable) public void setObjectLockConfiguration(@Nullable CfnBucket.ObjectLockConfigurationProperty value)
      Places an Object Lock configuration on the specified bucket.

      The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket. For more information, see Locking Objects .

      • The DefaultRetention settings require both a mode and a period.
      • The DefaultRetention period can be either Days or Years but you must select one. You cannot specify Days and Years at the same time.
      • You can only enable Object Lock for new buckets. If you want to turn on Object Lock for an existing bucket, contact AWS Support.

    • getObjectLockEnabled

      @Stability(Stable) @Nullable public Object getObjectLockEnabled()
      Indicates whether this bucket has an Object Lock configuration enabled.

      Enable ObjectLockEnabled when you apply ObjectLockConfiguration to a bucket.

    • setObjectLockEnabled

      @Stability(Stable) public void setObjectLockEnabled(@Nullable Boolean value)
      Indicates whether this bucket has an Object Lock configuration enabled.

      Enable ObjectLockEnabled when you apply ObjectLockConfiguration to a bucket.

    • setObjectLockEnabled

      @Stability(Stable) public void setObjectLockEnabled(@Nullable software.amazon.awscdk.core.IResolvable value)
      Indicates whether this bucket has an Object Lock configuration enabled.

      Enable ObjectLockEnabled when you apply ObjectLockConfiguration to a bucket.

    • getOwnershipControls

      @Stability(Stable) @Nullable public Object getOwnershipControls()
      Configuration that defines how Amazon S3 handles Object Ownership rules.
    • setOwnershipControls

      @Stability(Stable) public void setOwnershipControls(@Nullable software.amazon.awscdk.core.IResolvable value)
      Configuration that defines how Amazon S3 handles Object Ownership rules.
    • setOwnershipControls

      @Stability(Stable) public void setOwnershipControls(@Nullable CfnBucket.OwnershipControlsProperty value)
      Configuration that defines how Amazon S3 handles Object Ownership rules.
    • getPublicAccessBlockConfiguration

      @Stability(Stable) @Nullable public Object getPublicAccessBlockConfiguration()
      Configuration that defines how Amazon S3 handles public access.
    • setPublicAccessBlockConfiguration

      @Stability(Stable) public void setPublicAccessBlockConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Configuration that defines how Amazon S3 handles public access.
    • setPublicAccessBlockConfiguration

      @Stability(Stable) public void setPublicAccessBlockConfiguration(@Nullable CfnBucket.PublicAccessBlockConfigurationProperty value)
      Configuration that defines how Amazon S3 handles public access.
    • getReplicationConfiguration

      @Stability(Stable) @Nullable public Object getReplicationConfiguration()
      Configuration for replicating objects in an S3 bucket.

      To enable replication, you must also enable versioning by using the VersioningConfiguration property.

      Amazon S3 can store replicated objects in a single destination bucket or multiple destination buckets. The destination bucket or buckets must already exist.

    • setReplicationConfiguration

      @Stability(Stable) public void setReplicationConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Configuration for replicating objects in an S3 bucket.

      To enable replication, you must also enable versioning by using the VersioningConfiguration property.

      Amazon S3 can store replicated objects in a single destination bucket or multiple destination buckets. The destination bucket or buckets must already exist.

    • setReplicationConfiguration

      @Stability(Stable) public void setReplicationConfiguration(@Nullable CfnBucket.ReplicationConfigurationProperty value)
      Configuration for replicating objects in an S3 bucket.

      To enable replication, you must also enable versioning by using the VersioningConfiguration property.

      Amazon S3 can store replicated objects in a single destination bucket or multiple destination buckets. The destination bucket or buckets must already exist.

    • getVersioningConfiguration

      @Stability(Stable) @Nullable public Object getVersioningConfiguration()
      Enables multiple versions of all objects in this bucket.

      You might enable versioning to prevent objects from being deleted or overwritten by mistake or to archive objects so that you can retrieve previous versions of them.

    • setVersioningConfiguration

      @Stability(Stable) public void setVersioningConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Enables multiple versions of all objects in this bucket.

      You might enable versioning to prevent objects from being deleted or overwritten by mistake or to archive objects so that you can retrieve previous versions of them.

    • setVersioningConfiguration

      @Stability(Stable) public void setVersioningConfiguration(@Nullable CfnBucket.VersioningConfigurationProperty value)
      Enables multiple versions of all objects in this bucket.

      You might enable versioning to prevent objects from being deleted or overwritten by mistake or to archive objects so that you can retrieve previous versions of them.

    • getWebsiteConfiguration

      @Stability(Stable) @Nullable public Object getWebsiteConfiguration()
      Information used to configure the bucket as a static website.

      For more information, see Hosting Websites on Amazon S3 .

    • setWebsiteConfiguration

      @Stability(Stable) public void setWebsiteConfiguration(@Nullable software.amazon.awscdk.core.IResolvable value)
      Information used to configure the bucket as a static website.

      For more information, see Hosting Websites on Amazon S3 .

    • setWebsiteConfiguration

      @Stability(Stable) public void setWebsiteConfiguration(@Nullable CfnBucket.WebsiteConfigurationProperty value)
      Information used to configure the bucket as a static website.

      For more information, see Hosting Websites on Amazon S3 .