'How I can add event_api_destination to cloudwatch rule in AWS?
How can i add resource aws_cloudwatch_event_api_destination and aws_cloudwatch_event_connection to resource aws_cloudwatch_event_rule in terraform?
This Code in below
resource "aws_cloudwatch_event_rule" "test123_schedule_everyday" {
name = "${var.test123_bucket_name}-schedule-everyday-${var.env}"
description = "Meter reader get api data every 11:00 PM at lotus"
schedule_expression = "cron(0 16 * * ? *)"
is_enabled = "${var.test123_cloudwatch_is_enable}"
lifecycle {
ignore_changes = [schedule_expression, description, is_enabled]
}
}
resource "aws_cloudwatch_event_api_destination" "test123_event_api" {
name = "test-dev-api"
description = "test-dev-api destination"
invocation_endpoint = "https://test.com"
invocation_rate_limit_per_second = "1"
http_method = "GET"
connection_arn = aws_cloudwatch_event_connection.test123_event_connection.arn
}
resource "aws_cloudwatch_event_connection" "test123_event_connection" {
name = "test-dev-connection"
description = "A connection description"
authorization_type = "API_KEY"
auth_parameters {
api_key {
key = "test-key"
value = "TUVURVJSRUFESU5HOkNCWktXWFU3NzZDS0dGTk5LNjdGWUFVNFFRNE1HV0o3"
}
}
}
Solution 1:[1]
I believe what you seek is an aws_cloudwatch_event_target. This allows you to specify your destination as a target for a given rule, as documented in the official API destinations documentation.
resource "aws_cloudwatch_event_target" "this" {
rule = aws_cloudwatch_event_rule.test123_schedule_everyday.name
arn = aws_cloudwatch_event_api_destination.test123_event_api.arn
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | theherk |
