diff --git a/builtin/providers/aws/resource_aws_codebuild_project.go b/builtin/providers/aws/resource_aws_codebuild_project.go index 0f9bb9be7..9643dffe6 100644 --- a/builtin/providers/aws/resource_aws_codebuild_project.go +++ b/builtin/providers/aws/resource_aws_codebuild_project.go @@ -503,12 +503,17 @@ func flattenAwsCodebuildProjectSource(source *codebuild.ProjectSource) *schema.S F: resourceAwsCodeBuildProjectSourceHash, } + authSet := schema.Set{ + F: resourceAwsCodeBuildProjectSourceAuthHash, + } + sourceConfig := map[string]interface{}{} sourceConfig["type"] = *source.Type if source.Auth != nil { - sourceConfig["auth"] = sourceAuthToMap(source.Auth) + authSet.Add(sourceAuthToMap(source.Auth)) + sourceConfig["auth"] = &authSet } if source.Buildspec != nil { @@ -566,6 +571,19 @@ func resourceAwsCodeBuildProjectSourceHash(v interface{}) int { return hashcode.String(buf.String()) } +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-", authType)) + buf.WriteString(fmt.Sprintf("%s-", authResource)) + + return hashcode.String(buf.String()) +} + func environmentVariablesToMap(environmentVariables []*codebuild.EnvironmentVariable) []map[string]interface{} { envVariables := make([]map[string]interface{}, len(environmentVariables)) diff --git a/builtin/providers/aws/resource_aws_codebuild_project_test.go b/builtin/providers/aws/resource_aws_codebuild_project_test.go index a21fe0f2a..949a6fb29 100644 --- a/builtin/providers/aws/resource_aws_codebuild_project_test.go +++ b/builtin/providers/aws/resource_aws_codebuild_project_test.go @@ -355,6 +355,10 @@ resource "aws_codebuild_project" "foo" { } source { + auth { + type = "OAUTH" + } + type = "GITHUB" location = "https://github.com/mitchellh/packer.git" }