# aws_cloudwatch_event_rule.this will be created
+ resource "aws_cloudwatch_event_rule" "this" {
+ arn = (known after apply)
+ description = "MediaLive Events"
+ event_bus_name = "default"
+ event_pattern = "\"{\\\"source\\\":[\\\"aws.medialive\\\"]}\""
+ force_destroy = false
+ id = (known after apply)
+ is_enabled = true
+ name = "medialive-events"
+ name_prefix = (known after apply)
+ tags_all = (known after apply)
}
When i run apply it can't apply string in place of json object.
│ Error: creating EventBridge Rule (medialive-events): operation error EventBridge: PutRule, https response error StatusCode: 400, RequestID: 4c39b1c1-f975-41ff-96fb-b436068e280b, InvalidEventPatternException: Event pattern is not valid. Reason: Filter is not an object
│ at [Source: (String)""{\"source\":[\"aws.medialive\"]}""; line: 1, column: 2]
Expected Behavior
Manipulating with jsonencode function gave no result until i added variable type = any as listed below
# aws_cloudwatch_event_rule.this will be created
+ resource "aws_cloudwatch_event_rule" "this" {
+ arn = (known after apply)
+ description = "prd MediaLive Events"
+ event_bus_name = "default"
+ event_pattern = jsonencode(
{
+ source = [
+ "aws.medialive",
]
}
)
+ force_destroy = false
+ id = (known after apply)
+ name = "prd-medialive-events"
+ name_prefix = (known after apply)
+ state = "ENABLED"
+ tags_all = (known after apply)
}
Steps to Reproduce
FIX:
variable "cloudwatch_event_rule_pattern" {
description = "Event pattern described a HCL map which will be encoded as JSON with jsonencode function. See full documentation of CloudWatch Events and Event Patterns for details. http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CloudWatchEventsandEventPatterns.html"
type = any
}
Type any allow terraform to dynamically use any incoming type. If it's not provided, default is string.
Describe the Bug
i'm defining event patter:
when i run plan:
When i run apply it can't apply string in place of json object.
Expected Behavior
Manipulating with jsonencode function gave no result until i added variable type = any as listed below
Steps to Reproduce
FIX:
Type
any
allow terraform to dynamically use any incoming type. If it's not provided, default is string.Screenshots
No response
Environment
No response
Additional Context
No response