Skip to content
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]: aws_cloudwatch_event_target Cross-Region #31444

Open
pixie79 opened this issue May 17, 2023 · 1 comment
Open

[Bug]: aws_cloudwatch_event_target Cross-Region #31444

pixie79 opened this issue May 17, 2023 · 1 comment
Labels
bug Addresses a defect in current functionality. service/events Issues and PRs that pertain to the events service.

Comments

@pixie79
Copy link
Contributor

pixie79 commented May 17, 2023

Terraform Core Version

1.3.9

AWS Provider Version

4.67.0

Affected Resource(s)

aws_cloudwatch_event_target

Expected Behavior

I should be able to replicate events from a bus in one region to a bus in another using the bus ARN as a target

Actual Behavior

creating EventBridge Target (arn:aws:events:af-south-1::event-bus/ ): ValidationException: Cross-region api call is not allowed.

This was allowed when I added the target manually via the console.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

data "aws_iam_policy_document" "assume_role_policy" {
  statement {
    effect = "Allow"
    principals {
      type        = "Service"
      identifiers = ["events.amazonaws.com"]
    }
    actions = ["sts:AssumeRole"]
  }
  provider = aws.ireland
}

data "aws_iam_policy_document" "event_bus_invoke_remote_event_bus" {
  statement {
    effect    = "Allow"
    actions   = ["events:PutEvents"]
    resources = [module.salesforce.eventhub_bus_arn]
  }
  provider = aws.ireland
}

resource "aws_cloudwatch_event_rule" "eu_af" {
  name           = local.salesforce_name
  description    = "Sync bus to SF Region"
  event_bus_name = var.eu_eventbus_name
  event_pattern = jsonencode({
    source = [
      var.eu_eventbus_name
    ]
  })
  provider = aws.ireland
}

resource "aws_iam_role" "cross_account_sync" {
  name               = "${local.name}-service"
  assume_role_policy = data.aws_iam_policy_document.assume_role_policy.json
  inline_policy {
    name   = "policy-allow-events"
    policy = data.aws_iam_policy_document.event_bus_invoke_remote_event_bus.json
  }
  provider = aws.ireland
}

resource "aws_cloudwatch_event_target" "eu_af" {
  rule           = aws_cloudwatch_event_rule.eu_af.name
  arn            = module.salesforce.eventhub_bus_arn
  role_arn       = aws_iam_role.cross_account_sync.arn
  provider       = aws.ireland
  event_bus_name = module.salesforce.eventhub_bus_arn
}

Steps to Reproduce

Try and attach a target to send events from an event bus in one region to an event bus in another via TF

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@pixie79 pixie79 added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels May 17, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/events Issues and PRs that pertain to the events service. service/iam Issues and PRs that pertain to the iam service. labels May 17, 2023
@justinretzolk justinretzolk removed service/iam Issues and PRs that pertain to the iam service. needs-triage Waiting for first response or review from a maintainer. labels May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/events Issues and PRs that pertain to the events service.
Projects
None yet
Development

No branches or pull requests

2 participants