Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a custom Event Bus in AWS Event Bridge?

I can't find the documentation or an example Terraform module online.

How do I create a custom Event Bus in AWS Event Bridge?

like image 618
Madhav Shenoy Avatar asked Dec 17 '22 13:12

Madhav Shenoy


1 Answers

As of this writing, creating an EventBridge Event Bus isn't supported by the Terraform Provider for AWS yet.

We had to use the default Event Bus or create it with the AWS CLI or Console.

Caveats: EventBridge has a couple of serious IAM gaps right now: you can't restrict what buses an IAM principal can publish events too and it uses a Service principal instead of a Service Linked Role principal to access things like KMS keys used to encrypt the buses.

You can use a null_resource provisioner as a workaround for the missing provider resource (this assumes you are using environment variables or an IAM instance profile to authenticate your AWS provider):

resource "null_resource" "custom_event_bus" {
  triggers = {
    event_bus_name = var.event_bus_name
  }

  provisioner "local-exec" {
    command = "aws events create-event-bus --name ${var.event_bus_name}'"
  }
}

If you are using a named AWS configuration profile instead of environment variables, you'll need to specify that with --profile profile_name the same as you would if you ran it at your shell.

like image 93
Alain O'Dea Avatar answered Jan 11 '23 23:01

Alain O'Dea