-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Error creating "aws_cloudwatch_event_rule" while using Partner Event Sources - id format doesn't match #30293
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
I am facing the same problem while trying to integrate with │ Error: reading EventBridge Rule (arn:aws:events:eu-west-1:{account-id}:event-bus/aws.partner/genesys.com/cloud/{random-id}/{id-2}/genesys-eb-integration-target-rule): unexpected format for ID (arn:aws:events:eu-west-1:{account-id}:event-bus/aws.partner/genesys.com/cloud/{random-id}/{id-2}/genesys-eb-integration-target-rule), expected EVENTBUSNAME/RULENAME or RULENAME And my TF looks like this: # Genesys EventBridge Integration Source
data "aws_cloudwatch_event_source" "genesys_eb_integration_bus" {
name_prefix = "aws.partner/genesys.com"
}
# Genesys EventBridge Integration Event Bus
resource "aws_cloudwatch_event_bus" "genesys_eb_integration_bus" {
name = data.aws_cloudwatch_event_source.genesys_eb_integration_bus.name
event_source_name = data.aws_cloudwatch_event_source.genesys_eb_integration_bus.name
}
# Genesys EventBridge Integration Target SQS + DLQ
resource "aws_sqs_queue" "genesys_eb_integration_target_sqs" {
name = "genesys-eb-integration-target-sqs"
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue#message_retention_seconds
message_retention_seconds = 1209600 # 14 days
redrive_policy = jsonencode({
deadLetterTargetArn = aws_sqs_queue.genesys_eb_integration_target_sqs_dlq.arn
maxReceiveCount = 4
})
}
resource "aws_sqs_queue" "genesys_eb_integration_target_sqs_dlq" {
name = "genesys-eb-integration-target-sqs-dlq"
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue#message_retention_seconds
message_retention_seconds = 1209600 # 14 days
}
resource "aws_sqs_queue_redrive_allow_policy" "genesys_eb_integration_target_sqs_dlq" {
queue_url = aws_sqs_queue.genesys_eb_integration_target_sqs_dlq.id
redrive_allow_policy = jsonencode({
redrivePermission = "byQueue",
sourceQueueArns = [aws_sqs_queue.genesys_eb_integration_target_sqs.arn]
})
}
# Genesys EventBridge Integration Rule (push to target)
resource "aws_cloudwatch_event_rule" "genesys_eb_integration_target_rule" {
name = "genesys-eb-integration-target-rule"
event_bus_name = aws_cloudwatch_event_bus.genesys_eb_integration_bus.name
event_pattern = jsonencode({
source = [
{
"prefix" = "aws.partner/genesys.com"
}
]
})
}
# Genesys EventBridge Integration Rule Target + Rule Target DLQ
resource "aws_sqs_queue" "genesys_eb_integration_rule_target_dlq" {
name = "genesys-eb-integration-rule-target-dlq"
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue#message_retention_seconds
message_retention_seconds = 1209600 # 14 days
}
resource "aws_cloudwatch_event_target" "genesys_eb_integration_target" {
rule = aws_cloudwatch_event_rule.genesys_eb_integration_target_rule.name
arn = aws_sqs_queue.genesys_eb_integration_target_sqs.arn
dead_letter_config {
arn = aws_sqs_queue.genesys_eb_integration_rule_target_dlq.arn
}
} I am using provider version |
@alexandra-boca my PR fixes this issue. Once it gets approved and merged in it should hopefully help you get everything sorted. If you are however in a pinch and wanna solve your problem sooner, then you could clone my branch locally and follow the guidelines on how to do I was personally facing some trouble when trying to use it since at work we had the After running I was able to finally finish the work I was doing and it also meant that I not longer go the error you and I faced. |
* fix(events): fix arn based partner evernt bus id parse bug fixes #30293 * chore(changelog): add changelog for PR * test: add linting ignore to test to prevent providerlint failing * chore: correction in changelog file * r/aws_event_target(test): arn based partner event bus import test case --------- Co-authored-by: Jared Baker <jared.baker@hashicorp.com>
This functionality has been released in v5.13.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Core Version
0.13.5, 0.14.0
AWS Provider Version
4.0.0
Affected Resource(s)
Expected Behavior
Expected behaviour is that the EventBridge rule is created and all validations pass. While the rule does get created, it can't be used since a check fails due to an incorrect format.
Actual Behavior
Resource is created however it fails when the state is checked (terraform plan/apply).
Relevant Error/Panic Output Snippet
Error: unexpected format for ID (arn:aws:events:eu-west-1:test-id:event-bus/aws.partner/salesforce.com/id1/id2/crm-sync-create-account-rule-terraform-test), expected EVENTBUSNAME/RULENAME or RULENAME
Terraform Configuration Files
resource "aws_cloudwatch_event_rule" "event-bridge-rule" {
name = "event-bridge-rule"
description = "Testing creation of rules with Terraform"
event_bus_name = data.aws_cloudwatch_event_bus.my-bus.name
event_pattern = jsonencode({
"source": [{
"prefix": "aws.partner/salesforce.com"
}],
"detail-type": ["AccountChangeEvent"],
"detail": {
"payload": {
"ChangeEventHeader": {
"changeType": ["CREATE"]
}
}
}
})
}
Steps to Reproduce
terraform plan /
terraform apply
Both show the same error.
Debug Output
No response
Panic Output
No response
Important Factoids
I already researched the cause of why this happened and I got to the "aws/internal/service/events/id.go" file which contains a function called "RuleParseResourceID".
A split of the rule name is done based on "/" and in my case the code will enter the 3rd "if" statement (if len(parts) > 2 ).
The event bus name that I have is under the following format: "arn:aws:events:eu-west-1:test-id:event-bus/aws.partner/salesforce.com/id1/id2"
The "id" that gets passed to the function is under the following format:
"arn:aws:events:eu-west-1:test-id:event-bus/aws.partner/salesforce.com/id1/id2/test-rule-name"
I think the problem consists in our partner event bus name containing multiple "/". This makes the check of the "eventBusName" against the "eventBusARNPattern" regexp to fail causing the error to appear. I don't have the option to change the event bus name, it's created automatically.
References
I found a very smilar issue - same resource, same error, same file and function causing the error- however it seems in my case it's still something different caused by a mismatch with the regular expression.
#18431
Would you like to implement a fix?
No
The text was updated successfully, but these errors were encountered: