Skip to content

Commit 2cd71c5

Browse files
author
João Taveira Araújo
committed
feat(s3_bucket_subscription): allow enabling eventbridge
1 parent 8eb08fd commit 2cd71c5

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ No modules.
6868
|------|-------------|------|---------|:--------:|
6969
| <a name="input_dead_letter_queue_destination"></a> [dead\_letter\_queue\_destination](#input\_dead\_letter\_queue\_destination) | Send failed events/function executions to a dead letter queue arn sns or sqs | `string` | `null` | no |
7070
| <a name="input_description"></a> [description](#input\_description) | Lambda description | `string` | `"Lambda function to forward events towards Observe"` | no |
71+
| <a name="input_enable_eventbridge"></a> [enable\_eventbridge](#input\_enable\_eventbridge) | Enable sending bucket notifications to EventBridge | `bool` | `false` | no |
7172
| <a name="input_iam_name_prefix"></a> [iam\_name\_prefix](#input\_iam\_name\_prefix) | Prefix used for all created IAM roles and policies | `string` | `"observe-lambda-"` | no |
7273
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | The ARN of the AWS Key Management Service (AWS KMS) key that's used to encrypt your function's environment variables.<br>If it's not provided, AWS Lambda uses a default service key. | `string` | `""` | no |
7374
| <a name="input_lambda_envvars"></a> [lambda\_envvars](#input\_lambda\_envvars) | Environment variables | `map(any)` | `{}` | no |

modules/s3_bucket_subscription/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ module "observe_lambda_s3_subscription" {
3333
| Name | Version |
3434
|------|---------|
3535
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.1.0 |
36-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.68 |
36+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
3737

3838
## Providers
3939

4040
| Name | Version |
4141
|------|---------|
42-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 2.68 |
42+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0 |
4343

4444
## Modules
4545

@@ -60,6 +60,7 @@ No modules.
6060
| Name | Description | Type | Default | Required |
6161
|------|-------------|------|---------|:--------:|
6262
| <a name="input_bucket_arns"></a> [bucket\_arns](#input\_bucket\_arns) | S3 bucket ARNs to subscribe to Observe Lambda | `list(string)` | `[]` | no |
63+
| <a name="input_enable_eventbridge"></a> [enable\_eventbridge](#input\_enable\_eventbridge) | Enable sending bucket notifications to EventBridge | `bool` | `false` | no |
6364
| <a name="input_filter_prefix"></a> [filter\_prefix](#input\_filter\_prefix) | Specifies object key name prefix on S3 bucket notifications. | `string` | `""` | no |
6465
| <a name="input_filter_suffix"></a> [filter\_suffix](#input\_filter\_suffix) | Specifies object key name suffix on S3 bucket notifications. | `string` | `""` | no |
6566
| <a name="input_iam_name_prefix"></a> [iam\_name\_prefix](#input\_iam\_name\_prefix) | Prefix used for all created IAM roles and policies | `string` | `"observe-lambda-"` | no |

modules/s3_bucket_subscription/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ resource "aws_lambda_permission" "allow_bucket" {
1818
}
1919

2020
resource "aws_s3_bucket_notification" "notification" {
21-
count = length(aws_lambda_permission.allow_bucket)
22-
bucket = data.aws_arn.bucket[count.index].resource
21+
count = length(aws_lambda_permission.allow_bucket)
22+
bucket = data.aws_arn.bucket[count.index].resource
23+
eventbridge = var.enable_eventbridge
2324
lambda_function {
2425
lambda_function_arn = aws_lambda_permission.allow_bucket[count.index].function_name
2526
events = ["s3:ObjectCreated:*"]
2627
filter_prefix = var.filter_prefix
2728
filter_suffix = var.filter_suffix
2829
}
30+
2931
}
3032

3133
resource "aws_iam_policy" "s3_bucket_read" {

modules/s3_bucket_subscription/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,10 @@ variable "statement_id_prefix" {
4040
nullable = false
4141
default = ""
4242
}
43+
44+
variable "enable_eventbridge" {
45+
description = "Enable sending bucket notifications to EventBridge"
46+
type = bool
47+
nullable = false
48+
default = false
49+
}

modules/s3_bucket_subscription/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 2.68"
7+
version = ">= 4.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)