AWS CloudWatch Metric Stream
This page shows how to write Terraform and CloudFormation for CloudWatch Metric Stream and write them securely.
aws_cloudwatch_metric_stream (Terraform)
The Metric Stream in CloudWatch can be configured in Terraform with the resource name aws_cloudwatch_metric_stream. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
The following arguments are required:
firehose_arn- (Required) ARN of the Amazon Kinesis Firehose delivery stream to use for this metric stream.role_arn- (Required) ARN of the IAM role that this metric stream will use to access Amazon Kinesis Firehose resources. For more information about role permissions, see Trust between CloudWatch and Kinesis Data Firehose.output_format- (Required) Output format for the stream. Possible values arejsonandopentelemetry0.7. For more information about output formats, see Metric streams output formats.
The following arguments are optional:
exclude_filter- (Optional) List of exclusive metric filters. If you specify this parameter, the stream sends metrics from all metric namespaces except for the namespaces that you specify here. Conflicts withinclude_filter.include_filter- (Optional) List of inclusive metric filters. If you specify this parameter, the stream sends only the metrics from the metric namespaces that you specify here. Conflicts withexclude_filter.name- (Optional, Forces new resource) Friendly name of the metric stream. If omitted, Terraform will assign a random, unique name. Conflicts withname_prefix.name_prefix- (Optional, Forces new resource) Creates a unique friendly name beginning with the specified prefix. Conflicts withname.tags- (Optional) Map of tags to assign to the resource. If configured with a providerdefault_tagsconfiguration block present, tags with matching keys will overwrite those defined at the provider-level.
exclude_filter
namespace- (Required) Name of the metric namespace in the filter.
include_filter
namespace- (Required) Name of the metric namespace in the filter.
In addition to all arguments above, the following attributes are exported:
arn- ARN of the metric stream.creation_date- Date and time in RFC3339 format that the metric stream was created.last_update_date- Date and time in RFC3339 format that the metric stream was last updated.state- State of the metric stream. Possible values arerunningandstopped.tags_all- A map of tags assigned to the resource, including those inherited from the providerdefault_tagsconfiguration block.
Explanation in Terraform Registry
Provides a CloudWatch Metric Stream resource.
AWS::CloudWatch::MetricStream (CloudFormation)
The MetricStream in CloudWatch can be configured in CloudFormation with the resource name AWS::CloudWatch::MetricStream. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
ExcludeFiltersoptional - List of MetricStreamFilter -
FirehoseArnrequired - String -
IncludeFiltersoptional - List of MetricStreamFilter -
Nameoptional - String -
RoleArnrequired - String -
OutputFormatrequired - String -
Tagsoptional - List of Tag
Explanation in CloudFormation Registry
Creates or updates a metric stream. Metrics streams can automatically stream CloudWatch metrics to AWS destinations including Amazon S3 and to many third-party solutions. For more information, see Metric streams. To create a metric stream, you must be logged on to an account that has the
iam:PassRolepermission and either the CloudWatchFullAccess policy or thecloudwatch:PutMetricStreampermission. When you create or update a metric stream, you choose one of the following:+ Stream metrics from all metric namespaces in the account.
Stream metrics from all metric namespaces in the account, except for the namespaces that you list in
ExcludeFilters.Stream metrics from only the metric namespaces that you list in
IncludeFilters. When you create a metric stream, the stream is created in therunningstate. If you update an existing metric stream, the state does not change.