github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/s3/bucketMetric.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 a S3 bucket [metrics configuration](http://docs.aws.amazon.com/AmazonS3/latest/dev/metrics-configurations.html) resource.
    16  //
    17  // > This resource cannot be used with S3 directory buckets.
    18  //
    19  // ## Example Usage
    20  //
    21  // ### Add metrics configuration for entire S3 bucket
    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("example"),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			_, err = s3.NewBucketMetric(ctx, "example-entire-bucket", &s3.BucketMetricArgs{
    43  //				Bucket: example.ID(),
    44  //				Name:   pulumi.String("EntireBucket"),
    45  //			})
    46  //			if err != nil {
    47  //				return err
    48  //			}
    49  //			return nil
    50  //		})
    51  //	}
    52  //
    53  // ```
    54  // <!--End PulumiCodeChooser -->
    55  //
    56  // ### Add metrics configuration with S3 object filter
    57  //
    58  // <!--Start PulumiCodeChooser -->
    59  // ```go
    60  // package main
    61  //
    62  // import (
    63  //
    64  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    65  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    66  //
    67  // )
    68  //
    69  //	func main() {
    70  //		pulumi.Run(func(ctx *pulumi.Context) error {
    71  //			example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
    72  //				Bucket: pulumi.String("example"),
    73  //			})
    74  //			if err != nil {
    75  //				return err
    76  //			}
    77  //			_, err = s3.NewBucketMetric(ctx, "example-filtered", &s3.BucketMetricArgs{
    78  //				Bucket: example.ID(),
    79  //				Name:   pulumi.String("ImportantBlueDocuments"),
    80  //				Filter: &s3.BucketMetricFilterArgs{
    81  //					Prefix: pulumi.String("documents/"),
    82  //					Tags: pulumi.StringMap{
    83  //						"priority": pulumi.String("high"),
    84  //						"class":    pulumi.String("blue"),
    85  //					},
    86  //				},
    87  //			})
    88  //			if err != nil {
    89  //				return err
    90  //			}
    91  //			return nil
    92  //		})
    93  //	}
    94  //
    95  // ```
    96  // <!--End PulumiCodeChooser -->
    97  //
    98  // ### Add metrics configuration with S3 object filter for S3 Access Point
    99  //
   100  // <!--Start PulumiCodeChooser -->
   101  // ```go
   102  // package main
   103  //
   104  // import (
   105  //
   106  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
   107  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
   108  //
   109  // )
   110  //
   111  //	func main() {
   112  //		pulumi.Run(func(ctx *pulumi.Context) error {
   113  //			example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
   114  //				Bucket: pulumi.String("example"),
   115  //			})
   116  //			if err != nil {
   117  //				return err
   118  //			}
   119  //			_, err = s3.NewAccessPoint(ctx, "example-access-point", &s3.AccessPointArgs{
   120  //				Bucket: example.ID(),
   121  //				Name:   pulumi.String("example-access-point"),
   122  //			})
   123  //			if err != nil {
   124  //				return err
   125  //			}
   126  //			_, err = s3.NewBucketMetric(ctx, "example-filtered", &s3.BucketMetricArgs{
   127  //				Bucket: example.ID(),
   128  //				Name:   pulumi.String("ImportantBlueDocuments"),
   129  //				Filter: &s3.BucketMetricFilterArgs{
   130  //					AccessPoint: example_access_point.Arn,
   131  //					Tags: pulumi.StringMap{
   132  //						"priority": pulumi.String("high"),
   133  //						"class":    pulumi.String("blue"),
   134  //					},
   135  //				},
   136  //			})
   137  //			if err != nil {
   138  //				return err
   139  //			}
   140  //			return nil
   141  //		})
   142  //	}
   143  //
   144  // ```
   145  // <!--End PulumiCodeChooser -->
   146  //
   147  // ## Import
   148  //
   149  // Using `pulumi import`, import S3 bucket metric configurations using `bucket:metric`. For example:
   150  //
   151  // ```sh
   152  // $ pulumi import aws:s3/bucketMetric:BucketMetric my-bucket-entire-bucket my-bucket:EntireBucket
   153  // ```
   154  type BucketMetric struct {
   155  	pulumi.CustomResourceState
   156  
   157  	// Name of the bucket to put metric configuration.
   158  	Bucket pulumi.StringOutput `pulumi:"bucket"`
   159  	// [Object filtering](http://docs.aws.amazon.com/AmazonS3/latest/dev/metrics-configurations.html#metrics-configurations-filter) that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
   160  	Filter BucketMetricFilterPtrOutput `pulumi:"filter"`
   161  	// Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
   162  	Name pulumi.StringOutput `pulumi:"name"`
   163  }
   164  
   165  // NewBucketMetric registers a new resource with the given unique name, arguments, and options.
   166  func NewBucketMetric(ctx *pulumi.Context,
   167  	name string, args *BucketMetricArgs, opts ...pulumi.ResourceOption) (*BucketMetric, error) {
   168  	if args == nil {
   169  		return nil, errors.New("missing one or more required arguments")
   170  	}
   171  
   172  	if args.Bucket == nil {
   173  		return nil, errors.New("invalid value for required argument 'Bucket'")
   174  	}
   175  	opts = internal.PkgResourceDefaultOpts(opts)
   176  	var resource BucketMetric
   177  	err := ctx.RegisterResource("aws:s3/bucketMetric:BucketMetric", name, args, &resource, opts...)
   178  	if err != nil {
   179  		return nil, err
   180  	}
   181  	return &resource, nil
   182  }
   183  
   184  // GetBucketMetric gets an existing BucketMetric resource's state with the given name, ID, and optional
   185  // state properties that are used to uniquely qualify the lookup (nil if not required).
   186  func GetBucketMetric(ctx *pulumi.Context,
   187  	name string, id pulumi.IDInput, state *BucketMetricState, opts ...pulumi.ResourceOption) (*BucketMetric, error) {
   188  	var resource BucketMetric
   189  	err := ctx.ReadResource("aws:s3/bucketMetric:BucketMetric", name, id, state, &resource, opts...)
   190  	if err != nil {
   191  		return nil, err
   192  	}
   193  	return &resource, nil
   194  }
   195  
   196  // Input properties used for looking up and filtering BucketMetric resources.
   197  type bucketMetricState struct {
   198  	// Name of the bucket to put metric configuration.
   199  	Bucket *string `pulumi:"bucket"`
   200  	// [Object filtering](http://docs.aws.amazon.com/AmazonS3/latest/dev/metrics-configurations.html#metrics-configurations-filter) that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
   201  	Filter *BucketMetricFilter `pulumi:"filter"`
   202  	// Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
   203  	Name *string `pulumi:"name"`
   204  }
   205  
   206  type BucketMetricState struct {
   207  	// Name of the bucket to put metric configuration.
   208  	Bucket pulumi.StringPtrInput
   209  	// [Object filtering](http://docs.aws.amazon.com/AmazonS3/latest/dev/metrics-configurations.html#metrics-configurations-filter) that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
   210  	Filter BucketMetricFilterPtrInput
   211  	// Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
   212  	Name pulumi.StringPtrInput
   213  }
   214  
   215  func (BucketMetricState) ElementType() reflect.Type {
   216  	return reflect.TypeOf((*bucketMetricState)(nil)).Elem()
   217  }
   218  
   219  type bucketMetricArgs struct {
   220  	// Name of the bucket to put metric configuration.
   221  	Bucket string `pulumi:"bucket"`
   222  	// [Object filtering](http://docs.aws.amazon.com/AmazonS3/latest/dev/metrics-configurations.html#metrics-configurations-filter) that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
   223  	Filter *BucketMetricFilter `pulumi:"filter"`
   224  	// Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
   225  	Name *string `pulumi:"name"`
   226  }
   227  
   228  // The set of arguments for constructing a BucketMetric resource.
   229  type BucketMetricArgs struct {
   230  	// Name of the bucket to put metric configuration.
   231  	Bucket pulumi.StringInput
   232  	// [Object filtering](http://docs.aws.amazon.com/AmazonS3/latest/dev/metrics-configurations.html#metrics-configurations-filter) that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
   233  	Filter BucketMetricFilterPtrInput
   234  	// Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
   235  	Name pulumi.StringPtrInput
   236  }
   237  
   238  func (BucketMetricArgs) ElementType() reflect.Type {
   239  	return reflect.TypeOf((*bucketMetricArgs)(nil)).Elem()
   240  }
   241  
   242  type BucketMetricInput interface {
   243  	pulumi.Input
   244  
   245  	ToBucketMetricOutput() BucketMetricOutput
   246  	ToBucketMetricOutputWithContext(ctx context.Context) BucketMetricOutput
   247  }
   248  
   249  func (*BucketMetric) ElementType() reflect.Type {
   250  	return reflect.TypeOf((**BucketMetric)(nil)).Elem()
   251  }
   252  
   253  func (i *BucketMetric) ToBucketMetricOutput() BucketMetricOutput {
   254  	return i.ToBucketMetricOutputWithContext(context.Background())
   255  }
   256  
   257  func (i *BucketMetric) ToBucketMetricOutputWithContext(ctx context.Context) BucketMetricOutput {
   258  	return pulumi.ToOutputWithContext(ctx, i).(BucketMetricOutput)
   259  }
   260  
   261  // BucketMetricArrayInput is an input type that accepts BucketMetricArray and BucketMetricArrayOutput values.
   262  // You can construct a concrete instance of `BucketMetricArrayInput` via:
   263  //
   264  //	BucketMetricArray{ BucketMetricArgs{...} }
   265  type BucketMetricArrayInput interface {
   266  	pulumi.Input
   267  
   268  	ToBucketMetricArrayOutput() BucketMetricArrayOutput
   269  	ToBucketMetricArrayOutputWithContext(context.Context) BucketMetricArrayOutput
   270  }
   271  
   272  type BucketMetricArray []BucketMetricInput
   273  
   274  func (BucketMetricArray) ElementType() reflect.Type {
   275  	return reflect.TypeOf((*[]*BucketMetric)(nil)).Elem()
   276  }
   277  
   278  func (i BucketMetricArray) ToBucketMetricArrayOutput() BucketMetricArrayOutput {
   279  	return i.ToBucketMetricArrayOutputWithContext(context.Background())
   280  }
   281  
   282  func (i BucketMetricArray) ToBucketMetricArrayOutputWithContext(ctx context.Context) BucketMetricArrayOutput {
   283  	return pulumi.ToOutputWithContext(ctx, i).(BucketMetricArrayOutput)
   284  }
   285  
   286  // BucketMetricMapInput is an input type that accepts BucketMetricMap and BucketMetricMapOutput values.
   287  // You can construct a concrete instance of `BucketMetricMapInput` via:
   288  //
   289  //	BucketMetricMap{ "key": BucketMetricArgs{...} }
   290  type BucketMetricMapInput interface {
   291  	pulumi.Input
   292  
   293  	ToBucketMetricMapOutput() BucketMetricMapOutput
   294  	ToBucketMetricMapOutputWithContext(context.Context) BucketMetricMapOutput
   295  }
   296  
   297  type BucketMetricMap map[string]BucketMetricInput
   298  
   299  func (BucketMetricMap) ElementType() reflect.Type {
   300  	return reflect.TypeOf((*map[string]*BucketMetric)(nil)).Elem()
   301  }
   302  
   303  func (i BucketMetricMap) ToBucketMetricMapOutput() BucketMetricMapOutput {
   304  	return i.ToBucketMetricMapOutputWithContext(context.Background())
   305  }
   306  
   307  func (i BucketMetricMap) ToBucketMetricMapOutputWithContext(ctx context.Context) BucketMetricMapOutput {
   308  	return pulumi.ToOutputWithContext(ctx, i).(BucketMetricMapOutput)
   309  }
   310  
   311  type BucketMetricOutput struct{ *pulumi.OutputState }
   312  
   313  func (BucketMetricOutput) ElementType() reflect.Type {
   314  	return reflect.TypeOf((**BucketMetric)(nil)).Elem()
   315  }
   316  
   317  func (o BucketMetricOutput) ToBucketMetricOutput() BucketMetricOutput {
   318  	return o
   319  }
   320  
   321  func (o BucketMetricOutput) ToBucketMetricOutputWithContext(ctx context.Context) BucketMetricOutput {
   322  	return o
   323  }
   324  
   325  // Name of the bucket to put metric configuration.
   326  func (o BucketMetricOutput) Bucket() pulumi.StringOutput {
   327  	return o.ApplyT(func(v *BucketMetric) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput)
   328  }
   329  
   330  // [Object filtering](http://docs.aws.amazon.com/AmazonS3/latest/dev/metrics-configurations.html#metrics-configurations-filter) that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
   331  func (o BucketMetricOutput) Filter() BucketMetricFilterPtrOutput {
   332  	return o.ApplyT(func(v *BucketMetric) BucketMetricFilterPtrOutput { return v.Filter }).(BucketMetricFilterPtrOutput)
   333  }
   334  
   335  // Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
   336  func (o BucketMetricOutput) Name() pulumi.StringOutput {
   337  	return o.ApplyT(func(v *BucketMetric) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   338  }
   339  
   340  type BucketMetricArrayOutput struct{ *pulumi.OutputState }
   341  
   342  func (BucketMetricArrayOutput) ElementType() reflect.Type {
   343  	return reflect.TypeOf((*[]*BucketMetric)(nil)).Elem()
   344  }
   345  
   346  func (o BucketMetricArrayOutput) ToBucketMetricArrayOutput() BucketMetricArrayOutput {
   347  	return o
   348  }
   349  
   350  func (o BucketMetricArrayOutput) ToBucketMetricArrayOutputWithContext(ctx context.Context) BucketMetricArrayOutput {
   351  	return o
   352  }
   353  
   354  func (o BucketMetricArrayOutput) Index(i pulumi.IntInput) BucketMetricOutput {
   355  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BucketMetric {
   356  		return vs[0].([]*BucketMetric)[vs[1].(int)]
   357  	}).(BucketMetricOutput)
   358  }
   359  
   360  type BucketMetricMapOutput struct{ *pulumi.OutputState }
   361  
   362  func (BucketMetricMapOutput) ElementType() reflect.Type {
   363  	return reflect.TypeOf((*map[string]*BucketMetric)(nil)).Elem()
   364  }
   365  
   366  func (o BucketMetricMapOutput) ToBucketMetricMapOutput() BucketMetricMapOutput {
   367  	return o
   368  }
   369  
   370  func (o BucketMetricMapOutput) ToBucketMetricMapOutputWithContext(ctx context.Context) BucketMetricMapOutput {
   371  	return o
   372  }
   373  
   374  func (o BucketMetricMapOutput) MapIndex(k pulumi.StringInput) BucketMetricOutput {
   375  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BucketMetric {
   376  		return vs[0].(map[string]*BucketMetric)[vs[1].(string)]
   377  	}).(BucketMetricOutput)
   378  }
   379  
   380  func init() {
   381  	pulumi.RegisterInputType(reflect.TypeOf((*BucketMetricInput)(nil)).Elem(), &BucketMetric{})
   382  	pulumi.RegisterInputType(reflect.TypeOf((*BucketMetricArrayInput)(nil)).Elem(), BucketMetricArray{})
   383  	pulumi.RegisterInputType(reflect.TypeOf((*BucketMetricMapInput)(nil)).Elem(), BucketMetricMap{})
   384  	pulumi.RegisterOutputType(BucketMetricOutput{})
   385  	pulumi.RegisterOutputType(BucketMetricArrayOutput{})
   386  	pulumi.RegisterOutputType(BucketMetricMapOutput{})
   387  }