Skip to content

Commit

Permalink
Merge pull request #69 from schubergphilis/fix-role-policy
Browse files Browse the repository at this point in the history
bug: fixes creating role when no role_arn is specified
  • Loading branch information
stefanwb authored Mar 8, 2024
2 parents be9af50 + cde281f commit 0a41aa7
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 @@ -26,7 +26,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 @@ -35,7 +35,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 0a41aa7

Please sign in to comment.