Terraform lv 2 task 7

i have problem with this task Stream Kinesis Data to CloudWatch Using Terraform



this is the code:
provider “aws” { region = “us-east-1” }

resource “aws_kinesis_stream” “stream” {
name = “devops-kinesis-stream”
shard_count = 1
}

resource “aws_cloudwatch_metric_alarm” “alarm” {
alarm_name = “devops-kinesis-alarm”
namespace = “AWS/Kinesis”
metric_name = “WriteProvisionedThroughputExceeded”
statistic = “Sum”
period = 60
evaluation_periods = 1
threshold = 1
comparison_operator = “GreaterThanThreshold”
treat_missing_data = “notBreaching”
dimensions = { StreamName = aws_kinesis_stream.stream.name }
}
output “kke_kinesis_stream_name” {
value = aws_kinesis_stream.stream.name
}

output “kke_kinesis_alarm_name” {
value = aws_cloudwatch_metric_alarm.alarm.alarm_name
}

Dear Martoni,
I completed the task without any errors, please try once using the code snippet below. You may have forgotten to enable shared metrics.

resource “aws_kinesis_stream” “devops_stream” {
name = “devops-kinesis-stream”
shard_count = 1
retention_period = 24

shard_level_metrics = [
“IncomingBytes”,
“IncomingRecords”,
“OutgoingBytes”,
“OutgoingRecords”,
“WriteProvisionedThroughputExceeded”,
“ReadProvisionedThroughputExceeded”,
“IteratorAgeMilliseconds”,
]
}

resource “aws_cloudwatch_metric_alarm” “xfusion_kinesis_alarm” {
alarm_name = “xfusion-kinesis-alarm”
comparison_operator = “GreaterThanThreshold”
evaluation_periods = 1
metric_name = “WriteProvisionedThroughputExceeded”
namespace = “AWS/Kinesis”
period = 60
statistic = “Sum”
threshold = 1
alarm_description = “Alarm when write throughput exceeds provisioned limit”
dimensions = {
StreamName = aws_kinesis_stream.xfusion_stream.name
}
treat_missing_data = “notBreaching”
}
output “kke_kinesis_stream_name” {
description = “The name of the Kinesis stream”
value = aws_kinesis_stream.devops_stream.name
}

output “kke_kinesis_alarm_name” {
description = “The name of the CloudWatch alarm”
value = aws_cloudwatch_metric_alarm.devops_kinesis_alarm.alarm_name
}

Regards
Tamizh

1 Like