Skip to content

Commit

Permalink
bug: fixes creating role when no role_arn is specified
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Wessels Beljaars <[email protected]>
  • Loading branch information
stefanwb committed Mar 7, 2024
1 parent db6d267 commit cde281f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
create_event_invoke_config = var.retries != null || var.destination_on_failure != null || var.destination_on_success != null ? { create : true } : {}
create_policy = var.create_policy != null ? var.create_policy : var.role_arn == null
create_policy = var.role_arn == null && (var.create_policy != null ? var.create_policy : true)
dead_letter_config = var.dead_letter_target_arn != null ? { create : true } : {}
environment = var.environment != null ? { create : true } : {}
ephemeral_storage = var.ephemeral_storage_size != null ? { create : true } : {}
Expand All @@ -25,7 +25,7 @@ data "aws_iam_policy_document" "default" {
}

resource "aws_iam_role" "default" {
count = local.create_policy ? 1 : 0
count = var.role_arn == null ? 1 : 0

name = join("-", compact([var.role_prefix, "LambdaRole", var.name]))
assume_role_policy = data.aws_iam_policy_document.default.json
Expand All @@ -34,7 +34,7 @@ resource "aws_iam_role" "default" {
}

resource "aws_iam_role_policy" "default" {
count = local.create_policy ? 1 : 0
count = local.create_policy && var.policy != null ? 1 : 0

name = "LambdaRole-${var.name}"
role = aws_iam_role.default[0].id
Expand Down

0 comments on commit cde281f

Please sign in to comment.