aws.s3.BucketMetric
Explore with Pulumi AI
Provides a S3 bucket metrics configuration resource.
This resource cannot be used with S3 directory buckets.
Example Usage
Add metrics configuration for entire S3 bucket
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.s3.BucketV2("example", {bucket: "example"});
const example_entire_bucket = new aws.s3.BucketMetric("example-entire-bucket", {
bucket: example.id,
name: "EntireBucket",
});
import pulumi
import pulumi_aws as aws
example = aws.s3.BucketV2("example", bucket="example")
example_entire_bucket = aws.s3.BucketMetric("example-entire-bucket",
bucket=example.id,
name="EntireBucket")
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
Bucket: pulumi.String("example"),
})
if err != nil {
return err
}
_, err = s3.NewBucketMetric(ctx, "example-entire-bucket", &s3.BucketMetricArgs{
Bucket: example.ID(),
Name: pulumi.String("EntireBucket"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.S3.BucketV2("example", new()
{
Bucket = "example",
});
var example_entire_bucket = new Aws.S3.BucketMetric("example-entire-bucket", new()
{
Bucket = example.Id,
Name = "EntireBucket",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketMetric;
import com.pulumi.aws.s3.BucketMetricArgs;
import java.util.List;
import java.util.ArrayList;
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 BucketV2("example", BucketV2Args.builder()
.bucket("example")
.build());
var example_entire_bucket = new BucketMetric("example-entire-bucket", BucketMetricArgs.builder()
.bucket(example.id())
.name("EntireBucket")
.build());
}
}
resources:
example:
type: aws:s3:BucketV2
properties:
bucket: example
example-entire-bucket:
type: aws:s3:BucketMetric
properties:
bucket: ${example.id}
name: EntireBucket
Add metrics configuration with S3 object filter
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.s3.BucketV2("example", {bucket: "example"});
const example_filtered = new aws.s3.BucketMetric("example-filtered", {
bucket: example.id,
name: "ImportantBlueDocuments",
filter: {
prefix: "documents/",
tags: {
priority: "high",
"class": "blue",
},
},
});
import pulumi
import pulumi_aws as aws
example = aws.s3.BucketV2("example", bucket="example")
example_filtered = aws.s3.BucketMetric("example-filtered",
bucket=example.id,
name="ImportantBlueDocuments",
filter={
"prefix": "documents/",
"tags": {
"priority": "high",
"class_": "blue",
},
})
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
Bucket: pulumi.String("example"),
})
if err != nil {
return err
}
_, err = s3.NewBucketMetric(ctx, "example-filtered", &s3.BucketMetricArgs{
Bucket: example.ID(),
Name: pulumi.String("ImportantBlueDocuments"),
Filter: &s3.BucketMetricFilterArgs{
Prefix: pulumi.String("documents/"),
Tags: pulumi.StringMap{
"priority": pulumi.String("high"),
"class": pulumi.String("blue"),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.S3.BucketV2("example", new()
{
Bucket = "example",
});
var example_filtered = new Aws.S3.BucketMetric("example-filtered", new()
{
Bucket = example.Id,
Name = "ImportantBlueDocuments",
Filter = new Aws.S3.Inputs.BucketMetricFilterArgs
{
Prefix = "documents/",
Tags =
{
{ "priority", "high" },
{ "class", "blue" },
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketMetric;
import com.pulumi.aws.s3.BucketMetricArgs;
import com.pulumi.aws.s3.inputs.BucketMetricFilterArgs;
import java.util.List;
import java.util.ArrayList;
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 BucketV2("example", BucketV2Args.builder()
.bucket("example")
.build());
var example_filtered = new BucketMetric("example-filtered", BucketMetricArgs.builder()
.bucket(example.id())
.name("ImportantBlueDocuments")
.filter(BucketMetricFilterArgs.builder()
.prefix("documents/")
.tags(Map.ofEntries(
Map.entry("priority", "high"),
Map.entry("class", "blue")
))
.build())
.build());
}
}
resources:
example:
type: aws:s3:BucketV2
properties:
bucket: example
example-filtered:
type: aws:s3:BucketMetric
properties:
bucket: ${example.id}
name: ImportantBlueDocuments
filter:
prefix: documents/
tags:
priority: high
class: blue
Add metrics configuration with S3 object filter for S3 Access Point
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.s3.BucketV2("example", {bucket: "example"});
const example_access_point = new aws.s3.AccessPoint("example-access-point", {
bucket: example.id,
name: "example-access-point",
});
const example_filtered = new aws.s3.BucketMetric("example-filtered", {
bucket: example.id,
name: "ImportantBlueDocuments",
filter: {
accessPoint: example_access_point.arn,
tags: {
priority: "high",
"class": "blue",
},
},
});
import pulumi
import pulumi_aws as aws
example = aws.s3.BucketV2("example", bucket="example")
example_access_point = aws.s3.AccessPoint("example-access-point",
bucket=example.id,
name="example-access-point")
example_filtered = aws.s3.BucketMetric("example-filtered",
bucket=example.id,
name="ImportantBlueDocuments",
filter={
"access_point": example_access_point.arn,
"tags": {
"priority": "high",
"class_": "blue",
},
})
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
Bucket: pulumi.String("example"),
})
if err != nil {
return err
}
_, err = s3.NewAccessPoint(ctx, "example-access-point", &s3.AccessPointArgs{
Bucket: example.ID(),
Name: pulumi.String("example-access-point"),
})
if err != nil {
return err
}
_, err = s3.NewBucketMetric(ctx, "example-filtered", &s3.BucketMetricArgs{
Bucket: example.ID(),
Name: pulumi.String("ImportantBlueDocuments"),
Filter: &s3.BucketMetricFilterArgs{
AccessPoint: example_access_point.Arn,
Tags: pulumi.StringMap{
"priority": pulumi.String("high"),
"class": pulumi.String("blue"),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.S3.BucketV2("example", new()
{
Bucket = "example",
});
var example_access_point = new Aws.S3.AccessPoint("example-access-point", new()
{
Bucket = example.Id,
Name = "example-access-point",
});
var example_filtered = new Aws.S3.BucketMetric("example-filtered", new()
{
Bucket = example.Id,
Name = "ImportantBlueDocuments",
Filter = new Aws.S3.Inputs.BucketMetricFilterArgs
{
AccessPoint = example_access_point.Arn,
Tags =
{
{ "priority", "high" },
{ "class", "blue" },
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.AccessPoint;
import com.pulumi.aws.s3.AccessPointArgs;
import com.pulumi.aws.s3.BucketMetric;
import com.pulumi.aws.s3.BucketMetricArgs;
import com.pulumi.aws.s3.inputs.BucketMetricFilterArgs;
import java.util.List;
import java.util.ArrayList;
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 BucketV2("example", BucketV2Args.builder()
.bucket("example")
.build());
var example_access_point = new AccessPoint("example-access-point", AccessPointArgs.builder()
.bucket(example.id())
.name("example-access-point")
.build());
var example_filtered = new BucketMetric("example-filtered", BucketMetricArgs.builder()
.bucket(example.id())
.name("ImportantBlueDocuments")
.filter(BucketMetricFilterArgs.builder()
.accessPoint(example_access_point.arn())
.tags(Map.ofEntries(
Map.entry("priority", "high"),
Map.entry("class", "blue")
))
.build())
.build());
}
}
resources:
example:
type: aws:s3:BucketV2
properties:
bucket: example
example-access-point:
type: aws:s3:AccessPoint
properties:
bucket: ${example.id}
name: example-access-point
example-filtered:
type: aws:s3:BucketMetric
properties:
bucket: ${example.id}
name: ImportantBlueDocuments
filter:
accessPoint: ${["example-access-point"].arn}
tags:
priority: high
class: blue
Create BucketMetric Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new BucketMetric(name: string, args: BucketMetricArgs, opts?: CustomResourceOptions);
@overload
def BucketMetric(resource_name: str,
args: BucketMetricArgs,
opts: Optional[ResourceOptions] = None)
@overload
def BucketMetric(resource_name: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
filter: Optional[BucketMetricFilterArgs] = None,
name: Optional[str] = None)
func NewBucketMetric(ctx *Context, name string, args BucketMetricArgs, opts ...ResourceOption) (*BucketMetric, error)
public BucketMetric(string name, BucketMetricArgs args, CustomResourceOptions? opts = null)
public BucketMetric(String name, BucketMetricArgs args)
public BucketMetric(String name, BucketMetricArgs args, CustomResourceOptions options)
type: aws:s3:BucketMetric
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args BucketMetricArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args BucketMetricArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args BucketMetricArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args BucketMetricArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args BucketMetricArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var bucketMetricResource = new Aws.S3.BucketMetric("bucketMetricResource", new()
{
Bucket = "string",
Filter = new Aws.S3.Inputs.BucketMetricFilterArgs
{
AccessPoint = "string",
Prefix = "string",
Tags =
{
{ "string", "string" },
},
},
Name = "string",
});
example, err := s3.NewBucketMetric(ctx, "bucketMetricResource", &s3.BucketMetricArgs{
Bucket: pulumi.String("string"),
Filter: &s3.BucketMetricFilterArgs{
AccessPoint: pulumi.String("string"),
Prefix: pulumi.String("string"),
Tags: pulumi.StringMap{
"string": pulumi.String("string"),
},
},
Name: pulumi.String("string"),
})
var bucketMetricResource = new BucketMetric("bucketMetricResource", BucketMetricArgs.builder()
.bucket("string")
.filter(BucketMetricFilterArgs.builder()
.accessPoint("string")
.prefix("string")
.tags(Map.of("string", "string"))
.build())
.name("string")
.build());
bucket_metric_resource = aws.s3.BucketMetric("bucketMetricResource",
bucket="string",
filter={
"accessPoint": "string",
"prefix": "string",
"tags": {
"string": "string",
},
},
name="string")
const bucketMetricResource = new aws.s3.BucketMetric("bucketMetricResource", {
bucket: "string",
filter: {
accessPoint: "string",
prefix: "string",
tags: {
string: "string",
},
},
name: "string",
});
type: aws:s3:BucketMetric
properties:
bucket: string
filter:
accessPoint: string
prefix: string
tags:
string: string
name: string
BucketMetric Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The BucketMetric resource accepts the following input properties:
- Bucket string
- Name of the bucket to put metric configuration.
- Filter
Bucket
Metric Filter - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- Name string
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- Bucket string
- Name of the bucket to put metric configuration.
- Filter
Bucket
Metric Filter Args - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- Name string
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- bucket String
- Name of the bucket to put metric configuration.
- filter
Bucket
Metric Filter - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- name String
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- bucket string
- Name of the bucket to put metric configuration.
- filter
Bucket
Metric Filter - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- name string
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- bucket str
- Name of the bucket to put metric configuration.
- filter
Bucket
Metric Filter Args - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- name str
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- bucket String
- Name of the bucket to put metric configuration.
- filter Property Map
- Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- name String
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
Outputs
All input properties are implicitly available as output properties. Additionally, the BucketMetric resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing BucketMetric Resource
Get an existing BucketMetric resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: BucketMetricState, opts?: CustomResourceOptions): BucketMetric
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
filter: Optional[BucketMetricFilterArgs] = None,
name: Optional[str] = None) -> BucketMetric
func GetBucketMetric(ctx *Context, name string, id IDInput, state *BucketMetricState, opts ...ResourceOption) (*BucketMetric, error)
public static BucketMetric Get(string name, Input<string> id, BucketMetricState? state, CustomResourceOptions? opts = null)
public static BucketMetric get(String name, Output<String> id, BucketMetricState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Bucket string
- Name of the bucket to put metric configuration.
- Filter
Bucket
Metric Filter - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- Name string
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- Bucket string
- Name of the bucket to put metric configuration.
- Filter
Bucket
Metric Filter Args - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- Name string
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- bucket String
- Name of the bucket to put metric configuration.
- filter
Bucket
Metric Filter - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- name String
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- bucket string
- Name of the bucket to put metric configuration.
- filter
Bucket
Metric Filter - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- name string
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- bucket str
- Name of the bucket to put metric configuration.
- filter
Bucket
Metric Filter Args - Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- name str
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
- bucket String
- Name of the bucket to put metric configuration.
- filter Property Map
- Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
- name String
- Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
Supporting Types
BucketMetricFilter, BucketMetricFilterArgs
- Access
Point string - S3 Access Point ARN for filtering (singular).
- Prefix string
- Object prefix for filtering (singular).
- Dictionary<string, string>
- Object tags for filtering (up to 10).
- Access
Point string - S3 Access Point ARN for filtering (singular).
- Prefix string
- Object prefix for filtering (singular).
- map[string]string
- Object tags for filtering (up to 10).
- access
Point String - S3 Access Point ARN for filtering (singular).
- prefix String
- Object prefix for filtering (singular).
- Map<String,String>
- Object tags for filtering (up to 10).
- access
Point string - S3 Access Point ARN for filtering (singular).
- prefix string
- Object prefix for filtering (singular).
- {[key: string]: string}
- Object tags for filtering (up to 10).
- access_
point str - S3 Access Point ARN for filtering (singular).
- prefix str
- Object prefix for filtering (singular).
- Mapping[str, str]
- Object tags for filtering (up to 10).
- access
Point String - S3 Access Point ARN for filtering (singular).
- prefix String
- Object prefix for filtering (singular).
- Map<String>
- Object tags for filtering (up to 10).
Import
Using pulumi import
, import S3 bucket metric configurations using bucket:metric
. For example:
$ pulumi import aws:s3/bucketMetric:BucketMetric my-bucket-entire-bucket my-bucket:EntireBucket
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.