Skip to content

Commit 8c0019a

Browse files
authored
Use count instead of for_each (#17)
* Use count instead of for_each condition * and handle null var.path in filebase64sha256
1 parent 760a490 commit 8c0019a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
locals {
2626
deploy_artifact_key = "deploy.zip"
2727
deployment_bucket_id = coalesce(var.deployment_bucket_id, data.aws_ssm_parameter.deployment_bucket_id.value)
28-
source_hash = coalesce(var.git_sha, filebase64sha256(var.path))
28+
source_hash = coalesce(var.git_sha, try(filebase64sha256(var.path), null))
2929
role_arn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${var.role_name}"
3030
}
3131

@@ -52,7 +52,7 @@ resource "aws_iam_role_policy_attachment" "lambda_insights" {
5252

5353
# S3 object to hold the deployed artifact
5454
resource "aws_s3_bucket_object" "lambda_deploy_object" {
55-
for_each = var.image_uri == null ? [1] : []
55+
count = var.image_uri == null ? 1 : 0
5656
bucket = local.deployment_bucket_id
5757
key = "${var.name}/${local.deploy_artifact_key}"
5858
source = var.path

0 commit comments

Comments
 (0)