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

r/codebuild_project: Support type for environment_variable #2811

Merged
merged 3 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions aws/resource_aws_codebuild_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
},
},
},
},
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
}
Expand Down
10 changes: 6 additions & 4 deletions aws/resource_aws_codebuild_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down Expand Up @@ -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"
}
}

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/codebuild_project.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ The following arguments are supported:
`environment_variable` supports the following:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you can add an extra CR at the end of this? the docs don't parse properly otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done and merged BTW

* `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:

Expand All @@ -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.