Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
I am trying to setup an event bus with aaws_cloudwatch_event_target
with arn pointing to a aws_cloudwatch_event_api_destination
, i.e. with terraform code below. However once it is setup when I try to test it I get this error below which seems to be a bug where EventBridge connection is not found for the api destination. It might be that one of the two errors below are red herrings but it's not clear exactly what is wrong. I have independently verified that both the connection and API destinations are created so it doesn't seem like a setup issue.
So errors that in localstack I see:
[et.reactor-1] l.p.c.utils.aws.aws_utils : Unable to find EventBridge connection '0da25665-24fd-4bd2-b0a3-104c7054e25a' for API destination arn:aws:events:eu-west-2:000000000000:api-destination/slack-api-destination/41efb93e-d125-4cf8-86a6-6ef7afb54342
[et.reactor-1] l.s.events.v1.provider : Unable to send event notification {'version': '0', 'id': '6faaf14a-f669-4fca-85aa-0dce63893127', 'detail-type': 'AuditedAction', 'sour... to target {'RuleArn': 'arn:aws:events:eu-west-2:000000000000:rule/audit-localstack/audit-localstack-trigger-slack', 'Id': 'slack-notification', 'Arn': 'arn:aws:events:eu-west-2:000000000000:api-destination/slack-api-destination/41efb93e-d125-4cf8-86a6-6ef7afb54342', 'RoleArn': 'arn:aws:iam::000000000000:role/audit-localstack-eventbridge-target-role', 'InputTransformer': {'InputPathsMap': {}, 'InputTemplate': '{"channel":"sam-test"}'}}: tuple index out of range
test method:
$ cat putevents.json
[
{
"Detail": "{\"action\":\"xxxx\",\"event\":\"Hello world\"\"}",
"DetailType": "AuditedAction",
"EventBusName": "audit-localstack",
"Source": "super"
}
]
$ awslocal events put-events --entries file://putevents.json --endpoint-url http://localhost:4566
set up code:
module "audit_event_bus" {
source = "terraform-aws-modules/eventbridge/aws"
bus_name = local.audit_namespace
archives = {
(local.audit_namespace) = {
retention_days = var.audit_event_retention_days
}
}
create_bus = true
create_rules = false
create_targets = false
}
# Using BASIC auth with dummy values as the webhook URL is self-authenticating
resource "aws_cloudwatch_event_connection" "slack" {
name = "slack-connection"
authorization_type = "BASIC"
auth_parameters {
basic {
username = "dummy" # Required by AWS but not used
password = "dummy" # Required by AWS but not used
}
}
}
resource "aws_cloudwatch_event_rule" "audit_slack" {
event_bus_name = module.audit_event_bus.eventbridge_bus_name
name = "${local.audit_namespace}-trigger-slack"
event_pattern = jsonencode({
"detail-type" = ["AuditedAction"]
detail = {
action = ["BUSINESS_DIRECTOR_UPDATE"]
}
})
}
resource "aws_cloudwatch_event_api_destination" "audit_slack" {
name = "slack-api-destination"
description = "Slack API Destination"
invocation_endpoint = "https://example.com"
http_method = "POST"
invocation_rate_limit_per_second = 20
connection_arn = aws_cloudwatch_event_connection.slack.arn
}
resource "aws_cloudwatch_event_target" "audit_slack" {
event_bus_name = module.audit_event_bus.eventbridge_bus_name
rule = aws_cloudwatch_event_rule.audit_slack.name
arn = aws_cloudwatch_event_api_destination.audit_slack.arn
role_arn = aws_iam_role.eventbridge_target_role.arn
target_id = "slack-notification"
input_transformer {
input_paths = {
text = "$.detail.event"
}
input_template = <<EOF
{
"channel": "test",
"text": "<text>"
}
EOF
}
dead_letter_config {
arn = aws_sqs_queue.merchant_deadletter.arn
}
}
Expected Behavior
The message should be put on the event bus successfully
How are you starting LocalStack?
With a docker-compose file
Steps To Reproduce
How are you starting localstack (e.g., bin/localstack
command, arguments, or docker-compose.yml
)
docker-compose:
localstack:
image: localstack/localstack-pro:3
ports:
- "4566:4566"
environment:
DEBUG: 1
LS_LOG: trace
EAGER_SERVICE_LOADING: 0
LOCALSTACK_HOST: "localhost:4566"
LOCALSTACK_AUTH_TOKEN: ${LOCALSTACK_AUTH_TOKEN_FROM_SETUP:-}
LOCALSTACK_API_KEY: ${LOCALSTACK_API_KEY?required for cognito}
Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
(test file in main ticket description)
awslocal events put-events --entries file://putevents.json --endpoint-url http://localhost:4566
Environment
- OS:
ProductName: macOS
ProductVersion: 15.2
BuildVersion: 24C101
- LocalStack:
LocalStack version: localstack-pro:3
LocalStack Docker image sha: 15e326a5879d32dd7bad44c29206900cc0403d7bef815b6911e45ae367ab0239
Anything else?
No response