From 82ff95dfb859da0eb5a502ad393e12645efeab0d Mon Sep 17 00:00:00 2001 From: grahamhar Date: Sun, 14 Feb 2021 11:11:46 +0000 Subject: [PATCH] Fix change detection relating to vpc_config As reported in https://github.com/hashicorp/terraform-provider-aws/issues/17385 a change i detected in vpc_config when there are no changes, this is caused by an issue in https://github.com/hashicorp/terraform-plugin-sdk/issues/617 The PR to provide a fix is not getting any traction. On further debuging the issue is caused by the nested elements being of type set which needs the use of Equal rather than reflect.DeepEqual to test for differences. We can work around this bug by testing for changes in the two fields within vpc_config independantly as when the item passed to HasChanges is a Set it is tested correctly. --- aws/resource_aws_lambda_function.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_lambda_function.go b/aws/resource_aws_lambda_function.go index 4872f036966..32f716f41c9 100644 --- a/aws/resource_aws_lambda_function.go +++ b/aws/resource_aws_lambda_function.go @@ -364,7 +364,8 @@ func hasConfigChanges(d resourceDiffer) bool { d.HasChange("layers") || d.HasChange("dead_letter_config") || d.HasChange("tracing_config") || - d.HasChange("vpc_config") || + d.HasChange("vpc_config.0.security_group_ids") || + d.HasChange("vpc_config.0.subnet_ids") || d.HasChange("runtime") || d.HasChange("environment") }