github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/s3/bucketAclV2.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package s3
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides an S3 bucket ACL resource.
    16  //
    17  // > **Note:** destroy does not delete the S3 Bucket ACL but does remove the resource from state.
    18  //
    19  // > This resource cannot be used with S3 directory buckets.
    20  //
    21  // ## Example Usage
    22  //
    23  // ### With `private` ACL
    24  //
    25  // <!--Start PulumiCodeChooser -->
    26  // ```go
    27  // package main
    28  //
    29  // import (
    30  //
    31  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    32  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    33  //
    34  // )
    35  //
    36  //	func main() {
    37  //		pulumi.Run(func(ctx *pulumi.Context) error {
    38  //			example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
    39  //				Bucket: pulumi.String("my-tf-example-bucket"),
    40  //			})
    41  //			if err != nil {
    42  //				return err
    43  //			}
    44  //			exampleBucketOwnershipControls, err := s3.NewBucketOwnershipControls(ctx, "example", &s3.BucketOwnershipControlsArgs{
    45  //				Bucket: example.ID(),
    46  //				Rule: &s3.BucketOwnershipControlsRuleArgs{
    47  //					ObjectOwnership: pulumi.String("BucketOwnerPreferred"),
    48  //				},
    49  //			})
    50  //			if err != nil {
    51  //				return err
    52  //			}
    53  //			_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
    54  //				Bucket: example.ID(),
    55  //				Acl:    pulumi.String("private"),
    56  //			}, pulumi.DependsOn([]pulumi.Resource{
    57  //				exampleBucketOwnershipControls,
    58  //			}))
    59  //			if err != nil {
    60  //				return err
    61  //			}
    62  //			return nil
    63  //		})
    64  //	}
    65  //
    66  // ```
    67  // <!--End PulumiCodeChooser -->
    68  //
    69  // ### With `public-read` ACL
    70  //
    71  // > This example explicitly disables the default S3 bucket security settings. This
    72  // should be done with caution, as all bucket objects become publicly exposed.
    73  //
    74  // <!--Start PulumiCodeChooser -->
    75  // ```go
    76  // package main
    77  //
    78  // import (
    79  //
    80  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    81  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    82  //
    83  // )
    84  //
    85  //	func main() {
    86  //		pulumi.Run(func(ctx *pulumi.Context) error {
    87  //			example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
    88  //				Bucket: pulumi.String("my-tf-example-bucket"),
    89  //			})
    90  //			if err != nil {
    91  //				return err
    92  //			}
    93  //			exampleBucketOwnershipControls, err := s3.NewBucketOwnershipControls(ctx, "example", &s3.BucketOwnershipControlsArgs{
    94  //				Bucket: example.ID(),
    95  //				Rule: &s3.BucketOwnershipControlsRuleArgs{
    96  //					ObjectOwnership: pulumi.String("BucketOwnerPreferred"),
    97  //				},
    98  //			})
    99  //			if err != nil {
   100  //				return err
   101  //			}
   102  //			exampleBucketPublicAccessBlock, err := s3.NewBucketPublicAccessBlock(ctx, "example", &s3.BucketPublicAccessBlockArgs{
   103  //				Bucket:                example.ID(),
   104  //				BlockPublicAcls:       pulumi.Bool(false),
   105  //				BlockPublicPolicy:     pulumi.Bool(false),
   106  //				IgnorePublicAcls:      pulumi.Bool(false),
   107  //				RestrictPublicBuckets: pulumi.Bool(false),
   108  //			})
   109  //			if err != nil {
   110  //				return err
   111  //			}
   112  //			_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
   113  //				Bucket: example.ID(),
   114  //				Acl:    pulumi.String("public-read"),
   115  //			}, pulumi.DependsOn([]pulumi.Resource{
   116  //				exampleBucketOwnershipControls,
   117  //				exampleBucketPublicAccessBlock,
   118  //			}))
   119  //			if err != nil {
   120  //				return err
   121  //			}
   122  //			return nil
   123  //		})
   124  //	}
   125  //
   126  // ```
   127  // <!--End PulumiCodeChooser -->
   128  //
   129  // ### With Grants
   130  //
   131  // <!--Start PulumiCodeChooser -->
   132  // ```go
   133  // package main
   134  //
   135  // import (
   136  //
   137  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
   138  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
   139  //
   140  // )
   141  //
   142  //	func main() {
   143  //		pulumi.Run(func(ctx *pulumi.Context) error {
   144  //			current, err := s3.GetCanonicalUserId(ctx, nil, nil)
   145  //			if err != nil {
   146  //				return err
   147  //			}
   148  //			example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
   149  //				Bucket: pulumi.String("my-tf-example-bucket"),
   150  //			})
   151  //			if err != nil {
   152  //				return err
   153  //			}
   154  //			exampleBucketOwnershipControls, err := s3.NewBucketOwnershipControls(ctx, "example", &s3.BucketOwnershipControlsArgs{
   155  //				Bucket: example.ID(),
   156  //				Rule: &s3.BucketOwnershipControlsRuleArgs{
   157  //					ObjectOwnership: pulumi.String("BucketOwnerPreferred"),
   158  //				},
   159  //			})
   160  //			if err != nil {
   161  //				return err
   162  //			}
   163  //			_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
   164  //				Bucket: example.ID(),
   165  //				AccessControlPolicy: &s3.BucketAclV2AccessControlPolicyArgs{
   166  //					Grants: s3.BucketAclV2AccessControlPolicyGrantArray{
   167  //						&s3.BucketAclV2AccessControlPolicyGrantArgs{
   168  //							Grantee: &s3.BucketAclV2AccessControlPolicyGrantGranteeArgs{
   169  //								Id:   pulumi.String(current.Id),
   170  //								Type: pulumi.String("CanonicalUser"),
   171  //							},
   172  //							Permission: pulumi.String("READ"),
   173  //						},
   174  //						&s3.BucketAclV2AccessControlPolicyGrantArgs{
   175  //							Grantee: &s3.BucketAclV2AccessControlPolicyGrantGranteeArgs{
   176  //								Type: pulumi.String("Group"),
   177  //								Uri:  pulumi.String("http://acs.amazonaws.com/groups/s3/LogDelivery"),
   178  //							},
   179  //							Permission: pulumi.String("READ_ACP"),
   180  //						},
   181  //					},
   182  //					Owner: &s3.BucketAclV2AccessControlPolicyOwnerArgs{
   183  //						Id: pulumi.String(current.Id),
   184  //					},
   185  //				},
   186  //			}, pulumi.DependsOn([]pulumi.Resource{
   187  //				exampleBucketOwnershipControls,
   188  //			}))
   189  //			if err != nil {
   190  //				return err
   191  //			}
   192  //			return nil
   193  //		})
   194  //	}
   195  //
   196  // ```
   197  // <!--End PulumiCodeChooser -->
   198  //
   199  // ## Import
   200  //
   201  // 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
   202  // [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 (`,`):
   203  //
   204  // 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 `expected_bucket_owner` separated by a comma (`,`):
   205  //
   206  // 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
   207  // [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) (i.e. predefined grant), imported using the `bucket`, `expected_bucket_owner`, and `acl` separated by commas (`,`):
   208  //
   209  // __Using `pulumi import` to import__ using `bucket`, `expected_bucket_owner`, and/or `acl`, depending on your situation. For example:
   210  //
   211  // 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
   212  // [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) (i.e. predefined grant), import using the `bucket`:
   213  //
   214  // ```sh
   215  // $ pulumi import aws:s3/bucketAclV2:BucketAclV2 example bucket-name
   216  // ```
   217  // 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 (`,`):
   218  //
   219  // ```sh
   220  // $ pulumi import aws:s3/bucketAclV2:BucketAclV2 example bucket-name,private
   221  // ```
   222  // 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 `expected_bucket_owner` separated by a comma (`,`):
   223  //
   224  // ```sh
   225  // $ pulumi import aws:s3/bucketAclV2:BucketAclV2 example bucket-name,123456789012
   226  // ```
   227  // 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`, `expected_bucket_owner`, and `acl` separated by commas (`,`):
   228  //
   229  // ```sh
   230  // $ pulumi import aws:s3/bucketAclV2:BucketAclV2 example bucket-name,123456789012,private
   231  // ```
   232  type BucketAclV2 struct {
   233  	pulumi.CustomResourceState
   234  
   235  	// Configuration block that sets the ACL permissions for an object per grantee. See below.
   236  	AccessControlPolicy BucketAclV2AccessControlPolicyOutput `pulumi:"accessControlPolicy"`
   237  	// Canned ACL to apply to the bucket.
   238  	Acl pulumi.StringPtrOutput `pulumi:"acl"`
   239  	// Bucket to which to apply the ACL.
   240  	Bucket pulumi.StringOutput `pulumi:"bucket"`
   241  	// Account ID of the expected bucket owner.
   242  	ExpectedBucketOwner pulumi.StringPtrOutput `pulumi:"expectedBucketOwner"`
   243  }
   244  
   245  // NewBucketAclV2 registers a new resource with the given unique name, arguments, and options.
   246  func NewBucketAclV2(ctx *pulumi.Context,
   247  	name string, args *BucketAclV2Args, opts ...pulumi.ResourceOption) (*BucketAclV2, error) {
   248  	if args == nil {
   249  		return nil, errors.New("missing one or more required arguments")
   250  	}
   251  
   252  	if args.Bucket == nil {
   253  		return nil, errors.New("invalid value for required argument 'Bucket'")
   254  	}
   255  	opts = internal.PkgResourceDefaultOpts(opts)
   256  	var resource BucketAclV2
   257  	err := ctx.RegisterResource("aws:s3/bucketAclV2:BucketAclV2", name, args, &resource, opts...)
   258  	if err != nil {
   259  		return nil, err
   260  	}
   261  	return &resource, nil
   262  }
   263  
   264  // GetBucketAclV2 gets an existing BucketAclV2 resource's state with the given name, ID, and optional
   265  // state properties that are used to uniquely qualify the lookup (nil if not required).
   266  func GetBucketAclV2(ctx *pulumi.Context,
   267  	name string, id pulumi.IDInput, state *BucketAclV2State, opts ...pulumi.ResourceOption) (*BucketAclV2, error) {
   268  	var resource BucketAclV2
   269  	err := ctx.ReadResource("aws:s3/bucketAclV2:BucketAclV2", name, id, state, &resource, opts...)
   270  	if err != nil {
   271  		return nil, err
   272  	}
   273  	return &resource, nil
   274  }
   275  
   276  // Input properties used for looking up and filtering BucketAclV2 resources.
   277  type bucketAclV2State struct {
   278  	// Configuration block that sets the ACL permissions for an object per grantee. See below.
   279  	AccessControlPolicy *BucketAclV2AccessControlPolicy `pulumi:"accessControlPolicy"`
   280  	// Canned ACL to apply to the bucket.
   281  	Acl *string `pulumi:"acl"`
   282  	// Bucket to which to apply the ACL.
   283  	Bucket *string `pulumi:"bucket"`
   284  	// Account ID of the expected bucket owner.
   285  	ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"`
   286  }
   287  
   288  type BucketAclV2State struct {
   289  	// Configuration block that sets the ACL permissions for an object per grantee. See below.
   290  	AccessControlPolicy BucketAclV2AccessControlPolicyPtrInput
   291  	// Canned ACL to apply to the bucket.
   292  	Acl pulumi.StringPtrInput
   293  	// Bucket to which to apply the ACL.
   294  	Bucket pulumi.StringPtrInput
   295  	// Account ID of the expected bucket owner.
   296  	ExpectedBucketOwner pulumi.StringPtrInput
   297  }
   298  
   299  func (BucketAclV2State) ElementType() reflect.Type {
   300  	return reflect.TypeOf((*bucketAclV2State)(nil)).Elem()
   301  }
   302  
   303  type bucketAclV2Args struct {
   304  	// Configuration block that sets the ACL permissions for an object per grantee. See below.
   305  	AccessControlPolicy *BucketAclV2AccessControlPolicy `pulumi:"accessControlPolicy"`
   306  	// Canned ACL to apply to the bucket.
   307  	Acl *string `pulumi:"acl"`
   308  	// Bucket to which to apply the ACL.
   309  	Bucket string `pulumi:"bucket"`
   310  	// Account ID of the expected bucket owner.
   311  	ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"`
   312  }
   313  
   314  // The set of arguments for constructing a BucketAclV2 resource.
   315  type BucketAclV2Args struct {
   316  	// Configuration block that sets the ACL permissions for an object per grantee. See below.
   317  	AccessControlPolicy BucketAclV2AccessControlPolicyPtrInput
   318  	// Canned ACL to apply to the bucket.
   319  	Acl pulumi.StringPtrInput
   320  	// Bucket to which to apply the ACL.
   321  	Bucket pulumi.StringInput
   322  	// Account ID of the expected bucket owner.
   323  	ExpectedBucketOwner pulumi.StringPtrInput
   324  }
   325  
   326  func (BucketAclV2Args) ElementType() reflect.Type {
   327  	return reflect.TypeOf((*bucketAclV2Args)(nil)).Elem()
   328  }
   329  
   330  type BucketAclV2Input interface {
   331  	pulumi.Input
   332  
   333  	ToBucketAclV2Output() BucketAclV2Output
   334  	ToBucketAclV2OutputWithContext(ctx context.Context) BucketAclV2Output
   335  }
   336  
   337  func (*BucketAclV2) ElementType() reflect.Type {
   338  	return reflect.TypeOf((**BucketAclV2)(nil)).Elem()
   339  }
   340  
   341  func (i *BucketAclV2) ToBucketAclV2Output() BucketAclV2Output {
   342  	return i.ToBucketAclV2OutputWithContext(context.Background())
   343  }
   344  
   345  func (i *BucketAclV2) ToBucketAclV2OutputWithContext(ctx context.Context) BucketAclV2Output {
   346  	return pulumi.ToOutputWithContext(ctx, i).(BucketAclV2Output)
   347  }
   348  
   349  // BucketAclV2ArrayInput is an input type that accepts BucketAclV2Array and BucketAclV2ArrayOutput values.
   350  // You can construct a concrete instance of `BucketAclV2ArrayInput` via:
   351  //
   352  //	BucketAclV2Array{ BucketAclV2Args{...} }
   353  type BucketAclV2ArrayInput interface {
   354  	pulumi.Input
   355  
   356  	ToBucketAclV2ArrayOutput() BucketAclV2ArrayOutput
   357  	ToBucketAclV2ArrayOutputWithContext(context.Context) BucketAclV2ArrayOutput
   358  }
   359  
   360  type BucketAclV2Array []BucketAclV2Input
   361  
   362  func (BucketAclV2Array) ElementType() reflect.Type {
   363  	return reflect.TypeOf((*[]*BucketAclV2)(nil)).Elem()
   364  }
   365  
   366  func (i BucketAclV2Array) ToBucketAclV2ArrayOutput() BucketAclV2ArrayOutput {
   367  	return i.ToBucketAclV2ArrayOutputWithContext(context.Background())
   368  }
   369  
   370  func (i BucketAclV2Array) ToBucketAclV2ArrayOutputWithContext(ctx context.Context) BucketAclV2ArrayOutput {
   371  	return pulumi.ToOutputWithContext(ctx, i).(BucketAclV2ArrayOutput)
   372  }
   373  
   374  // BucketAclV2MapInput is an input type that accepts BucketAclV2Map and BucketAclV2MapOutput values.
   375  // You can construct a concrete instance of `BucketAclV2MapInput` via:
   376  //
   377  //	BucketAclV2Map{ "key": BucketAclV2Args{...} }
   378  type BucketAclV2MapInput interface {
   379  	pulumi.Input
   380  
   381  	ToBucketAclV2MapOutput() BucketAclV2MapOutput
   382  	ToBucketAclV2MapOutputWithContext(context.Context) BucketAclV2MapOutput
   383  }
   384  
   385  type BucketAclV2Map map[string]BucketAclV2Input
   386  
   387  func (BucketAclV2Map) ElementType() reflect.Type {
   388  	return reflect.TypeOf((*map[string]*BucketAclV2)(nil)).Elem()
   389  }
   390  
   391  func (i BucketAclV2Map) ToBucketAclV2MapOutput() BucketAclV2MapOutput {
   392  	return i.ToBucketAclV2MapOutputWithContext(context.Background())
   393  }
   394  
   395  func (i BucketAclV2Map) ToBucketAclV2MapOutputWithContext(ctx context.Context) BucketAclV2MapOutput {
   396  	return pulumi.ToOutputWithContext(ctx, i).(BucketAclV2MapOutput)
   397  }
   398  
   399  type BucketAclV2Output struct{ *pulumi.OutputState }
   400  
   401  func (BucketAclV2Output) ElementType() reflect.Type {
   402  	return reflect.TypeOf((**BucketAclV2)(nil)).Elem()
   403  }
   404  
   405  func (o BucketAclV2Output) ToBucketAclV2Output() BucketAclV2Output {
   406  	return o
   407  }
   408  
   409  func (o BucketAclV2Output) ToBucketAclV2OutputWithContext(ctx context.Context) BucketAclV2Output {
   410  	return o
   411  }
   412  
   413  // Configuration block that sets the ACL permissions for an object per grantee. See below.
   414  func (o BucketAclV2Output) AccessControlPolicy() BucketAclV2AccessControlPolicyOutput {
   415  	return o.ApplyT(func(v *BucketAclV2) BucketAclV2AccessControlPolicyOutput { return v.AccessControlPolicy }).(BucketAclV2AccessControlPolicyOutput)
   416  }
   417  
   418  // Canned ACL to apply to the bucket.
   419  func (o BucketAclV2Output) Acl() pulumi.StringPtrOutput {
   420  	return o.ApplyT(func(v *BucketAclV2) pulumi.StringPtrOutput { return v.Acl }).(pulumi.StringPtrOutput)
   421  }
   422  
   423  // Bucket to which to apply the ACL.
   424  func (o BucketAclV2Output) Bucket() pulumi.StringOutput {
   425  	return o.ApplyT(func(v *BucketAclV2) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput)
   426  }
   427  
   428  // Account ID of the expected bucket owner.
   429  func (o BucketAclV2Output) ExpectedBucketOwner() pulumi.StringPtrOutput {
   430  	return o.ApplyT(func(v *BucketAclV2) pulumi.StringPtrOutput { return v.ExpectedBucketOwner }).(pulumi.StringPtrOutput)
   431  }
   432  
   433  type BucketAclV2ArrayOutput struct{ *pulumi.OutputState }
   434  
   435  func (BucketAclV2ArrayOutput) ElementType() reflect.Type {
   436  	return reflect.TypeOf((*[]*BucketAclV2)(nil)).Elem()
   437  }
   438  
   439  func (o BucketAclV2ArrayOutput) ToBucketAclV2ArrayOutput() BucketAclV2ArrayOutput {
   440  	return o
   441  }
   442  
   443  func (o BucketAclV2ArrayOutput) ToBucketAclV2ArrayOutputWithContext(ctx context.Context) BucketAclV2ArrayOutput {
   444  	return o
   445  }
   446  
   447  func (o BucketAclV2ArrayOutput) Index(i pulumi.IntInput) BucketAclV2Output {
   448  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BucketAclV2 {
   449  		return vs[0].([]*BucketAclV2)[vs[1].(int)]
   450  	}).(BucketAclV2Output)
   451  }
   452  
   453  type BucketAclV2MapOutput struct{ *pulumi.OutputState }
   454  
   455  func (BucketAclV2MapOutput) ElementType() reflect.Type {
   456  	return reflect.TypeOf((*map[string]*BucketAclV2)(nil)).Elem()
   457  }
   458  
   459  func (o BucketAclV2MapOutput) ToBucketAclV2MapOutput() BucketAclV2MapOutput {
   460  	return o
   461  }
   462  
   463  func (o BucketAclV2MapOutput) ToBucketAclV2MapOutputWithContext(ctx context.Context) BucketAclV2MapOutput {
   464  	return o
   465  }
   466  
   467  func (o BucketAclV2MapOutput) MapIndex(k pulumi.StringInput) BucketAclV2Output {
   468  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BucketAclV2 {
   469  		return vs[0].(map[string]*BucketAclV2)[vs[1].(string)]
   470  	}).(BucketAclV2Output)
   471  }
   472  
   473  func init() {
   474  	pulumi.RegisterInputType(reflect.TypeOf((*BucketAclV2Input)(nil)).Elem(), &BucketAclV2{})
   475  	pulumi.RegisterInputType(reflect.TypeOf((*BucketAclV2ArrayInput)(nil)).Elem(), BucketAclV2Array{})
   476  	pulumi.RegisterInputType(reflect.TypeOf((*BucketAclV2MapInput)(nil)).Elem(), BucketAclV2Map{})
   477  	pulumi.RegisterOutputType(BucketAclV2Output{})
   478  	pulumi.RegisterOutputType(BucketAclV2ArrayOutput{})
   479  	pulumi.RegisterOutputType(BucketAclV2MapOutput{})
   480  }