Skip to content

Commit

Permalink
bug: Refactor role_arn variable to list of strings to cope with 'Inva…
Browse files Browse the repository at this point in the history
…lid count' error

Signed-off-by: Stefan Wessels Beljaars <[email protected]>
  • Loading branch information
stefanwb committed Jun 11, 2024
1 parent a13af2c commit 2ea47fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ locals {
}

module "lambda_role" {
count = var.role_arn == null ? 1 : 0
count = length([var.role_arn]) == 0 ? 1 : 0

source = "github.com/schubergphilis/terraform-aws-mcaf-role?ref=v0.3.3"
name = join("-", compact([var.role_prefix, "LambdaRole", var.name]))
Expand Down Expand Up @@ -140,7 +140,7 @@ resource "aws_lambda_function" "default" {
memory_size = var.memory_size
publish = var.publish
reserved_concurrent_executions = var.reserved_concurrency
role = var.role_arn != null ? var.role_arn : module.lambda_role[0].arn
role = length([var.role_arn]) > 0 ? var.role_arn : module.lambda_role[0].arn
runtime = var.runtime
s3_bucket = var.s3_bucket
s3_key = var.s3_key
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ output "qualified_arn" {
}

output "role_arn" {
value = var.role_arn != null ? var.role_arn : module.lambda_role[0].arn
value = length([var.role_arn]) > 0 ? var.role_arn : module.lambda_role[0].arn
description = "ARN of the lambda execution role"
}

Expand Down

0 comments on commit 2ea47fd

Please sign in to comment.