diff --git a/aws/resource_aws_codebuild_project.go b/aws/resource_aws_codebuild_project.go index 32745251606..5df8bf37fd6 100644 --- a/aws/resource_aws_codebuild_project.go +++ b/aws/resource_aws_codebuild_project.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" ) func resourceAwsCodeBuildProject() *schema.Resource { @@ -95,6 +96,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), + }, }, }, }, @@ -314,6 +323,10 @@ func expandProjectEnvironment(d *schema.ResourceData) *codebuild.ProjectEnvironm projectEnvironmentVar.Value = &v } + if v := config["type"].(string); v != "" { + projectEnvironmentVar.Type = &v + } + projectEnvironmentVariables = append(projectEnvironmentVariables, projectEnvironmentVar) } @@ -626,6 +639,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 e79e49a8ff2..120a02e4bc0 100644 --- a/aws/resource_aws_codebuild_project_test.go +++ b/aws/resource_aws_codebuild_project_test.go @@ -388,8 +388,9 @@ resource "aws_codebuild_project" "foo" { type = "LINUX_CONTAINER" environment_variable = { - "name" = "SOME_KEY" - "value" = "SOME_VALUE" + name = "SOME_KEY" + value = "SOME_VALUE" + type = "PLAINTEXT" } } @@ -471,8 +472,9 @@ resource "aws_codebuild_project" "foo" { type = "LINUX_CONTAINER" environment_variable = { - "name" = "SOME_OTHERKEY" - "value" = "SOME_OTHERVALUE" + name = "SOME_OTHERKEY" + value = "SOME_OTHERVALUE" + type = "PARAMETER_STORE" } } diff --git a/website/docs/r/codebuild_project.html.markdown b/website/docs/r/codebuild_project.html.markdown index bb6a0c22bb0..14a732568d8 100644 --- a/website/docs/r/codebuild_project.html.markdown +++ b/website/docs/r/codebuild_project.html.markdown @@ -134,6 +134,7 @@ The following arguments are supported: `environment_variable` supports the following: * `name` - (Required) The environment variable's name or key. * `value` - (Required) The environment variable's value. +* `type` - (Optional) The type of environment variable. Valid values: `PARAMETER_STORE`, `PLAINTEXT`. `source` supports the following: @@ -156,4 +157,3 @@ The following attributes are exported: * `encryption_key` - The AWS Key Management Service (AWS KMS) customer master key (CMK) that was used for encrypting the build project's build output artifacts. * `name` - The projects name. * `service_role` - The ARN of the IAM service role. -