Skip to content

Commit a670d7a

Browse files
fix: use lambda arn instead of name
1 parent e847cac commit a670d7a

File tree

3 files changed

+7
-26
lines changed

3 files changed

+7
-26
lines changed

modules/integrations/github_webhook_relay_destination/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ No modules.
6666
| [aws_cloudwatch_event_target.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource |
6767
| [aws_iam_role.reader](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
6868
| [aws_iam_role_policy.allow_assume_external_inline](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
69-
| [aws_lambda_permission.allow_events](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
7069
| [aws_iam_policy_document.allow_assume_external](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
7170
| [aws_iam_policy_document.trust](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
72-
| [aws_lambda_function.receiver](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lambda_function) | data source |
7371
| [aws_secretsmanager_secret_version.target](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/secretsmanager_secret_version) | data source |
7472
| [external_external.reader_profile](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source |
7573

@@ -82,7 +80,7 @@ No modules.
8280
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | n/a | `map(string)` | n/a | yes |
8381
| <a name="input_reader_config"></a> [reader\_config](#input\_reader\_config) | Configuration for IAM role creation and secret retrieval | <pre>object({<br/> role_name = string<br/> role_trust_principals = list(string)<br/> source_secret_role_arn = string<br/> enable_secret_fetch = bool<br/> source_secret_arn = string<br/> source_secret_region = string<br/> })</pre> | <pre>{<br/> "enable_secret_fetch": false,<br/> "role_name": "github-webhook-relay-secret-reader",<br/> "role_trust_principals": [],<br/> "source_secret_arn": "",<br/> "source_secret_region": "",<br/> "source_secret_role_arn": ""<br/>}</pre> | no |
8482
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(string)` | `{}` | no |
85-
| <a name="input_webhook_relay_destination_config"></a> [webhook\_relay\_destination\_config](#input\_webhook\_relay\_destination\_config) | All configuration for the destination EventBridge relay | <pre>object({<br/> name_prefix = string<br/> destination_event_bus_name = string<br/> source_account_id = string<br/> targets = list(object({<br/> event_pattern = string<br/> lambda_function_name = string<br/> }))<br/> })</pre> | <pre>{<br/> "destination_event_bus_name": "webhook-relay-destination",<br/> "name_prefix": "webhook-relay-destination",<br/> "source_account_id": "",<br/> "targets": []<br/>}</pre> | no |
83+
| <a name="input_webhook_relay_destination_config"></a> [webhook\_relay\_destination\_config](#input\_webhook\_relay\_destination\_config) | All configuration for the destination EventBridge relay | <pre>object({<br/> name_prefix = string<br/> destination_event_bus_name = string<br/> source_account_id = string<br/> targets = list(object({<br/> event_pattern = string<br/> lambda_function_arn = string<br/> }))<br/> })</pre> | <pre>{<br/> "destination_event_bus_name": "webhook-relay-destination",<br/> "name_prefix": "webhook-relay-destination",<br/> "source_account_id": "",<br/> "targets": []<br/>}</pre> | no |
8684

8785
## Outputs
8886

modules/integrations/github_webhook_relay_destination/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ variable "webhook_relay_destination_config" {
4444
destination_event_bus_name = string
4545
source_account_id = string
4646
targets = list(object({
47-
event_pattern = string
48-
lambda_function_name = string
47+
event_pattern = string
48+
lambda_function_arn = string
4949
}))
5050
})
5151
default = {

modules/integrations/github_webhook_relay_destination/webhook_relay_destination.tf

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ resource "aws_cloudwatch_event_bus" "destination" {
44
include_detail = "NONE"
55
level = "OFF"
66
}
7-
tags = local.all_security_tags
8-
tags_all = local.all_security_tags
7+
tags = var.tags
98
}
109

1110
resource "aws_cloudwatch_event_bus_policy" "allow_source" {
@@ -26,8 +25,7 @@ resource "aws_cloudwatch_event_bus_policy" "allow_source" {
2625

2726
locals {
2827
targets_indexed = {
29-
for idx, t in var.webhook_relay_destination_config.targets :
30-
idx => t
28+
for idx, t in var.webhook_relay_destination_config.targets : idx => t
3129
}
3230
}
3331

@@ -37,27 +35,12 @@ resource "aws_cloudwatch_event_rule" "receive" {
3735
description = "Webhook relay target ${each.key}"
3836
event_bus_name = aws_cloudwatch_event_bus.destination.name
3937
event_pattern = each.value.event_pattern
40-
tags = local.all_security_tags
41-
tags_all = local.all_security_tags
42-
}
43-
44-
data "aws_lambda_function" "receiver" {
45-
for_each = local.targets_indexed
46-
function_name = each.value.lambda_function_name
38+
tags = var.tags
4739
}
4840

4941
resource "aws_cloudwatch_event_target" "lambda" {
5042
for_each = aws_cloudwatch_event_rule.receive
5143
rule = each.value.name
5244
event_bus_name = each.value.event_bus_name
53-
arn = data.aws_lambda_function.receiver[each.key].arn
54-
}
55-
56-
resource "aws_lambda_permission" "allow_events" {
57-
for_each = aws_cloudwatch_event_rule.receive
58-
statement_id = "AllowEventBridgeInvoke-${each.key}"
59-
action = "lambda:InvokeFunction"
60-
function_name = data.aws_lambda_function.receiver[each.key].function_name
61-
principal = "events.amazonaws.com"
62-
source_arn = each.value.arn
45+
arn = local.targets_indexed[each.key].lambda_function_arn
6346
}

0 commit comments

Comments
 (0)