github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/s3/bucketCorsConfigurationV2.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 CORS configuration resource. For more information about CORS, go to [Enabling Cross-Origin Resource Sharing](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cors.html) in the Amazon S3 User Guide.
    16  //
    17  // > **NOTE:** S3 Buckets only support a single CORS configuration. Declaring multiple `s3.BucketCorsConfigurationV2` resources to the same S3 Bucket will cause a perpetual difference in configuration.
    18  //
    19  // > This resource cannot be used with S3 directory buckets.
    20  //
    21  // ## Example Usage
    22  //
    23  // <!--Start PulumiCodeChooser -->
    24  // ```go
    25  // package main
    26  //
    27  // import (
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
    37  //				Bucket: pulumi.String("mybucket"),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			_, err = s3.NewBucketCorsConfigurationV2(ctx, "example", &s3.BucketCorsConfigurationV2Args{
    43  //				Bucket: example.ID(),
    44  //				CorsRules: s3.BucketCorsConfigurationV2CorsRuleArray{
    45  //					&s3.BucketCorsConfigurationV2CorsRuleArgs{
    46  //						AllowedHeaders: pulumi.StringArray{
    47  //							pulumi.String("*"),
    48  //						},
    49  //						AllowedMethods: pulumi.StringArray{
    50  //							pulumi.String("PUT"),
    51  //							pulumi.String("POST"),
    52  //						},
    53  //						AllowedOrigins: pulumi.StringArray{
    54  //							pulumi.String("https://s3-website-test.domain.example"),
    55  //						},
    56  //						ExposeHeaders: pulumi.StringArray{
    57  //							pulumi.String("ETag"),
    58  //						},
    59  //						MaxAgeSeconds: pulumi.Int(3000),
    60  //					},
    61  //					&s3.BucketCorsConfigurationV2CorsRuleArgs{
    62  //						AllowedMethods: pulumi.StringArray{
    63  //							pulumi.String("GET"),
    64  //						},
    65  //						AllowedOrigins: pulumi.StringArray{
    66  //							pulumi.String("*"),
    67  //						},
    68  //					},
    69  //				},
    70  //			})
    71  //			if err != nil {
    72  //				return err
    73  //			}
    74  //			return nil
    75  //		})
    76  //	}
    77  //
    78  // ```
    79  // <!--End PulumiCodeChooser -->
    80  //
    81  // ## Import
    82  //
    83  // If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expected_bucket_owner` separated by a comma (`,`):
    84  //
    85  // __Using `pulumi import` to import__ S3 bucket CORS configuration using the `bucket` or using the `bucket` and `expected_bucket_owner` separated by a comma (`,`). For example:
    86  //
    87  // If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, import using the `bucket`:
    88  //
    89  // ```sh
    90  // $ pulumi import aws:s3/bucketCorsConfigurationV2:BucketCorsConfigurationV2 example bucket-name
    91  // ```
    92  // If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expected_bucket_owner` separated by a comma (`,`):
    93  //
    94  // ```sh
    95  // $ pulumi import aws:s3/bucketCorsConfigurationV2:BucketCorsConfigurationV2 example bucket-name,123456789012
    96  // ```
    97  type BucketCorsConfigurationV2 struct {
    98  	pulumi.CustomResourceState
    99  
   100  	// Name of the bucket.
   101  	Bucket pulumi.StringOutput `pulumi:"bucket"`
   102  	// Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
   103  	CorsRules BucketCorsConfigurationV2CorsRuleArrayOutput `pulumi:"corsRules"`
   104  	// Account ID of the expected bucket owner.
   105  	ExpectedBucketOwner pulumi.StringPtrOutput `pulumi:"expectedBucketOwner"`
   106  }
   107  
   108  // NewBucketCorsConfigurationV2 registers a new resource with the given unique name, arguments, and options.
   109  func NewBucketCorsConfigurationV2(ctx *pulumi.Context,
   110  	name string, args *BucketCorsConfigurationV2Args, opts ...pulumi.ResourceOption) (*BucketCorsConfigurationV2, error) {
   111  	if args == nil {
   112  		return nil, errors.New("missing one or more required arguments")
   113  	}
   114  
   115  	if args.Bucket == nil {
   116  		return nil, errors.New("invalid value for required argument 'Bucket'")
   117  	}
   118  	if args.CorsRules == nil {
   119  		return nil, errors.New("invalid value for required argument 'CorsRules'")
   120  	}
   121  	opts = internal.PkgResourceDefaultOpts(opts)
   122  	var resource BucketCorsConfigurationV2
   123  	err := ctx.RegisterResource("aws:s3/bucketCorsConfigurationV2:BucketCorsConfigurationV2", name, args, &resource, opts...)
   124  	if err != nil {
   125  		return nil, err
   126  	}
   127  	return &resource, nil
   128  }
   129  
   130  // GetBucketCorsConfigurationV2 gets an existing BucketCorsConfigurationV2 resource's state with the given name, ID, and optional
   131  // state properties that are used to uniquely qualify the lookup (nil if not required).
   132  func GetBucketCorsConfigurationV2(ctx *pulumi.Context,
   133  	name string, id pulumi.IDInput, state *BucketCorsConfigurationV2State, opts ...pulumi.ResourceOption) (*BucketCorsConfigurationV2, error) {
   134  	var resource BucketCorsConfigurationV2
   135  	err := ctx.ReadResource("aws:s3/bucketCorsConfigurationV2:BucketCorsConfigurationV2", name, id, state, &resource, opts...)
   136  	if err != nil {
   137  		return nil, err
   138  	}
   139  	return &resource, nil
   140  }
   141  
   142  // Input properties used for looking up and filtering BucketCorsConfigurationV2 resources.
   143  type bucketCorsConfigurationV2State struct {
   144  	// Name of the bucket.
   145  	Bucket *string `pulumi:"bucket"`
   146  	// Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
   147  	CorsRules []BucketCorsConfigurationV2CorsRule `pulumi:"corsRules"`
   148  	// Account ID of the expected bucket owner.
   149  	ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"`
   150  }
   151  
   152  type BucketCorsConfigurationV2State struct {
   153  	// Name of the bucket.
   154  	Bucket pulumi.StringPtrInput
   155  	// Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
   156  	CorsRules BucketCorsConfigurationV2CorsRuleArrayInput
   157  	// Account ID of the expected bucket owner.
   158  	ExpectedBucketOwner pulumi.StringPtrInput
   159  }
   160  
   161  func (BucketCorsConfigurationV2State) ElementType() reflect.Type {
   162  	return reflect.TypeOf((*bucketCorsConfigurationV2State)(nil)).Elem()
   163  }
   164  
   165  type bucketCorsConfigurationV2Args struct {
   166  	// Name of the bucket.
   167  	Bucket string `pulumi:"bucket"`
   168  	// Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
   169  	CorsRules []BucketCorsConfigurationV2CorsRule `pulumi:"corsRules"`
   170  	// Account ID of the expected bucket owner.
   171  	ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"`
   172  }
   173  
   174  // The set of arguments for constructing a BucketCorsConfigurationV2 resource.
   175  type BucketCorsConfigurationV2Args struct {
   176  	// Name of the bucket.
   177  	Bucket pulumi.StringInput
   178  	// Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
   179  	CorsRules BucketCorsConfigurationV2CorsRuleArrayInput
   180  	// Account ID of the expected bucket owner.
   181  	ExpectedBucketOwner pulumi.StringPtrInput
   182  }
   183  
   184  func (BucketCorsConfigurationV2Args) ElementType() reflect.Type {
   185  	return reflect.TypeOf((*bucketCorsConfigurationV2Args)(nil)).Elem()
   186  }
   187  
   188  type BucketCorsConfigurationV2Input interface {
   189  	pulumi.Input
   190  
   191  	ToBucketCorsConfigurationV2Output() BucketCorsConfigurationV2Output
   192  	ToBucketCorsConfigurationV2OutputWithContext(ctx context.Context) BucketCorsConfigurationV2Output
   193  }
   194  
   195  func (*BucketCorsConfigurationV2) ElementType() reflect.Type {
   196  	return reflect.TypeOf((**BucketCorsConfigurationV2)(nil)).Elem()
   197  }
   198  
   199  func (i *BucketCorsConfigurationV2) ToBucketCorsConfigurationV2Output() BucketCorsConfigurationV2Output {
   200  	return i.ToBucketCorsConfigurationV2OutputWithContext(context.Background())
   201  }
   202  
   203  func (i *BucketCorsConfigurationV2) ToBucketCorsConfigurationV2OutputWithContext(ctx context.Context) BucketCorsConfigurationV2Output {
   204  	return pulumi.ToOutputWithContext(ctx, i).(BucketCorsConfigurationV2Output)
   205  }
   206  
   207  // BucketCorsConfigurationV2ArrayInput is an input type that accepts BucketCorsConfigurationV2Array and BucketCorsConfigurationV2ArrayOutput values.
   208  // You can construct a concrete instance of `BucketCorsConfigurationV2ArrayInput` via:
   209  //
   210  //	BucketCorsConfigurationV2Array{ BucketCorsConfigurationV2Args{...} }
   211  type BucketCorsConfigurationV2ArrayInput interface {
   212  	pulumi.Input
   213  
   214  	ToBucketCorsConfigurationV2ArrayOutput() BucketCorsConfigurationV2ArrayOutput
   215  	ToBucketCorsConfigurationV2ArrayOutputWithContext(context.Context) BucketCorsConfigurationV2ArrayOutput
   216  }
   217  
   218  type BucketCorsConfigurationV2Array []BucketCorsConfigurationV2Input
   219  
   220  func (BucketCorsConfigurationV2Array) ElementType() reflect.Type {
   221  	return reflect.TypeOf((*[]*BucketCorsConfigurationV2)(nil)).Elem()
   222  }
   223  
   224  func (i BucketCorsConfigurationV2Array) ToBucketCorsConfigurationV2ArrayOutput() BucketCorsConfigurationV2ArrayOutput {
   225  	return i.ToBucketCorsConfigurationV2ArrayOutputWithContext(context.Background())
   226  }
   227  
   228  func (i BucketCorsConfigurationV2Array) ToBucketCorsConfigurationV2ArrayOutputWithContext(ctx context.Context) BucketCorsConfigurationV2ArrayOutput {
   229  	return pulumi.ToOutputWithContext(ctx, i).(BucketCorsConfigurationV2ArrayOutput)
   230  }
   231  
   232  // BucketCorsConfigurationV2MapInput is an input type that accepts BucketCorsConfigurationV2Map and BucketCorsConfigurationV2MapOutput values.
   233  // You can construct a concrete instance of `BucketCorsConfigurationV2MapInput` via:
   234  //
   235  //	BucketCorsConfigurationV2Map{ "key": BucketCorsConfigurationV2Args{...} }
   236  type BucketCorsConfigurationV2MapInput interface {
   237  	pulumi.Input
   238  
   239  	ToBucketCorsConfigurationV2MapOutput() BucketCorsConfigurationV2MapOutput
   240  	ToBucketCorsConfigurationV2MapOutputWithContext(context.Context) BucketCorsConfigurationV2MapOutput
   241  }
   242  
   243  type BucketCorsConfigurationV2Map map[string]BucketCorsConfigurationV2Input
   244  
   245  func (BucketCorsConfigurationV2Map) ElementType() reflect.Type {
   246  	return reflect.TypeOf((*map[string]*BucketCorsConfigurationV2)(nil)).Elem()
   247  }
   248  
   249  func (i BucketCorsConfigurationV2Map) ToBucketCorsConfigurationV2MapOutput() BucketCorsConfigurationV2MapOutput {
   250  	return i.ToBucketCorsConfigurationV2MapOutputWithContext(context.Background())
   251  }
   252  
   253  func (i BucketCorsConfigurationV2Map) ToBucketCorsConfigurationV2MapOutputWithContext(ctx context.Context) BucketCorsConfigurationV2MapOutput {
   254  	return pulumi.ToOutputWithContext(ctx, i).(BucketCorsConfigurationV2MapOutput)
   255  }
   256  
   257  type BucketCorsConfigurationV2Output struct{ *pulumi.OutputState }
   258  
   259  func (BucketCorsConfigurationV2Output) ElementType() reflect.Type {
   260  	return reflect.TypeOf((**BucketCorsConfigurationV2)(nil)).Elem()
   261  }
   262  
   263  func (o BucketCorsConfigurationV2Output) ToBucketCorsConfigurationV2Output() BucketCorsConfigurationV2Output {
   264  	return o
   265  }
   266  
   267  func (o BucketCorsConfigurationV2Output) ToBucketCorsConfigurationV2OutputWithContext(ctx context.Context) BucketCorsConfigurationV2Output {
   268  	return o
   269  }
   270  
   271  // Name of the bucket.
   272  func (o BucketCorsConfigurationV2Output) Bucket() pulumi.StringOutput {
   273  	return o.ApplyT(func(v *BucketCorsConfigurationV2) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput)
   274  }
   275  
   276  // Set of origins and methods (cross-origin access that you want to allow). See below. You can configure up to 100 rules.
   277  func (o BucketCorsConfigurationV2Output) CorsRules() BucketCorsConfigurationV2CorsRuleArrayOutput {
   278  	return o.ApplyT(func(v *BucketCorsConfigurationV2) BucketCorsConfigurationV2CorsRuleArrayOutput { return v.CorsRules }).(BucketCorsConfigurationV2CorsRuleArrayOutput)
   279  }
   280  
   281  // Account ID of the expected bucket owner.
   282  func (o BucketCorsConfigurationV2Output) ExpectedBucketOwner() pulumi.StringPtrOutput {
   283  	return o.ApplyT(func(v *BucketCorsConfigurationV2) pulumi.StringPtrOutput { return v.ExpectedBucketOwner }).(pulumi.StringPtrOutput)
   284  }
   285  
   286  type BucketCorsConfigurationV2ArrayOutput struct{ *pulumi.OutputState }
   287  
   288  func (BucketCorsConfigurationV2ArrayOutput) ElementType() reflect.Type {
   289  	return reflect.TypeOf((*[]*BucketCorsConfigurationV2)(nil)).Elem()
   290  }
   291  
   292  func (o BucketCorsConfigurationV2ArrayOutput) ToBucketCorsConfigurationV2ArrayOutput() BucketCorsConfigurationV2ArrayOutput {
   293  	return o
   294  }
   295  
   296  func (o BucketCorsConfigurationV2ArrayOutput) ToBucketCorsConfigurationV2ArrayOutputWithContext(ctx context.Context) BucketCorsConfigurationV2ArrayOutput {
   297  	return o
   298  }
   299  
   300  func (o BucketCorsConfigurationV2ArrayOutput) Index(i pulumi.IntInput) BucketCorsConfigurationV2Output {
   301  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BucketCorsConfigurationV2 {
   302  		return vs[0].([]*BucketCorsConfigurationV2)[vs[1].(int)]
   303  	}).(BucketCorsConfigurationV2Output)
   304  }
   305  
   306  type BucketCorsConfigurationV2MapOutput struct{ *pulumi.OutputState }
   307  
   308  func (BucketCorsConfigurationV2MapOutput) ElementType() reflect.Type {
   309  	return reflect.TypeOf((*map[string]*BucketCorsConfigurationV2)(nil)).Elem()
   310  }
   311  
   312  func (o BucketCorsConfigurationV2MapOutput) ToBucketCorsConfigurationV2MapOutput() BucketCorsConfigurationV2MapOutput {
   313  	return o
   314  }
   315  
   316  func (o BucketCorsConfigurationV2MapOutput) ToBucketCorsConfigurationV2MapOutputWithContext(ctx context.Context) BucketCorsConfigurationV2MapOutput {
   317  	return o
   318  }
   319  
   320  func (o BucketCorsConfigurationV2MapOutput) MapIndex(k pulumi.StringInput) BucketCorsConfigurationV2Output {
   321  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BucketCorsConfigurationV2 {
   322  		return vs[0].(map[string]*BucketCorsConfigurationV2)[vs[1].(string)]
   323  	}).(BucketCorsConfigurationV2Output)
   324  }
   325  
   326  func init() {
   327  	pulumi.RegisterInputType(reflect.TypeOf((*BucketCorsConfigurationV2Input)(nil)).Elem(), &BucketCorsConfigurationV2{})
   328  	pulumi.RegisterInputType(reflect.TypeOf((*BucketCorsConfigurationV2ArrayInput)(nil)).Elem(), BucketCorsConfigurationV2Array{})
   329  	pulumi.RegisterInputType(reflect.TypeOf((*BucketCorsConfigurationV2MapInput)(nil)).Elem(), BucketCorsConfigurationV2Map{})
   330  	pulumi.RegisterOutputType(BucketCorsConfigurationV2Output{})
   331  	pulumi.RegisterOutputType(BucketCorsConfigurationV2ArrayOutput{})
   332  	pulumi.RegisterOutputType(BucketCorsConfigurationV2MapOutput{})
   333  }