From 7455d5a782cff4a45c8ac614f47ebf0109ac9a5a Mon Sep 17 00:00:00 2001 From: Ryan Kennedy Date: Thu, 21 Jun 2018 15:58:30 -0700 Subject: [PATCH 1/2] Adding codebuild.EnvironmentTypeWindowsContainer as valid type for aws_codepipeline_project/environment/type. Fixes #4940 --- aws/resource_aws_codebuild_project.go | 1 + 1 file changed, 1 insertion(+) diff --git a/aws/resource_aws_codebuild_project.go b/aws/resource_aws_codebuild_project.go index 4a378ecf048..6705fc82bc7 100644 --- a/aws/resource_aws_codebuild_project.go +++ b/aws/resource_aws_codebuild_project.go @@ -157,6 +157,7 @@ func resourceAwsCodeBuildProject() *schema.Resource { Required: true, ValidateFunc: validation.StringInSlice([]string{ codebuild.EnvironmentTypeLinuxContainer, + codebuild.EnvironmentTypeWindowsContainer, }, false), }, "privileged_mode": { From 7bd7d5866c4e00c284427f669cdc379cb59ce10a Mon Sep 17 00:00:00 2001 From: Ryan Kennedy Date: Fri, 22 Jun 2018 11:57:32 -0700 Subject: [PATCH 2/2] adding acceptance test (TestAccAWSCodeBuildProject_WindowsContainer) for #4940. credit: @callmeradical --- aws/resource_aws_codebuild_project_test.go | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/aws/resource_aws_codebuild_project_test.go b/aws/resource_aws_codebuild_project_test.go index 25203c3b057..e5b1a3b1165 100644 --- a/aws/resource_aws_codebuild_project_test.go +++ b/aws/resource_aws_codebuild_project_test.go @@ -418,6 +418,32 @@ func TestAccAWSCodeBuildProject_VpcConfig(t *testing.T) { }) } +func TestAccAWSCodeBuildProject_WindowsContainer(t *testing.T) { + var project codebuild.Project + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_codebuild_project.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSCodeBuildProjectDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSCodeBuildProjectConfig_WindowsContainer(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSCodeBuildProjectExists(resourceName, &project), + resource.TestCheckResourceAttr(resourceName, "environment.#", "1"), + resource.TestCheckResourceAttr(resourceName, "environment.3935046469.compute_type", "BUILD_GENERAL1_MEDIUM"), + resource.TestCheckResourceAttr(resourceName, "environment.3935046469.environment_variable.#", "0"), + resource.TestCheckResourceAttr(resourceName, "environment.3935046469.image", "2"), + resource.TestCheckResourceAttr(resourceName, "environment.3935046469.privileged_mode", "false"), + resource.TestCheckResourceAttr(resourceName, "environment.3935046469.type", "WINDOWS_CONTAINER"), + ), + }, + }, + }) +} + func TestAWSCodeBuildProject_nameValidation(t *testing.T) { cases := []struct { Value string @@ -912,3 +938,27 @@ resource "aws_codebuild_project" "test" { } `, subnetCount, rName) } + +func testAccAWSCodeBuildProjectConfig_WindowsContainer(rName string) string { + return testAccAWSCodeBuildProjectConfig_Base_ServiceRole(rName) + fmt.Sprintf(` +resource "aws_codebuild_project" "test" { + name = "%s" + service_role = "${aws_iam_role.test.arn}" + + artifacts { + type = "NO_ARTIFACTS" + } + + environment { + compute_type = "BUILD_GENERAL1_MEDIUM" + image = "2" + type = "WINDOWS_CONTAINER" + } + + source { + location = "%s" + type = "GITHUB" + } +} +`, rName, testAccAWSCodeBuildGitHubSourceLocationFromEnv()) +}