diff --git a/aws/resource_aws_codebuild_project.go b/aws/resource_aws_codebuild_project.go index e6d92150aee..3b3b2ea810f 100644 --- a/aws/resource_aws_codebuild_project.go +++ b/aws/resource_aws_codebuild_project.go @@ -128,6 +128,14 @@ func resourceAwsCodeBuildProject() *schema.Resource { Type: schema.TypeString, Required: true, }, + "type": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + codebuild.EnvironmentVariableTypeParameterStore, + codebuild.EnvironmentVariableTypePlaintext, + }, false), + }, }, }, }, @@ -412,6 +420,10 @@ func expandProjectEnvironment(d *schema.ResourceData) *codebuild.ProjectEnvironm projectEnvironmentVar.Value = &v } + if v := config["type"].(string); v != "" { + projectEnvironmentVar.Type = &v + } + projectEnvironmentVariables = append(projectEnvironmentVariables, projectEnvironmentVar) } @@ -782,6 +794,9 @@ func environmentVariablesToMap(environmentVariables []*codebuild.EnvironmentVari item := map[string]interface{}{} item["name"] = *env.Name item["value"] = *env.Value + if env.Type != nil { + item["type"] = *env.Type + } envVariables = append(envVariables, item) } } diff --git a/aws/resource_aws_codebuild_project_test.go b/aws/resource_aws_codebuild_project_test.go index 2851b4964bc..41f3a28e2bd 100644 --- a/aws/resource_aws_codebuild_project_test.go +++ b/aws/resource_aws_codebuild_project_test.go @@ -148,6 +148,34 @@ func TestAccAWSCodeBuildProject_sourceAuth(t *testing.T) { }) } +func TestAccAWSCodeBuildProject_parameter_store_type(t *testing.T) { + name := acctest.RandString(10) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSCodeBuildProjectDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSCodeBuildProjectConfig_environment_variable_plaintext_type(name), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSCodeBuildProjectExists("aws_codebuild_project.foo"), + resource.TestCheckResourceAttr( + "aws_codebuild_project.foo", "environment.0.environment_variable.0.type", "PLAINTEXT"), + ), + }, + { + Config: testAccAWSCodeBuildProjectConfig_environment_variable_parameter_store_type(name), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSCodeBuildProjectExists("aws_codebuild_project.foo"), + resource.TestCheckResourceAttr( + "aws_codebuild_project.foo", "environment.0.environment_variable.0.type", "PARAMETER_STORE"), + ), + }, + }, + }) +} + func TestAccAWSCodeBuildProject_default_build_timeout(t *testing.T) { name := acctest.RandString(10) @@ -710,7 +738,7 @@ resource "aws_codebuild_project" "foo" { source { type = "GITHUB" location = "https://github.com/hashicorp/packer.git" - + auth { resource = "%[2]s" type = "%[3]s" @@ -767,6 +795,174 @@ func testAccAWSCodeBuildProjectConfig_vpcConfig(subnets string) string { `, subnets) } +func testAccAWSCodeBuildProjectConfig_environment_variable_plaintext_type(rName string) string { + return fmt.Sprintf(` +resource "aws_iam_role" "codebuild_role" { + name = "codebuild-role-%s" + assume_role_policy = <