Skip to content

Commit 5603ad8

Browse files
committed
add support for apigw identifier change
1 parent 1c07595 commit 5603ad8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

data.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ data "aws_iam_policy_document" "update_lambda" {
2323
sid = "LambdaUpdateEvent"
2424

2525
actions = [
26+
"lambda:AddPermission",
2627
"lambda:UpdateFunctionCode",
2728
"lambda:UpdateFunctionConfiguration",
2829
"lambda:UpdateAlias",
@@ -33,6 +34,20 @@ data "aws_iam_policy_document" "update_lambda" {
3334
]
3435
resources = ["arn:aws:lambda:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:function:${var.function_prefix}*"]
3536
}
37+
38+
dynamic "statement" {
39+
for_each = var.enable_version_identifier ? [1] : []
40+
content {
41+
sid = "AllowApiGatewayInvoke"
42+
actions = [
43+
"apigateway:POST",
44+
"apigateway:PUT",
45+
]
46+
resources = [
47+
var.apigw_arn,
48+
]
49+
}
50+
}
3651
}
3752

3853
data "aws_iam_policy_document" "update_lambda_combined" {

variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,16 @@ variable "function_tags" {
457457
type = map(string)
458458
default = {}
459459
}
460+
461+
# to allow deployments with api gateway triggers and update version whenever there is new deployment
462+
variable "enable_version_identifier" {
463+
description = "Enable version identifier for lambda function"
464+
type = bool
465+
default = false
466+
}
467+
468+
variable "apigw_arn" {
469+
description = "API Gateway ARN"
470+
type = string
471+
default = null
472+
}

0 commit comments

Comments
 (0)