Skip to content

Commit d481c67

Browse files
committed
Added region variable
1 parent de1244f commit d481c67

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ No modules.
523523
| <a name="input_policy_jsons"></a> [policy\_jsons](#input\_policy\_jsons) | List of additional policy documents as JSON to attach to IAM role | `list(string)` | `[]` | no |
524524
| <a name="input_policy_path"></a> [policy\_path](#input\_policy\_path) | Path of IAM policy to use for EventBridge | `string` | `null` | no |
525525
| <a name="input_policy_statements"></a> [policy\_statements](#input\_policy\_statements) | Map of dynamic policy statements to attach to IAM role | `any` | `{}` | no |
526+
| <a name="input_region"></a> [region](#input\_region) | Region where the resource(s) will be managed. Defaults to the region set in the provider configuration | `string` | `null` | no |
526527
| <a name="input_role_description"></a> [role\_description](#input\_role\_description) | Description of IAM role to use for EventBridge | `string` | `null` | no |
527528
| <a name="input_role_force_detach_policies"></a> [role\_force\_detach\_policies](#input\_role\_force\_detach\_policies) | Specifies to force detaching any policies the IAM role has before destroying it. | `bool` | `true` | no |
528529
| <a name="input_role_name"></a> [role\_name](#input\_role\_name) | Name of IAM role to use for EventBridge | `string` | `null` | no |

main.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ data "aws_cloudwatch_event_bus" "this" {
6464
resource "aws_cloudwatch_event_bus" "this" {
6565
count = var.create && var.create_bus ? 1 : 0
6666

67+
region = var.region
68+
6769
name = var.bus_name
6870
description = var.bus_description
6971
event_source_name = var.event_source_name
@@ -82,6 +84,8 @@ resource "aws_cloudwatch_event_bus" "this" {
8284
resource "aws_schemas_discoverer" "this" {
8385
count = var.create && var.create_schemas_discoverer ? 1 : 0
8486

87+
region = var.region
88+
8589
source_arn = var.create_bus ? aws_cloudwatch_event_bus.this[0].arn : data.aws_cloudwatch_event_bus.this[0].arn
8690
description = var.schemas_discoverer_description
8791

@@ -91,6 +95,8 @@ resource "aws_schemas_discoverer" "this" {
9195
resource "aws_cloudwatch_event_rule" "this" {
9296
for_each = { for k, v in local.eventbridge_rules : v.name => v if var.create && var.create_rules }
9397

98+
region = var.region
99+
94100
name = each.value.Name
95101
name_prefix = lookup(each.value, "name_prefix", null)
96102

@@ -111,6 +117,8 @@ resource "aws_cloudwatch_event_rule" "this" {
111117
resource "aws_cloudwatch_event_target" "this" {
112118
for_each = { for k, v in local.eventbridge_targets : v.name => v if var.create && var.create_targets }
113119

120+
region = var.region
121+
114122
event_bus_name = var.create_bus ? aws_cloudwatch_event_bus.this[0].name : var.bus_name
115123

116124
rule = each.value.Name
@@ -274,6 +282,8 @@ resource "aws_cloudwatch_event_target" "this" {
274282
resource "aws_cloudwatch_event_archive" "this" {
275283
for_each = var.create && var.create_archives ? var.archives : {}
276284

285+
region = var.region
286+
277287
name = lookup(each.value, "name", each.key)
278288
event_source_arn = try(each.value["event_source_arn"], aws_cloudwatch_event_bus.this[0].arn)
279289

@@ -285,6 +295,8 @@ resource "aws_cloudwatch_event_archive" "this" {
285295
resource "aws_cloudwatch_event_permission" "this" {
286296
for_each = var.create && var.create_permissions ? var.permissions : {}
287297

298+
region = var.region
299+
288300
principal = compact(split(" ", each.key))[0]
289301
statement_id = compact(split(" ", each.key))[1]
290302

@@ -305,6 +317,8 @@ resource "aws_cloudwatch_event_permission" "this" {
305317
resource "aws_cloudwatch_event_connection" "this" {
306318
for_each = { for k, v in local.eventbridge_connections : v.name => v if var.create && var.create_connections }
307319

320+
region = var.region
321+
308322
name = each.value.Name
309323
description = lookup(each.value, "description", null)
310324
authorization_type = each.value.authorization_type
@@ -448,6 +462,8 @@ resource "aws_cloudwatch_event_connection" "this" {
448462
resource "aws_cloudwatch_event_api_destination" "this" {
449463
for_each = { for k, v in local.eventbridge_api_destinations : v.name => v if var.create && var.create_api_destinations }
450464

465+
region = var.region
466+
451467
name = each.value.Name
452468
description = lookup(each.value, "description", null)
453469
invocation_endpoint = each.value.invocation_endpoint
@@ -459,6 +475,8 @@ resource "aws_cloudwatch_event_api_destination" "this" {
459475
resource "aws_scheduler_schedule_group" "this" {
460476
for_each = { for k, v in local.eventbridge_schedule_groups : k => v if var.create && var.create_schedule_groups }
461477

478+
region = var.region
479+
462480
name = lookup(each.value, "name_prefix", null) == null ? try(each.value.name, each.key) : null
463481
name_prefix = lookup(each.value, "name_prefix", null) != null ? each.value.name_prefix : null
464482

@@ -477,6 +495,8 @@ resource "aws_scheduler_schedule_group" "this" {
477495
resource "aws_scheduler_schedule" "this" {
478496
for_each = { for k, v in local.eventbridge_schedules : v.name => v if var.create && var.create_schedules }
479497

498+
region = var.region
499+
480500
name = each.value.Name
481501
name_prefix = lookup(each.value, "name_prefix", null)
482502
description = lookup(each.value, "description", null)
@@ -638,6 +658,8 @@ resource "aws_scheduler_schedule" "this" {
638658
resource "aws_pipes_pipe" "this" {
639659
for_each = { for k, v in local.eventbridge_pipes : v.name => v if local.create_pipes }
640660

661+
region = var.region
662+
641663
name = each.value.Name
642664

643665
role_arn = try(each.value.role_arn, aws_iam_role.eventbridge_pipe[each.key].arn)

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ variable "create_pipes" {
120120

121121
#######################
122122

123+
variable "region" {
124+
description = "Region where the resource(s) will be managed. Defaults to the region set in the provider configuration"
125+
type = string
126+
default = null
127+
}
128+
123129
variable "bus_name" {
124130
description = "A unique name for your EventBridge Bus"
125131
type = string

0 commit comments

Comments
 (0)