From f0e7bc942b76051b9a0ae7fa098efa5220d18a7e Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Tue, 21 Mar 2017 15:33:32 +0000 Subject: [PATCH] provider/aws: Prevent panic when setting AWS CodeBuild Source to state (#12915) Fixes: #12914 this is just a simple guard clause to prevent the hash from including an optional value by default --- builtin/providers/aws/resource_aws_codebuild_project.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_codebuild_project.go b/builtin/providers/aws/resource_aws_codebuild_project.go index 3a198366f..bbd3523a3 100644 --- a/builtin/providers/aws/resource_aws_codebuild_project.go +++ b/builtin/providers/aws/resource_aws_codebuild_project.go @@ -592,11 +592,11 @@ func resourceAwsCodeBuildProjectSourceAuthHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) - authType := m["type"].(string) - authResource := m["resource"].(string) + buf.WriteString(fmt.Sprintf("%s-", m["type"].(string))) - buf.WriteString(fmt.Sprintf("%s-", authType)) - buf.WriteString(fmt.Sprintf("%s-", authResource)) + if m["resource"] != nil { + buf.WriteString(fmt.Sprintf("%s-", m["resource"].(string))) + } return hashcode.String(buf.String()) }