Skip to content

Commit 9002bd3

Browse files
authored
Use statement prefix IDs for lambda permissions (#37)
* Use statement prefix IDs for lambda permissions * Make statement ID prefix optional
1 parent 26235ed commit 9002bd3

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

terraform/modules/team/main.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ resource "aws_cloudwatch_event_target" "main" {
1515
}
1616

1717
resource "aws_lambda_permission" "main" {
18-
statement_id = "concourse-${var.name}-github-lambda-permission"
19-
action = "lambda:InvokeFunction"
20-
function_name = var.lambda_arn
21-
principal = "events.amazonaws.com"
22-
source_arn = aws_cloudwatch_event_rule.main.arn
18+
statement_id = var.use_statement_id_prefix ? null : "concourse-${var.name}-github-lambda-permission"
19+
statement_id_prefix = var.use_statement_id_prefix ? "concourse-${var.name}-github-lambda-permission-" : null
20+
action = "lambda:InvokeFunction"
21+
function_name = var.lambda_arn
22+
principal = "events.amazonaws.com"
23+
source_arn = aws_cloudwatch_event_rule.main.arn
2324
}
2425

2526
locals {

terraform/modules/team/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ variable "name" {
66
type = string
77
}
88

9+
variable "use_statement_id_prefix" {
10+
description = "If the name is used as a prefix to a randomised name or not"
11+
type = bool
12+
default = false
13+
}
14+
915
variable "lambda_arn" {
1016
description = "ARN of the Github Lambda."
1117
type = string

0 commit comments

Comments
 (0)