Class CfnBucket

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

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-12-06T14:43:26.389Z") @Stability(Stable) public class CfnBucket extends CfnResource implements IInspectable, ITaggable
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());
 

See Also:
  • 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.constructs.Construct scope, @NotNull String id, @Nullable CfnBucketProps props)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties.
    • CfnBucket

      @Stability(Stable) public CfnBucket(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
  • Method Details

    • inspect

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

      Specified by:
      inspect in interface 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 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 CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getTags in interface ITaggable
    • getAccelerateConfiguration

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

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

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

      @Stability(Stable) @Nullable public String getAccessControl()

      This is a legacy property, and it is not recommended for most use cases.

    • setAccessControl

      @Stability(Stable) public void setAccessControl(@Nullable String value)

      This is a legacy property, and it is not recommended for most use cases.

    • 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 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), AWS KMS-managed keys (SSE-KMS), or dual-layer server-side encryption with KMS-managed keys (DSSE-KMS).
    • setBucketEncryption

      @Stability(Stable) public void setBucketEncryption(@Nullable IResolvable value)
      Specifies default encryption for a bucket using server-side encryption with Amazon S3-managed keys (SSE-S3), AWS KMS-managed keys (SSE-KMS), or dual-layer server-side encryption with KMS-managed keys (DSSE-KMS).
    • 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), AWS KMS-managed keys (SSE-KMS), or dual-layer server-side encryption with KMS-managed keys (DSSE-KMS).
    • getBucketName

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

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

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

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

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

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

      @Stability(Stable) public void setIntelligentTieringConfigurations(@Nullable 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.
    • setInventoryConfigurations

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

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

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

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

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

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

      @Stability(Stable) public void setLoggingConfiguration(@Nullable 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.
    • setMetricsConfigurations

      @Stability(Stable) public void setMetricsConfigurations(@Nullable IResolvable value)
      Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket.
    • 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.
    • getNotificationConfiguration

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

      @Stability(Stable) public void setNotificationConfiguration(@Nullable 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()

      This operation is not supported by directory buckets.

    • setObjectLockConfiguration

      @Stability(Stable) public void setObjectLockConfiguration(@Nullable IResolvable value)

      This operation is not supported by directory buckets.

    • setObjectLockConfiguration

      @Stability(Stable) public void setObjectLockConfiguration(@Nullable CfnBucket.ObjectLockConfigurationProperty value)

      This operation is not supported by directory buckets.

    • getObjectLockEnabled

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

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

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

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

      @Stability(Stable) public void setOwnershipControls(@Nullable 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 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.
    • setReplicationConfiguration

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

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

      @Stability(Stable) @Nullable public List<CfnTag> getTagsRaw()
      An arbitrary set of tags (key-value pairs) for this S3 bucket.
    • setTagsRaw

      @Stability(Stable) public void setTagsRaw(@Nullable List<CfnTag> value)
      An arbitrary set of tags (key-value pairs) for this S3 bucket.
    • getVersioningConfiguration

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

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

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

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

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

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