From 7388eea3f95835e5ef19efd82c0bb42cf4cc895c Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Sat, 10 Jun 2023 16:22:38 +0000 Subject: [PATCH 1/3] Initial Commit --- internal/service/lambda/function.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/service/lambda/function.go b/internal/service/lambda/function.go index a49a9c777dc4..b0c3354d427d 100644 --- a/internal/service/lambda/function.go +++ b/internal/service/lambda/function.go @@ -334,6 +334,12 @@ func ResourceFunction() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + if old == "1" && new == "0" { + return true + } + return false + }, }, "source_code_size": { Type: schema.TypeInt, From f2f762fd011e285149750dda38964dd0a445ecc0 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Sat, 10 Jun 2023 16:26:52 +0000 Subject: [PATCH 2/3] Added Chnage Log --- .changelog/29921.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/29921.txt diff --git a/.changelog/29921.txt b/.changelog/29921.txt new file mode 100644 index 000000000000..17977a53638c --- /dev/null +++ b/.changelog/29921.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_lambda_function: Ensure lambda does not get deployed if `source_code_hash` does not change. +``` From c42a6bbfd7f170bbb30254045c1657e2e9c973c2 Mon Sep 17 00:00:00 2001 From: Sharon Nam Date: Wed, 3 Jan 2024 16:59:51 -0800 Subject: [PATCH 3/3] Use suppress function --- internal/service/lambda/function.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/internal/service/lambda/function.go b/internal/service/lambda/function.go index b60c43a062c5..f7a47a0df79c 100644 --- a/internal/service/lambda/function.go +++ b/internal/service/lambda/function.go @@ -369,15 +369,10 @@ func ResourceFunction() *schema.Resource { }, }, "source_code_hash": { - Type: schema.TypeString, - Optional: true, - Computed: true, - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - if old == "1" && new == "0" { - return true - } - return false - }, + Type: schema.TypeString, + Optional: true, + Computed: true, + DiffSuppressFunc: verify.SuppressMissingOptionalConfigurationBlock, }, "source_code_size": { Type: schema.TypeInt,