published on Wednesday, Oct 28, 2026 by Pulumi
published on Wednesday, Oct 28, 2026 by Pulumi
Manages a CloudWatch resource metrics configuration. Creating a configuration makes CloudWatch collect detailed metrics for the targeted AWS resource.
Each AWS resource can have at most one resource metrics configuration. Detailed metrics incur charges, so limit collection with metricSelection when you only need a subset of metrics. See Amazon CloudWatch pricing for details.
Note: Not every AWS resource type is eligible for detailed metrics. At the time of writing, only Amazon ElastiCache replication groups are supported. Targeting any other resource type, including ElastiCache serverless caches and cache clusters, returns a
ValidationErrorwith the messageUnsupported resource type.
Example Usage
Basic Usage
Omit metricSelection to collect every detailed metric that is available for the resource.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.elasticache.ReplicationGroup("example", {
replicationGroupId: "example",
description: "example",
engine: "valkey",
nodeType: "cache.t3.small",
numCacheClusters: 1,
});
const exampleResourceMetricsConfiguration = new aws.cloudwatch.ResourceMetricsConfiguration("example", {resourceArn: example.arn});
import pulumi
import pulumi_aws as aws
example = aws.elasticache.ReplicationGroup("example",
replication_group_id="example",
description="example",
engine="valkey",
node_type="cache.t3.small",
num_cache_clusters=1)
example_resource_metrics_configuration = aws.cloudwatch.ResourceMetricsConfiguration("example", resource_arn=example.arn)
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/elasticache"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := elasticache.NewReplicationGroup(ctx, "example", &elasticache.ReplicationGroupArgs{
ReplicationGroupId: pulumi.String("example"),
Description: pulumi.String("example"),
Engine: pulumi.String("valkey"),
NodeType: pulumi.String("cache.t3.small"),
NumCacheClusters: pulumi.Int(1),
})
if err != nil {
return err
}
_, err = cloudwatch.NewResourceMetricsConfiguration(ctx, "example", &cloudwatch.ResourceMetricsConfigurationArgs{
ResourceArn: example.Arn,
})
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.ElastiCache.ReplicationGroup("example", new()
{
ReplicationGroupId = "example",
Description = "example",
Engine = "valkey",
NodeType = "cache.t3.small",
NumCacheClusters = 1,
});
var exampleResourceMetricsConfiguration = new Aws.CloudWatch.ResourceMetricsConfiguration("example", new()
{
ResourceArn = example.Arn,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elasticache.ReplicationGroup;
import com.pulumi.aws.elasticache.ReplicationGroupArgs;
import com.pulumi.aws.cloudwatch.ResourceMetricsConfiguration;
import com.pulumi.aws.cloudwatch.ResourceMetricsConfigurationArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 ReplicationGroup("example", ReplicationGroupArgs.builder()
.replicationGroupId("example")
.description("example")
.engine("valkey")
.nodeType("cache.t3.small")
.numCacheClusters(1)
.build());
var exampleResourceMetricsConfiguration = new ResourceMetricsConfiguration("exampleResourceMetricsConfiguration", ResourceMetricsConfigurationArgs.builder()
.resourceArn(example.arn())
.build());
}
}
resources:
example:
type: aws:elasticache:ReplicationGroup
properties:
replicationGroupId: example
description: example
engine: valkey
nodeType: cache.t3.small
numCacheClusters: 1
exampleResourceMetricsConfiguration:
type: aws:cloudwatch:ResourceMetricsConfiguration
name: example
properties:
resourceArn: ${example.arn}
terraform {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_elasticache_replication_group" "example" {
lifecycle {
create_before_destroy = true
}
replication_group_id = "example"
description = "example"
engine = "valkey"
node_type = "cache.t3.small"
num_cache_clusters = 1
}
resource "aws_cloudwatch_resource_metrics_configuration" "example" {
lifecycle {
create_before_destroy = true
}
resource_arn = aws_elasticache_replication_group.example.arn
}
Collect Selected Metrics
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.cloudwatch.ResourceMetricsConfiguration("example", {
metricSelection: {
includeMetrics: [
"valkey.memory.used",
"valkey.commands.processed",
],
},
resourceArn: exampleAwsElasticacheReplicationGroup.arn,
});
import pulumi
import pulumi_aws as aws
example = aws.cloudwatch.ResourceMetricsConfiguration("example",
metric_selection={
"include_metrics": [
"valkey.memory.used",
"valkey.commands.processed",
],
},
resource_arn=example_aws_elasticache_replication_group["arn"])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cloudwatch"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudwatch.NewResourceMetricsConfiguration(ctx, "example", &cloudwatch.ResourceMetricsConfigurationArgs{
MetricSelection: &cloudwatch.ResourceMetricsConfigurationMetricSelectionArgs{
IncludeMetrics: pulumi.StringArray{
pulumi.String("valkey.memory.used"),
pulumi.String("valkey.commands.processed"),
},
},
ResourceArn: pulumi.Any(exampleAwsElasticacheReplicationGroup.Arn),
})
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.CloudWatch.ResourceMetricsConfiguration("example", new()
{
MetricSelection = new Aws.CloudWatch.Inputs.ResourceMetricsConfigurationMetricSelectionArgs
{
IncludeMetrics = new[]
{
"valkey.memory.used",
"valkey.commands.processed",
},
},
ResourceArn = exampleAwsElasticacheReplicationGroup.Arn,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.ResourceMetricsConfiguration;
import com.pulumi.aws.cloudwatch.ResourceMetricsConfigurationArgs;
import com.pulumi.aws.cloudwatch.inputs.ResourceMetricsConfigurationMetricSelectionArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 ResourceMetricsConfiguration("example", ResourceMetricsConfigurationArgs.builder()
.metricSelection(ResourceMetricsConfigurationMetricSelectionArgs.builder()
.includeMetrics(
"valkey.memory.used",
"valkey.commands.processed")
.build())
.resourceArn(exampleAwsElasticacheReplicationGroup.get("arn"))
.build());
}
}
resources:
example:
type: aws:cloudwatch:ResourceMetricsConfiguration
properties:
metricSelection:
includeMetrics:
- valkey.memory.used
- valkey.commands.processed
resourceArn: ${exampleAwsElasticacheReplicationGroup.arn}
terraform {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_cloudwatch_resource_metrics_configuration" "example" {
lifecycle {
create_before_destroy = true
}
metric_selection {
include_metrics = ["valkey.memory.used", "valkey.commands.processed"]
}
resource_arn = exampleAwsElasticacheReplicationGroup.arn
}
Create ResourceMetricsConfiguration Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ResourceMetricsConfiguration(name: string, args: ResourceMetricsConfigurationArgs, opts?: CustomResourceOptions);@overload
def ResourceMetricsConfiguration(resource_name: str,
args: ResourceMetricsConfigurationArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ResourceMetricsConfiguration(resource_name: str,
opts: Optional[ResourceOptions] = None,
resource_arn: Optional[str] = None,
metric_selection: Optional[ResourceMetricsConfigurationMetricSelectionArgs] = None,
region: Optional[str] = None)func NewResourceMetricsConfiguration(ctx *Context, name string, args ResourceMetricsConfigurationArgs, opts ...ResourceOption) (*ResourceMetricsConfiguration, error)public ResourceMetricsConfiguration(string name, ResourceMetricsConfigurationArgs args, CustomResourceOptions? opts = null)
public ResourceMetricsConfiguration(String name, ResourceMetricsConfigurationArgs args)
public ResourceMetricsConfiguration(String name, ResourceMetricsConfigurationArgs args, CustomResourceOptions options)
type: aws:cloudwatch:ResourceMetricsConfiguration
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "aws_cloudwatch_resource_metrics_configuration" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args ResourceMetricsConfigurationArgs
- 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 ResourceMetricsConfigurationArgs
- 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 ResourceMetricsConfigurationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ResourceMetricsConfigurationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ResourceMetricsConfigurationArgs
- 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 resourceMetricsConfigurationResource = new Aws.CloudWatch.ResourceMetricsConfiguration("resourceMetricsConfigurationResource", new()
{
ResourceArn = "string",
MetricSelection = new Aws.CloudWatch.Inputs.ResourceMetricsConfigurationMetricSelectionArgs
{
IncludeMetrics = new[]
{
"string",
},
},
Region = "string",
});
example, err := cloudwatch.NewResourceMetricsConfiguration(ctx, "resourceMetricsConfigurationResource", &cloudwatch.ResourceMetricsConfigurationArgs{
ResourceArn: pulumi.String("string"),
MetricSelection: &cloudwatch.ResourceMetricsConfigurationMetricSelectionArgs{
IncludeMetrics: pulumi.StringArray{
pulumi.String("string"),
},
},
Region: pulumi.String("string"),
})
resource "aws_cloudwatch_resource_metrics_configuration" "resourceMetricsConfigurationResource" {
lifecycle {
create_before_destroy = true
}
resource_arn = "string"
metric_selection = {
include_metrics = ["string"]
}
region = "string"
}
var resourceMetricsConfigurationResource = new ResourceMetricsConfiguration("resourceMetricsConfigurationResource", ResourceMetricsConfigurationArgs.builder()
.resourceArn("string")
.metricSelection(ResourceMetricsConfigurationMetricSelectionArgs.builder()
.includeMetrics("string")
.build())
.region("string")
.build());
resource_metrics_configuration_resource = aws.cloudwatch.ResourceMetricsConfiguration("resourceMetricsConfigurationResource",
resource_arn="string",
metric_selection={
"include_metrics": ["string"],
},
region="string")
const resourceMetricsConfigurationResource = new aws.cloudwatch.ResourceMetricsConfiguration("resourceMetricsConfigurationResource", {
resourceArn: "string",
metricSelection: {
includeMetrics: ["string"],
},
region: "string",
});
type: aws:cloudwatch:ResourceMetricsConfiguration
properties:
metricSelection:
includeMetrics:
- string
region: string
resourceArn: string
ResourceMetricsConfiguration Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The ResourceMetricsConfiguration resource accepts the following input properties:
- Resource
Arn string ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- Metric
Selection ResourceMetrics Configuration Metric Selection - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Resource
Arn string ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- Metric
Selection ResourceMetrics Configuration Metric Selection Args - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource_
arn string ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric_
selection object - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource
Arn String ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric
Selection ResourceMetrics Configuration Metric Selection - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource
Arn string ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric
Selection ResourceMetrics Configuration Metric Selection - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource_
arn str ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric_
selection ResourceMetrics Configuration Metric Selection Args - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region str
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource
Arn String ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric
Selection Property Map - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
Outputs
All input properties are implicitly available as output properties. Additionally, the ResourceMetricsConfiguration 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 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 ResourceMetricsConfiguration Resource
Get an existing ResourceMetricsConfiguration 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?: ResourceMetricsConfigurationState, opts?: CustomResourceOptions): ResourceMetricsConfiguration@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
metric_selection: Optional[ResourceMetricsConfigurationMetricSelectionArgs] = None,
region: Optional[str] = None,
resource_arn: Optional[str] = None) -> ResourceMetricsConfigurationfunc GetResourceMetricsConfiguration(ctx *Context, name string, id IDInput, state *ResourceMetricsConfigurationState, opts ...ResourceOption) (*ResourceMetricsConfiguration, error)public static ResourceMetricsConfiguration Get(string name, Input<string> id, ResourceMetricsConfigurationState? state, CustomResourceOptions? opts = null)public static ResourceMetricsConfiguration get(String name, Output<String> id, ResourceMetricsConfigurationState state, CustomResourceOptions options)resources: _: type: aws:cloudwatch:ResourceMetricsConfiguration get: id: ${id}import {
to = aws_cloudwatch_resource_metrics_configuration.example
id = "${id}"
}
- 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.
- Metric
Selection ResourceMetrics Configuration Metric Selection - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Resource
Arn string ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- Metric
Selection ResourceMetrics Configuration Metric Selection Args - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Resource
Arn string ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric_
selection object - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource_
arn string ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric
Selection ResourceMetrics Configuration Metric Selection - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource
Arn String ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric
Selection ResourceMetrics Configuration Metric Selection - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource
Arn string ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric_
selection ResourceMetrics Configuration Metric Selection Args - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region str
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource_
arn str ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
- metric
Selection Property Map - Configuration block that limits which metrics CloudWatch collects. At most one block is supported. When omitted, CloudWatch collects all available detailed metrics for the resource. See
metricSelectionbelow. - region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- resource
Arn String ARN of the AWS resource to enable detailed monitoring for. Changing this forces a new resource to be created.
The following arguments are optional:
Supporting Types
ResourceMetricsConfigurationMetricSelection, ResourceMetricsConfigurationMetricSelectionArgs
- Include
Metrics List<string> - Set of metric names to collect for the resource. CloudWatch collects only the metrics listed here. Between 1 and 500 names, each between 1 and 255 characters. For the OpenTelemetry metrics published by ElastiCache, see OpenTelemetry metrics.
- Include
Metrics []string - Set of metric names to collect for the resource. CloudWatch collects only the metrics listed here. Between 1 and 500 names, each between 1 and 255 characters. For the OpenTelemetry metrics published by ElastiCache, see OpenTelemetry metrics.
- include_
metrics list(string) - Set of metric names to collect for the resource. CloudWatch collects only the metrics listed here. Between 1 and 500 names, each between 1 and 255 characters. For the OpenTelemetry metrics published by ElastiCache, see OpenTelemetry metrics.
- include
Metrics List<String> - Set of metric names to collect for the resource. CloudWatch collects only the metrics listed here. Between 1 and 500 names, each between 1 and 255 characters. For the OpenTelemetry metrics published by ElastiCache, see OpenTelemetry metrics.
- include
Metrics string[] - Set of metric names to collect for the resource. CloudWatch collects only the metrics listed here. Between 1 and 500 names, each between 1 and 255 characters. For the OpenTelemetry metrics published by ElastiCache, see OpenTelemetry metrics.
- include_
metrics Sequence[str] - Set of metric names to collect for the resource. CloudWatch collects only the metrics listed here. Between 1 and 500 names, each between 1 and 255 characters. For the OpenTelemetry metrics published by ElastiCache, see OpenTelemetry metrics.
- include
Metrics List<String> - Set of metric names to collect for the resource. CloudWatch collects only the metrics listed here. Between 1 and 500 names, each between 1 and 255 characters. For the OpenTelemetry metrics published by ElastiCache, see OpenTelemetry metrics.
Import
Identity Schema
Required
resourceArn- ARN of the AWS resource that the resource metrics configuration applies to.
Using pulumi import, import a CloudWatch resource metrics configuration using the resourceArn. For example:
$ pulumi import aws:cloudwatch/resourceMetricsConfiguration:ResourceMetricsConfiguration example arn:aws:elasticache:us-west-2:012345678901:replicationgroup:example
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
awsTerraform Provider.
published on Wednesday, Oct 28, 2026 by Pulumi