Skip to content

Commit cb3ec5e

Browse files
author
Max Rabin
committed
Add Region parameter to Notification module
1 parent cdf595d commit cb3ec5e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

modules/notification/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ No modules.
3939
|------|-------------|------|---------|:--------:|
4040
| <a name="input_bucket"></a> [bucket](#input\_bucket) | Name of S3 bucket to use | `string` | `""` | no |
4141
| <a name="input_bucket_arn"></a> [bucket\_arn](#input\_bucket\_arn) | ARN of S3 bucket to use in policies | `string` | `null` | no |
42+
| <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 |
4243
| <a name="input_create"></a> [create](#input\_create) | Whether to create this resource or not? | `bool` | `true` | no |
4344
| <a name="input_create_lambda_permission"></a> [create\_lambda\_permission](#input\_create\_lambda\_permission) | Whether to create Lambda permissions or not? | `bool` | `true` | no |
4445
| <a name="input_create_sns_policy"></a> [create\_sns\_policy](#input\_create\_sns\_policy) | Whether to create a policy for SNS permissions or not? | `bool` | `true` | no |

modules/notification/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ resource "aws_s3_bucket_notification" "this" {
1313

1414
bucket = var.bucket
1515

16+
region = var.region
17+
1618
eventbridge = var.eventbridge
1719

1820
dynamic "lambda_function" {
@@ -62,6 +64,8 @@ resource "aws_s3_bucket_notification" "this" {
6264
resource "aws_lambda_permission" "allow" {
6365
for_each = { for k, v in var.lambda_notifications : k => v if var.create_lambda_permission }
6466

67+
region = var.region
68+
6569
statement_id_prefix = "AllowLambdaS3BucketNotification-"
6670
action = "lambda:InvokeFunction"
6771
function_name = each.value.function_name
@@ -110,6 +114,8 @@ data "aws_iam_policy_document" "sqs" {
110114
resource "aws_sqs_queue_policy" "allow" {
111115
for_each = { for k, v in var.sqs_notifications : k => v if var.create_sqs_policy }
112116

117+
region = var.region
118+
113119
queue_url = try(each.value.queue_id, local.queue_ids[each.key], null)
114120
policy = data.aws_iam_policy_document.sqs[each.key].json
115121
}
@@ -145,6 +151,8 @@ data "aws_iam_policy_document" "sns" {
145151
resource "aws_sns_topic_policy" "allow" {
146152
for_each = { for k, v in var.sns_notifications : k => v if var.create_sns_policy }
147153

154+
region = var.region
155+
148156
arn = each.value.topic_arn
149157
policy = data.aws_iam_policy_document.sns[each.key].json
150158
}

modules/notification/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ variable "create_lambda_permission" {
2222
default = true
2323
}
2424

25+
variable "region" {
26+
description = "Region where the resource(s) will be managed. Defaults to the region set in the provider configuration"
27+
type = string
28+
default = null
29+
}
30+
2531
variable "bucket" {
2632
description = "Name of S3 bucket to use"
2733
type = string

0 commit comments

Comments
 (0)