Skip to content

Commit

Permalink
feat: Added create before destroy on aws_lambda_permission (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinnko authored May 3, 2024
1 parent 2e3dc95 commit e9c4676
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,17 @@ resource "aws_lambda_permission" "current_version_triggers" {
function_name = aws_lambda_function.this[0].function_name
qualifier = aws_lambda_function.this[0].version

statement_id = try(each.value.statement_id, each.key)
action = try(each.value.action, "lambda:InvokeFunction")
principal = try(each.value.principal, format("%s.amazonaws.com", try(each.value.service, "")))
principal_org_id = try(each.value.principal_org_id, null)
source_arn = try(each.value.source_arn, null)
source_account = try(each.value.source_account, null)
event_source_token = try(each.value.event_source_token, null)
statement_id_prefix = try(each.value.statement_id, each.key)
action = try(each.value.action, "lambda:InvokeFunction")
principal = try(each.value.principal, format("%s.amazonaws.com", try(each.value.service, "")))
principal_org_id = try(each.value.principal_org_id, null)
source_arn = try(each.value.source_arn, null)
source_account = try(each.value.source_account, null)
event_source_token = try(each.value.event_source_token, null)

lifecycle {
create_before_destroy = true
}
}

# Error: Error adding new Lambda Permission for lambda: InvalidParameterValueException: We currently do not support adding policies for $LATEST.
Expand All @@ -288,13 +292,17 @@ resource "aws_lambda_permission" "unqualified_alias_triggers" {

function_name = aws_lambda_function.this[0].function_name

statement_id = try(each.value.statement_id, each.key)
action = try(each.value.action, "lambda:InvokeFunction")
principal = try(each.value.principal, format("%s.amazonaws.com", try(each.value.service, "")))
principal_org_id = try(each.value.principal_org_id, null)
source_arn = try(each.value.source_arn, null)
source_account = try(each.value.source_account, null)
event_source_token = try(each.value.event_source_token, null)
statement_id_prefix = try(each.value.statement_id, each.key)
action = try(each.value.action, "lambda:InvokeFunction")
principal = try(each.value.principal, format("%s.amazonaws.com", try(each.value.service, "")))
principal_org_id = try(each.value.principal_org_id, null)
source_arn = try(each.value.source_arn, null)
source_account = try(each.value.source_account, null)
event_source_token = try(each.value.event_source_token, null)

lifecycle {
create_before_destroy = true
}
}

resource "aws_lambda_event_source_mapping" "this" {
Expand Down

0 comments on commit e9c4676

Please sign in to comment.