Class BucketPolicy

All Implemented Interfaces:
IConstruct, IDependable, IResource,, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:37.500Z") @Stability(Stable) public class BucketPolicy extends Resource
The bucket policy for an Amazon S3 bucket.

Policies define the operations that are allowed on this resource.

You almost never need to define this construct directly.

All AWS resources that support resource policies have a method called addToResourcePolicy(), which will automatically create a new resource policy if one doesn't exist yet, otherwise it will add to the existing policy.

Prefer to use addToResourcePolicy() instead.


 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 Bucket bucket;
 BucketPolicy bucketPolicy = BucketPolicy.Builder.create(this, "MyBucketPolicy")
         // the properties below are optional
  • Constructor Details

    • BucketPolicy

      protected BucketPolicy( objRef)
    • BucketPolicy

      protected BucketPolicy( initializationMode)
    • BucketPolicy

      @Stability(Stable) public BucketPolicy(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull BucketPolicyProps props)
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • applyRemovalPolicy

      @Stability(Stable) public void applyRemovalPolicy(@NotNull RemovalPolicy removalPolicy)
      Sets the removal policy for the BucketPolicy.

      Specified by:
      applyRemovalPolicy in interface IResource
      applyRemovalPolicy in class Resource
      removalPolicy - the RemovalPolicy to set. This parameter is required.
    • getDocument

      @Stability(Stable) @NotNull public PolicyDocument getDocument()
      A policy document containing permissions to add to the specified bucket.

      For more information, see Access Policy Language Overview in the Amazon Simple Storage Service Developer Guide.