Class BucketAcl


  • public class BucketAcl
    extends com.pulumi.resources.CustomResource
    Provides an S3 bucket ACL resource. > **Note:** destroy does not delete the S3 Bucket ACL but does remove the resource from state. > This resource cannot be used with S3 directory buckets. ## Example Usage ### With `private` ACL
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.s3.Bucket;
     import com.pulumi.aws.s3.BucketArgs;
     import com.pulumi.aws.s3.BucketOwnershipControls;
     import com.pulumi.aws.s3.BucketOwnershipControlsArgs;
     import com.pulumi.aws.s3.inputs.BucketOwnershipControlsRuleArgs;
     import com.pulumi.aws.s3.BucketAcl;
     import com.pulumi.aws.s3.BucketAclArgs;
     import com.pulumi.resources.CustomResourceOptions;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var example = new Bucket("example", BucketArgs.builder()
                 .bucket("my-tf-example-bucket")
                 .build());
     
             var exampleBucketOwnershipControls = new BucketOwnershipControls("exampleBucketOwnershipControls", BucketOwnershipControlsArgs.builder()
                 .rule(BucketOwnershipControlsRuleArgs.builder()
                     .objectOwnership("BucketOwnerPreferred")
                     .build())
                 .bucket(example.id())
                 .build());
     
             var exampleBucketAcl = new BucketAcl("exampleBucketAcl", BucketAclArgs.builder()
                 .bucket(example.id())
                 .acl("private")
                 .build(), CustomResourceOptions.builder()
                     .dependsOn(exampleBucketOwnershipControls)
                     .build());
     
         }
     }
     
     
    ### With `public-read` ACL > This example explicitly disables the default S3 bucket security settings. This should be done with caution, as all bucket objects become publicly exposed.
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.s3.Bucket;
     import com.pulumi.aws.s3.BucketArgs;
     import com.pulumi.aws.s3.BucketOwnershipControls;
     import com.pulumi.aws.s3.BucketOwnershipControlsArgs;
     import com.pulumi.aws.s3.inputs.BucketOwnershipControlsRuleArgs;
     import com.pulumi.aws.s3.BucketPublicAccessBlock;
     import com.pulumi.aws.s3.BucketPublicAccessBlockArgs;
     import com.pulumi.aws.s3.BucketAcl;
     import com.pulumi.aws.s3.BucketAclArgs;
     import com.pulumi.resources.CustomResourceOptions;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var example = new Bucket("example", BucketArgs.builder()
                 .bucket("my-tf-example-bucket")
                 .build());
     
             var exampleBucketOwnershipControls = new BucketOwnershipControls("exampleBucketOwnershipControls", BucketOwnershipControlsArgs.builder()
                 .rule(BucketOwnershipControlsRuleArgs.builder()
                     .objectOwnership("BucketOwnerPreferred")
                     .build())
                 .bucket(example.id())
                 .build());
     
             var exampleBucketPublicAccessBlock = new BucketPublicAccessBlock("exampleBucketPublicAccessBlock", BucketPublicAccessBlockArgs.builder()
                 .bucket(example.id())
                 .blockPublicAcls(false)
                 .blockPublicPolicy(false)
                 .ignorePublicAcls(false)
                 .restrictPublicBuckets(false)
                 .build());
     
             var exampleBucketAcl = new BucketAcl("exampleBucketAcl", BucketAclArgs.builder()
                 .bucket(example.id())
                 .acl("public-read")
                 .build(), CustomResourceOptions.builder()
                     .dependsOn(                
                         exampleBucketOwnershipControls,
                         exampleBucketPublicAccessBlock)
                     .build());
     
         }
     }
     
     
    ### With Grants
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.s3.S3Functions;
     import com.pulumi.aws.s3.Bucket;
     import com.pulumi.aws.s3.BucketArgs;
     import com.pulumi.aws.s3.BucketOwnershipControls;
     import com.pulumi.aws.s3.BucketOwnershipControlsArgs;
     import com.pulumi.aws.s3.inputs.BucketOwnershipControlsRuleArgs;
     import com.pulumi.aws.s3.BucketAcl;
     import com.pulumi.aws.s3.BucketAclArgs;
     import com.pulumi.aws.s3.inputs.BucketAclAccessControlPolicyArgs;
     import com.pulumi.aws.s3.inputs.BucketAclAccessControlPolicyOwnerArgs;
     import com.pulumi.aws.s3.inputs.BucketAclAccessControlPolicyGrantArgs;
     import com.pulumi.aws.s3.inputs.BucketAclAccessControlPolicyGrantGranteeArgs;
     import com.pulumi.resources.CustomResourceOptions;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             final var current = S3Functions.getCanonicalUserId(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference);
     
             var example = new Bucket("example", BucketArgs.builder()
                 .bucket("my-tf-example-bucket")
                 .build());
     
             var exampleBucketOwnershipControls = new BucketOwnershipControls("exampleBucketOwnershipControls", BucketOwnershipControlsArgs.builder()
                 .rule(BucketOwnershipControlsRuleArgs.builder()
                     .objectOwnership("BucketOwnerPreferred")
                     .build())
                 .bucket(example.id())
                 .build());
     
             var exampleBucketAcl = new BucketAcl("exampleBucketAcl", BucketAclArgs.builder()
                 .accessControlPolicy(BucketAclAccessControlPolicyArgs.builder()
                     .owner(BucketAclAccessControlPolicyOwnerArgs.builder()
                         .id(current.id())
                         .build())
                     .grants(                
                         BucketAclAccessControlPolicyGrantArgs.builder()
                             .grantee(BucketAclAccessControlPolicyGrantGranteeArgs.builder()
                                 .id(current.id())
                                 .type("CanonicalUser")
                                 .build())
                             .permission("READ")
                             .build(),
                         BucketAclAccessControlPolicyGrantArgs.builder()
                             .grantee(BucketAclAccessControlPolicyGrantGranteeArgs.builder()
                                 .type("Group")
                                 .uri("http://acs.amazonaws.com/groups/s3/LogDelivery")
                                 .build())
                             .permission("READ_ACP")
                             .build())
                     .build())
                 .bucket(example.id())
                 .build(), CustomResourceOptions.builder()
                     .dependsOn(exampleBucketOwnershipControls)
                     .build());
     
         }
     }
     
     
    ## Import ### Identity Schema #### Required * `bucket` (String) S3 bucket name. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. If the owner (account ID) of the source bucket is the _same_ account used to configure the AWS Provider, and the source bucket is **configured** with a [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) (i.e. predefined grant), import using the `bucket` and `acl` separated by a comma (`,`): If the owner (account ID) of the source bucket _differs_ from the account used to configure the AWS Provider, and the source bucket is **not configured** with a [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) (i.e. predefined grant), imported using the `bucket` and `expectedBucketOwner` separated by a comma (`,`): If the owner (account ID) of the source bucket _differs_ from the account used to configure the AWS Provider, and the source bucket is **configured** with a [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) (i.e. predefined grant), imported using the `bucket`, `expectedBucketOwner`, and `acl` separated by commas (`,`): **Using `pulumi import` to import** using `bucket`, `expectedBucketOwner`, and/or `acl`, depending on your situation. For example: If the owner (account ID) of the source bucket is the _same_ account used to configure the AWS Provider, and the source bucket is **not configured** with a [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) (i.e. predefined grant), import using the `bucket`: ```sh $ pulumi import aws:s3/bucketAcl:BucketAcl example bucket-name ``` If the owner (account ID) of the source bucket is the _same_ account used to configure the AWS Provider, and the source bucket is **configured** with a [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) (i.e. predefined grant), import using the `bucket` and `acl` separated by a comma (`,`): ```sh $ pulumi import aws:s3/bucketAcl:BucketAcl example bucket-name,private ``` If the owner (account ID) of the source bucket _differs_ from the account used to configure the AWS Provider, and the source bucket is **not configured** with a [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) (i.e. predefined grant), imported using the `bucket` and `expectedBucketOwner` separated by a comma (`,`): ```sh $ pulumi import aws:s3/bucketAcl:BucketAcl example bucket-name,123456789012 ``` If the owner (account ID) of the source bucket _differs_ from the account used to configure the AWS Provider, and the source bucket is **configured** with a [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) (i.e. predefined grant), imported using the `bucket`, `expectedBucketOwner`, and `acl` separated by commas (`,`): ```sh $ pulumi import aws:s3/bucketAcl:BucketAcl example bucket-name,123456789012,private ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      BucketAcl​(java.lang.String name)  
      BucketAcl​(java.lang.String name, BucketAclArgs args)  
      BucketAcl​(java.lang.String name, BucketAclArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<BucketAclAccessControlPolicy> accessControlPolicy()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> acl()  
      com.pulumi.core.Output<java.lang.String> bucket()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> expectedBucketOwner()  
      static BucketAcl get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, BucketAclState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> region()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BucketAcl

        public BucketAcl​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • BucketAcl

        public BucketAcl​(java.lang.String name,
                         BucketAclArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • BucketAcl

        public BucketAcl​(java.lang.String name,
                         BucketAclArgs args,
                         @Nullable
                         com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • accessControlPolicy

        public com.pulumi.core.Output<BucketAclAccessControlPolicy> accessControlPolicy()
        Returns:
        Configuration block that sets the ACL permissions for an object per grantee. See below.
      • acl

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> acl()
        Returns:
        Canned ACL to apply to the bucket. Valid values: `private`, `public-read`, `public-read-write`, `aws-exec-read`, `authenticated-read`, `bucket-owner-read`, `bucket-owner-full-control`, `log-delivery-write`. Full details are available on the [AWS documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl).
      • bucket

        public com.pulumi.core.Output<java.lang.String> bucket()
        Returns:
        Bucket to which to apply the ACL.
      • expectedBucketOwner

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> expectedBucketOwner()
        Returns:
        Account ID of the expected bucket owner.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • get

        public static BucketAcl get​(java.lang.String name,
                                    com.pulumi.core.Output<java.lang.String> id,
                                    @Nullable
                                    BucketAclState state,
                                    @Nullable
                                    com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.