github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/s3/bucketLoggingV2.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 (server access) logging resource. For more information, see [Logging requests using server access logging](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerLogs.html)
    16  // in the AWS S3 User Guide.
    17  //
    18  // > **Note:** Amazon S3 supports server access logging, AWS CloudTrail, or a combination of both. Refer to the [Logging options for Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/logging-with-S3.html)
    19  // to decide which method meets your requirements.
    20  //
    21  // > This resource cannot be used with S3 directory buckets.
    22  //
    23  // ## Example Usage
    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  //			_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
    45  //				Bucket: example.ID(),
    46  //				Acl:    pulumi.String("private"),
    47  //			})
    48  //			if err != nil {
    49  //				return err
    50  //			}
    51  //			logBucket, err := s3.NewBucketV2(ctx, "log_bucket", &s3.BucketV2Args{
    52  //				Bucket: pulumi.String("my-tf-log-bucket"),
    53  //			})
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			_, err = s3.NewBucketAclV2(ctx, "log_bucket_acl", &s3.BucketAclV2Args{
    58  //				Bucket: logBucket.ID(),
    59  //				Acl:    pulumi.String("log-delivery-write"),
    60  //			})
    61  //			if err != nil {
    62  //				return err
    63  //			}
    64  //			_, err = s3.NewBucketLoggingV2(ctx, "example", &s3.BucketLoggingV2Args{
    65  //				Bucket:       example.ID(),
    66  //				TargetBucket: logBucket.ID(),
    67  //				TargetPrefix: pulumi.String("log/"),
    68  //			})
    69  //			if err != nil {
    70  //				return err
    71  //			}
    72  //			return nil
    73  //		})
    74  //	}
    75  //
    76  // ```
    77  // <!--End PulumiCodeChooser -->
    78  //
    79  // ## Import
    80  //
    81  // 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 (`,`):
    82  //
    83  // __Using `pulumi import` to import__ S3 bucket logging using the `bucket` or using the `bucket` and `expected_bucket_owner` separated by a comma (`,`). For example:
    84  //
    85  // If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, import using the `bucket`:
    86  //
    87  // ```sh
    88  // $ pulumi import aws:s3/bucketLoggingV2:BucketLoggingV2 example bucket-name
    89  // ```
    90  // 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 (`,`):
    91  //
    92  // ```sh
    93  // $ pulumi import aws:s3/bucketLoggingV2:BucketLoggingV2 example bucket-name,123456789012
    94  // ```
    95  type BucketLoggingV2 struct {
    96  	pulumi.CustomResourceState
    97  
    98  	// Name of the bucket.
    99  	Bucket pulumi.StringOutput `pulumi:"bucket"`
   100  	// Account ID of the expected bucket owner.
   101  	ExpectedBucketOwner pulumi.StringPtrOutput `pulumi:"expectedBucketOwner"`
   102  	// Name of the bucket where you want Amazon S3 to store server access logs.
   103  	TargetBucket pulumi.StringOutput `pulumi:"targetBucket"`
   104  	// Set of configuration blocks with information for granting permissions. See below.
   105  	TargetGrants BucketLoggingV2TargetGrantArrayOutput `pulumi:"targetGrants"`
   106  	// Amazon S3 key format for log objects. See below.
   107  	TargetObjectKeyFormat BucketLoggingV2TargetObjectKeyFormatPtrOutput `pulumi:"targetObjectKeyFormat"`
   108  	// Prefix for all log object keys.
   109  	TargetPrefix pulumi.StringOutput `pulumi:"targetPrefix"`
   110  }
   111  
   112  // NewBucketLoggingV2 registers a new resource with the given unique name, arguments, and options.
   113  func NewBucketLoggingV2(ctx *pulumi.Context,
   114  	name string, args *BucketLoggingV2Args, opts ...pulumi.ResourceOption) (*BucketLoggingV2, error) {
   115  	if args == nil {
   116  		return nil, errors.New("missing one or more required arguments")
   117  	}
   118  
   119  	if args.Bucket == nil {
   120  		return nil, errors.New("invalid value for required argument 'Bucket'")
   121  	}
   122  	if args.TargetBucket == nil {
   123  		return nil, errors.New("invalid value for required argument 'TargetBucket'")
   124  	}
   125  	if args.TargetPrefix == nil {
   126  		return nil, errors.New("invalid value for required argument 'TargetPrefix'")
   127  	}
   128  	opts = internal.PkgResourceDefaultOpts(opts)
   129  	var resource BucketLoggingV2
   130  	err := ctx.RegisterResource("aws:s3/bucketLoggingV2:BucketLoggingV2", name, args, &resource, opts...)
   131  	if err != nil {
   132  		return nil, err
   133  	}
   134  	return &resource, nil
   135  }
   136  
   137  // GetBucketLoggingV2 gets an existing BucketLoggingV2 resource's state with the given name, ID, and optional
   138  // state properties that are used to uniquely qualify the lookup (nil if not required).
   139  func GetBucketLoggingV2(ctx *pulumi.Context,
   140  	name string, id pulumi.IDInput, state *BucketLoggingV2State, opts ...pulumi.ResourceOption) (*BucketLoggingV2, error) {
   141  	var resource BucketLoggingV2
   142  	err := ctx.ReadResource("aws:s3/bucketLoggingV2:BucketLoggingV2", name, id, state, &resource, opts...)
   143  	if err != nil {
   144  		return nil, err
   145  	}
   146  	return &resource, nil
   147  }
   148  
   149  // Input properties used for looking up and filtering BucketLoggingV2 resources.
   150  type bucketLoggingV2State struct {
   151  	// Name of the bucket.
   152  	Bucket *string `pulumi:"bucket"`
   153  	// Account ID of the expected bucket owner.
   154  	ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"`
   155  	// Name of the bucket where you want Amazon S3 to store server access logs.
   156  	TargetBucket *string `pulumi:"targetBucket"`
   157  	// Set of configuration blocks with information for granting permissions. See below.
   158  	TargetGrants []BucketLoggingV2TargetGrant `pulumi:"targetGrants"`
   159  	// Amazon S3 key format for log objects. See below.
   160  	TargetObjectKeyFormat *BucketLoggingV2TargetObjectKeyFormat `pulumi:"targetObjectKeyFormat"`
   161  	// Prefix for all log object keys.
   162  	TargetPrefix *string `pulumi:"targetPrefix"`
   163  }
   164  
   165  type BucketLoggingV2State struct {
   166  	// Name of the bucket.
   167  	Bucket pulumi.StringPtrInput
   168  	// Account ID of the expected bucket owner.
   169  	ExpectedBucketOwner pulumi.StringPtrInput
   170  	// Name of the bucket where you want Amazon S3 to store server access logs.
   171  	TargetBucket pulumi.StringPtrInput
   172  	// Set of configuration blocks with information for granting permissions. See below.
   173  	TargetGrants BucketLoggingV2TargetGrantArrayInput
   174  	// Amazon S3 key format for log objects. See below.
   175  	TargetObjectKeyFormat BucketLoggingV2TargetObjectKeyFormatPtrInput
   176  	// Prefix for all log object keys.
   177  	TargetPrefix pulumi.StringPtrInput
   178  }
   179  
   180  func (BucketLoggingV2State) ElementType() reflect.Type {
   181  	return reflect.TypeOf((*bucketLoggingV2State)(nil)).Elem()
   182  }
   183  
   184  type bucketLoggingV2Args struct {
   185  	// Name of the bucket.
   186  	Bucket string `pulumi:"bucket"`
   187  	// Account ID of the expected bucket owner.
   188  	ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"`
   189  	// Name of the bucket where you want Amazon S3 to store server access logs.
   190  	TargetBucket string `pulumi:"targetBucket"`
   191  	// Set of configuration blocks with information for granting permissions. See below.
   192  	TargetGrants []BucketLoggingV2TargetGrant `pulumi:"targetGrants"`
   193  	// Amazon S3 key format for log objects. See below.
   194  	TargetObjectKeyFormat *BucketLoggingV2TargetObjectKeyFormat `pulumi:"targetObjectKeyFormat"`
   195  	// Prefix for all log object keys.
   196  	TargetPrefix string `pulumi:"targetPrefix"`
   197  }
   198  
   199  // The set of arguments for constructing a BucketLoggingV2 resource.
   200  type BucketLoggingV2Args struct {
   201  	// Name of the bucket.
   202  	Bucket pulumi.StringInput
   203  	// Account ID of the expected bucket owner.
   204  	ExpectedBucketOwner pulumi.StringPtrInput
   205  	// Name of the bucket where you want Amazon S3 to store server access logs.
   206  	TargetBucket pulumi.StringInput
   207  	// Set of configuration blocks with information for granting permissions. See below.
   208  	TargetGrants BucketLoggingV2TargetGrantArrayInput
   209  	// Amazon S3 key format for log objects. See below.
   210  	TargetObjectKeyFormat BucketLoggingV2TargetObjectKeyFormatPtrInput
   211  	// Prefix for all log object keys.
   212  	TargetPrefix pulumi.StringInput
   213  }
   214  
   215  func (BucketLoggingV2Args) ElementType() reflect.Type {
   216  	return reflect.TypeOf((*bucketLoggingV2Args)(nil)).Elem()
   217  }
   218  
   219  type BucketLoggingV2Input interface {
   220  	pulumi.Input
   221  
   222  	ToBucketLoggingV2Output() BucketLoggingV2Output
   223  	ToBucketLoggingV2OutputWithContext(ctx context.Context) BucketLoggingV2Output
   224  }
   225  
   226  func (*BucketLoggingV2) ElementType() reflect.Type {
   227  	return reflect.TypeOf((**BucketLoggingV2)(nil)).Elem()
   228  }
   229  
   230  func (i *BucketLoggingV2) ToBucketLoggingV2Output() BucketLoggingV2Output {
   231  	return i.ToBucketLoggingV2OutputWithContext(context.Background())
   232  }
   233  
   234  func (i *BucketLoggingV2) ToBucketLoggingV2OutputWithContext(ctx context.Context) BucketLoggingV2Output {
   235  	return pulumi.ToOutputWithContext(ctx, i).(BucketLoggingV2Output)
   236  }
   237  
   238  // BucketLoggingV2ArrayInput is an input type that accepts BucketLoggingV2Array and BucketLoggingV2ArrayOutput values.
   239  // You can construct a concrete instance of `BucketLoggingV2ArrayInput` via:
   240  //
   241  //	BucketLoggingV2Array{ BucketLoggingV2Args{...} }
   242  type BucketLoggingV2ArrayInput interface {
   243  	pulumi.Input
   244  
   245  	ToBucketLoggingV2ArrayOutput() BucketLoggingV2ArrayOutput
   246  	ToBucketLoggingV2ArrayOutputWithContext(context.Context) BucketLoggingV2ArrayOutput
   247  }
   248  
   249  type BucketLoggingV2Array []BucketLoggingV2Input
   250  
   251  func (BucketLoggingV2Array) ElementType() reflect.Type {
   252  	return reflect.TypeOf((*[]*BucketLoggingV2)(nil)).Elem()
   253  }
   254  
   255  func (i BucketLoggingV2Array) ToBucketLoggingV2ArrayOutput() BucketLoggingV2ArrayOutput {
   256  	return i.ToBucketLoggingV2ArrayOutputWithContext(context.Background())
   257  }
   258  
   259  func (i BucketLoggingV2Array) ToBucketLoggingV2ArrayOutputWithContext(ctx context.Context) BucketLoggingV2ArrayOutput {
   260  	return pulumi.ToOutputWithContext(ctx, i).(BucketLoggingV2ArrayOutput)
   261  }
   262  
   263  // BucketLoggingV2MapInput is an input type that accepts BucketLoggingV2Map and BucketLoggingV2MapOutput values.
   264  // You can construct a concrete instance of `BucketLoggingV2MapInput` via:
   265  //
   266  //	BucketLoggingV2Map{ "key": BucketLoggingV2Args{...} }
   267  type BucketLoggingV2MapInput interface {
   268  	pulumi.Input
   269  
   270  	ToBucketLoggingV2MapOutput() BucketLoggingV2MapOutput
   271  	ToBucketLoggingV2MapOutputWithContext(context.Context) BucketLoggingV2MapOutput
   272  }
   273  
   274  type BucketLoggingV2Map map[string]BucketLoggingV2Input
   275  
   276  func (BucketLoggingV2Map) ElementType() reflect.Type {
   277  	return reflect.TypeOf((*map[string]*BucketLoggingV2)(nil)).Elem()
   278  }
   279  
   280  func (i BucketLoggingV2Map) ToBucketLoggingV2MapOutput() BucketLoggingV2MapOutput {
   281  	return i.ToBucketLoggingV2MapOutputWithContext(context.Background())
   282  }
   283  
   284  func (i BucketLoggingV2Map) ToBucketLoggingV2MapOutputWithContext(ctx context.Context) BucketLoggingV2MapOutput {
   285  	return pulumi.ToOutputWithContext(ctx, i).(BucketLoggingV2MapOutput)
   286  }
   287  
   288  type BucketLoggingV2Output struct{ *pulumi.OutputState }
   289  
   290  func (BucketLoggingV2Output) ElementType() reflect.Type {
   291  	return reflect.TypeOf((**BucketLoggingV2)(nil)).Elem()
   292  }
   293  
   294  func (o BucketLoggingV2Output) ToBucketLoggingV2Output() BucketLoggingV2Output {
   295  	return o
   296  }
   297  
   298  func (o BucketLoggingV2Output) ToBucketLoggingV2OutputWithContext(ctx context.Context) BucketLoggingV2Output {
   299  	return o
   300  }
   301  
   302  // Name of the bucket.
   303  func (o BucketLoggingV2Output) Bucket() pulumi.StringOutput {
   304  	return o.ApplyT(func(v *BucketLoggingV2) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput)
   305  }
   306  
   307  // Account ID of the expected bucket owner.
   308  func (o BucketLoggingV2Output) ExpectedBucketOwner() pulumi.StringPtrOutput {
   309  	return o.ApplyT(func(v *BucketLoggingV2) pulumi.StringPtrOutput { return v.ExpectedBucketOwner }).(pulumi.StringPtrOutput)
   310  }
   311  
   312  // Name of the bucket where you want Amazon S3 to store server access logs.
   313  func (o BucketLoggingV2Output) TargetBucket() pulumi.StringOutput {
   314  	return o.ApplyT(func(v *BucketLoggingV2) pulumi.StringOutput { return v.TargetBucket }).(pulumi.StringOutput)
   315  }
   316  
   317  // Set of configuration blocks with information for granting permissions. See below.
   318  func (o BucketLoggingV2Output) TargetGrants() BucketLoggingV2TargetGrantArrayOutput {
   319  	return o.ApplyT(func(v *BucketLoggingV2) BucketLoggingV2TargetGrantArrayOutput { return v.TargetGrants }).(BucketLoggingV2TargetGrantArrayOutput)
   320  }
   321  
   322  // Amazon S3 key format for log objects. See below.
   323  func (o BucketLoggingV2Output) TargetObjectKeyFormat() BucketLoggingV2TargetObjectKeyFormatPtrOutput {
   324  	return o.ApplyT(func(v *BucketLoggingV2) BucketLoggingV2TargetObjectKeyFormatPtrOutput { return v.TargetObjectKeyFormat }).(BucketLoggingV2TargetObjectKeyFormatPtrOutput)
   325  }
   326  
   327  // Prefix for all log object keys.
   328  func (o BucketLoggingV2Output) TargetPrefix() pulumi.StringOutput {
   329  	return o.ApplyT(func(v *BucketLoggingV2) pulumi.StringOutput { return v.TargetPrefix }).(pulumi.StringOutput)
   330  }
   331  
   332  type BucketLoggingV2ArrayOutput struct{ *pulumi.OutputState }
   333  
   334  func (BucketLoggingV2ArrayOutput) ElementType() reflect.Type {
   335  	return reflect.TypeOf((*[]*BucketLoggingV2)(nil)).Elem()
   336  }
   337  
   338  func (o BucketLoggingV2ArrayOutput) ToBucketLoggingV2ArrayOutput() BucketLoggingV2ArrayOutput {
   339  	return o
   340  }
   341  
   342  func (o BucketLoggingV2ArrayOutput) ToBucketLoggingV2ArrayOutputWithContext(ctx context.Context) BucketLoggingV2ArrayOutput {
   343  	return o
   344  }
   345  
   346  func (o BucketLoggingV2ArrayOutput) Index(i pulumi.IntInput) BucketLoggingV2Output {
   347  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BucketLoggingV2 {
   348  		return vs[0].([]*BucketLoggingV2)[vs[1].(int)]
   349  	}).(BucketLoggingV2Output)
   350  }
   351  
   352  type BucketLoggingV2MapOutput struct{ *pulumi.OutputState }
   353  
   354  func (BucketLoggingV2MapOutput) ElementType() reflect.Type {
   355  	return reflect.TypeOf((*map[string]*BucketLoggingV2)(nil)).Elem()
   356  }
   357  
   358  func (o BucketLoggingV2MapOutput) ToBucketLoggingV2MapOutput() BucketLoggingV2MapOutput {
   359  	return o
   360  }
   361  
   362  func (o BucketLoggingV2MapOutput) ToBucketLoggingV2MapOutputWithContext(ctx context.Context) BucketLoggingV2MapOutput {
   363  	return o
   364  }
   365  
   366  func (o BucketLoggingV2MapOutput) MapIndex(k pulumi.StringInput) BucketLoggingV2Output {
   367  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BucketLoggingV2 {
   368  		return vs[0].(map[string]*BucketLoggingV2)[vs[1].(string)]
   369  	}).(BucketLoggingV2Output)
   370  }
   371  
   372  func init() {
   373  	pulumi.RegisterInputType(reflect.TypeOf((*BucketLoggingV2Input)(nil)).Elem(), &BucketLoggingV2{})
   374  	pulumi.RegisterInputType(reflect.TypeOf((*BucketLoggingV2ArrayInput)(nil)).Elem(), BucketLoggingV2Array{})
   375  	pulumi.RegisterInputType(reflect.TypeOf((*BucketLoggingV2MapInput)(nil)).Elem(), BucketLoggingV2Map{})
   376  	pulumi.RegisterOutputType(BucketLoggingV2Output{})
   377  	pulumi.RegisterOutputType(BucketLoggingV2ArrayOutput{})
   378  	pulumi.RegisterOutputType(BucketLoggingV2MapOutput{})
   379  }