Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build_batch_config cannot be removed problem #34121

Merged
merged 31 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
79d0259
Fix build_batch_config cannot be removed problem
digglife Oct 26, 2023
e97cbae
Merge branch 'main' into HEAD
ewbankkit Jan 22, 2024
6a78678
codebuild: Migrate to AWS SDK for Go v2.
ewbankkit Jan 22, 2024
027c51e
Run 'make gen'.
ewbankkit Jan 22, 2024
fcc5143
Run 'go get github.com/aws/aws-sdk-go-v2/service/codebuild@v1.28.0 &&…
ewbankkit Jan 22, 2024
0cbbc61
Correct tagging code generation.
ewbankkit Jan 22, 2024
763ef39
r/aws_codebuild_resource_policy: Migrate to AWS SDK for Go v2.
ewbankkit Jan 22, 2024
ef77a32
r/aws_codebuild_source_credential: Migrate to AWS SDK for Go v2.
ewbankkit Jan 22, 2024
1afd700
r/aws_codebuild_report_group: Migrate to AWS SDK for Go v2.
ewbankkit Jan 22, 2024
9f5d5fe
r/aws_codebuild_webhook: Migrate to AWS SDK for Go v2.
ewbankkit Jan 22, 2024
104ee1f
r/aws_codebuild_project: Migrate to AWS SDK for Go v2.
ewbankkit Jan 22, 2024
cbc248e
codebuild: Migrate sweepers to AWS SDK for Go v2.
ewbankkit Jan 22, 2024
a0d32d1
Add 'names.CodeBuildEndpointID'.
ewbankkit Jan 22, 2024
e20bd93
codebuild: Migrate acceptance tests to AWS SDK for Go v2.
ewbankkit Jan 22, 2024
c137ba3
Fix golangci-lint 'whitespace'.
ewbankkit Jan 22, 2024
84bbd5c
Fix golangci-lint 'asasalint'.
ewbankkit Jan 22, 2024
7a11213
r/aws_codebuild_resource_policy: Fix 'ResourceNotFoundException: Reso…
ewbankkit Jan 23, 2024
9701067
Add CHANGELOG entry.
ewbankkit Jan 23, 2024
e8c28d4
codebuild: Add 'testAccPreCheckSourceCredentialsForServerType'.
ewbankkit Jan 23, 2024
23d3f77
r/aws_codebuild_webhook: Fix typo.
ewbankkit Jan 23, 2024
ccc569c
r/aws_codebuild_project: Use 'testAccPreCheckSourceCredentialsForServ…
ewbankkit Jan 23, 2024
00bfe9f
Tidy up 'TestAccCodeBuildProject_tags'.
ewbankkit Jan 23, 2024
94704bd
r/aws_codebuild_project: Fix some 'ImportStateVerify attributes not e…
ewbankkit Jan 23, 2024
220eebf
r/aws_codebuild_project: Fix diff suppression for 'secondary_artifact…
ewbankkit Jan 23, 2024
2dc8da9
Acceptance test output:
ewbankkit Jan 23, 2024
5b3a446
r/aws_codebuild_project: Tidy up acceptance tests.
ewbankkit Jan 23, 2024
7c5d016
r/aws_codebuild_project: Fix some more 'ImportStateVerify attributes …
ewbankkit Jan 23, 2024
c6ea4a8
r/aws_codebuild_project: Fix typos.
ewbankkit Jan 23, 2024
0fdc0eb
r/aws_codebuild_project: Fix typos.
ewbankkit Jan 23, 2024
4eed2ab
r/aws_codebuild_project: Correct 'vpc_config' and 'logs_config' flex.
ewbankkit Jan 23, 2024
99bfcb3
Fix terrafmt errors.
ewbankkit Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/service/codebuild/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,10 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, meta int

if d.HasChange("build_batch_config") {
input.BuildBatchConfig = expandBuildBatchConfig(d)
// If BuildBatchConfig is nil we should remove it by passing an empty struct.
if input.BuildBatchConfig == nil {
input.BuildBatchConfig = &codebuild.ProjectBuildBatchConfig{}
}
}

if d.HasChange("cache") {
Expand Down
85 changes: 85 additions & 0 deletions internal/service/codebuild/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,45 @@ func TestAccCodeBuildProject_buildBatch(t *testing.T) {
})
}

func TestAccCodeBuildProject_buildBatchConfigDelete(t *testing.T) {
ctx := acctest.Context(t)
var project codebuild.Project
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_codebuild_project.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, codebuild.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckProjectDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccProjectConfig_buildBatchConfigDelete(rName, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckProjectExists(ctx, resourceName, &project),
resource.TestCheckResourceAttr(resourceName, "build_batch_config.0.combine_artifacts", "true"),
resource.TestCheckResourceAttr(resourceName, "build_batch_config.0.restrictions.#", "1"),
resource.TestCheckResourceAttr(resourceName, "build_batch_config.0.restrictions.0.compute_types_allowed.#", "0"),
resource.TestCheckResourceAttr(resourceName, "build_batch_config.0.restrictions.0.maximum_builds_allowed", "10"),
resource.TestCheckResourceAttr(resourceName, "build_batch_config.0.timeout_in_mins", "480"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccProjectConfig_buildBatchConfigDelete(rName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckProjectExists(ctx, resourceName, &project),
resource.TestCheckNoResourceAttr(resourceName, "build_batch_config.%"),
),
},
},
})
}

func TestAccCodeBuildProject_Source_gitCloneDepth(t *testing.T) {
ctx := acctest.Context(t)
var project codebuild.Project
Expand Down Expand Up @@ -3421,6 +3460,52 @@ resource "aws_codebuild_project" "test" {
`, rName, combineArtifacts, computeTypesAllowed, maximumBuildsAllowed, timeoutInMins))
}

func testAccProjectConfig_buildBatchConfigDelete(rName string, withBuildBatchConfig bool) string {

template := `
resource "aws_codebuild_project" "test" {
name = %[1]q
service_role = aws_iam_role.test.arn

artifacts {
type = "NO_ARTIFACTS"
}

environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "2"
type = "LINUX_CONTAINER"
}

source {
location = "https://github.com/hashicorp/packer.git"
type = "GITHUB"
}

%[2]s
}
`

buildBatchConfig := `
build_batch_config {
combine_artifacts = true

restrictions {
compute_types_allowed = []
maximum_builds_allowed = 10
}

service_role = aws_iam_role.test.arn
timeout_in_mins = 480
}
`

if withBuildBatchConfig {
return acctest.ConfigCompose(testAccProjectConfig_Base_ServiceRole(rName), fmt.Sprintf(template, rName, buildBatchConfig))
}
return acctest.ConfigCompose(testAccProjectConfig_Base_ServiceRole(rName), fmt.Sprintf(template, rName, ""))
}

func testAccProjectConfig_s3Logs(rName, status, location string, encryptionDisabled bool) string {
return acctest.ConfigCompose(
testAccProjectConfig_Base_ServiceRole(rName),
Expand Down