From cdbd21923aca9abe4a58abd53e13183bad9b0807 Mon Sep 17 00:00:00 2001 From: gui-don Date: Wed, 17 Nov 2021 21:43:31 -0500 Subject: [PATCH] Add `description` and `concurrent_build_limit` to `aws_codebuild_project` (#89) * feat: allows user to input a description for the codebuild project * feat: allows user to input a description for the codebuild project * feat: allows user to input a concurrent_build_limit for the codebuild project * Auto Format * fix: integer is number for Terraform * Auto Format * Update variables.tf Co-authored-by: Vladimir <26582191+SweetOps@users.noreply.github.com> * Auto Format * Update variables.tf * Auto Format Co-authored-by: Guillaume DONVAL Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> Co-authored-by: nitrocode Co-authored-by: Vladimir <26582191+SweetOps@users.noreply.github.com> --- README.md | 2 ++ docs/terraform.md | 2 ++ examples/complete/main.tf | 2 ++ main.tf | 14 ++++++++------ variables.tf | 12 ++++++++++++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 611f35c..9283b79 100644 --- a/README.md +++ b/README.md @@ -218,8 +218,10 @@ Available targets: | [cache\_bucket\_suffix\_enabled](#input\_cache\_bucket\_suffix\_enabled) | The cache bucket generates a random 13 character string to generate a unique bucket name. If set to false it uses terraform-null-label's id value. It only works when cache\_type is 'S3 | `bool` | `true` | no | | [cache\_expiration\_days](#input\_cache\_expiration\_days) | How many days should the build cache be kept. It only works when cache\_type is 'S3' | `number` | `7` | no | | [cache\_type](#input\_cache\_type) | The type of storage that will be used for the AWS CodeBuild project cache. Valid values: NO\_CACHE, LOCAL, and S3. Defaults to NO\_CACHE. If cache\_type is S3, it will create an S3 bucket for storing codebuild cache inside | `string` | `"NO_CACHE"` | no | +| [concurrent\_build\_limit](#input\_concurrent\_build\_limit) | Specify a maximum number of concurrent builds for the project. The value specified must be greater than 0 and less than the account concurrent running builds limit. | `number` | `null` | no | | [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no | | [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | +| [description](#input\_description) | Short description of the CodeBuild project | `string` | `"Managed by Terraform"` | no | | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | | [encryption\_enabled](#input\_encryption\_enabled) | When set to 'true' the resource will have AES256 encryption enabled by default | `bool` | `false` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 2701d90..212a8f9 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -62,8 +62,10 @@ | [cache\_bucket\_suffix\_enabled](#input\_cache\_bucket\_suffix\_enabled) | The cache bucket generates a random 13 character string to generate a unique bucket name. If set to false it uses terraform-null-label's id value. It only works when cache\_type is 'S3 | `bool` | `true` | no | | [cache\_expiration\_days](#input\_cache\_expiration\_days) | How many days should the build cache be kept. It only works when cache\_type is 'S3' | `number` | `7` | no | | [cache\_type](#input\_cache\_type) | The type of storage that will be used for the AWS CodeBuild project cache. Valid values: NO\_CACHE, LOCAL, and S3. Defaults to NO\_CACHE. If cache\_type is S3, it will create an S3 bucket for storing codebuild cache inside | `string` | `"NO_CACHE"` | no | +| [concurrent\_build\_limit](#input\_concurrent\_build\_limit) | Specify a maximum number of concurrent builds for the project. The value specified must be greater than 0 and less than the account concurrent running builds limit. | `number` | `null` | no | | [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no | | [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | +| [description](#input\_description) | Short description of the CodeBuild project | `string` | `"Managed by Terraform"` | no | | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | | [encryption\_enabled](#input\_encryption\_enabled) | When set to 'true' the resource will have AES256 encryption enabled by default | `bool` | `false` | no | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 09556fc..6b19569 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -4,6 +4,8 @@ provider "aws" { module "codebuild" { source = "../../" + description = "This is my awesome CodeBuild project" + concurrent_build_limit = 10 cache_bucket_suffix_enabled = var.cache_bucket_suffix_enabled environment_variables = var.environment_variables cache_expiration_days = var.cache_expiration_days diff --git a/main.tf b/main.tf index 3020b03..9fa9085 100644 --- a/main.tf +++ b/main.tf @@ -290,12 +290,14 @@ resource "aws_codebuild_source_credential" "authorization" { } resource "aws_codebuild_project" "default" { - count = module.this.enabled ? 1 : 0 - name = module.this.id - service_role = join("", aws_iam_role.default.*.arn) - badge_enabled = var.badge_enabled - build_timeout = var.build_timeout - source_version = var.source_version != "" ? var.source_version : null + count = module.this.enabled ? 1 : 0 + name = module.this.id + description = var.description + concurrent_build_limit = var.concurrent_build_limit + service_role = join("", aws_iam_role.default.*.arn) + badge_enabled = var.badge_enabled + build_timeout = var.build_timeout + source_version = var.source_version != "" ? var.source_version : null tags = { for name, value in module.this.tags : name => value diff --git a/variables.tf b/variables.tf index e71790b..3204da7 100644 --- a/variables.tf +++ b/variables.tf @@ -16,6 +16,18 @@ variable "environment_variables" { description = "A list of maps, that contain the keys 'name', 'value', and 'type' to be used as additional environment variables for the build. Valid types are 'PLAINTEXT', 'PARAMETER_STORE', or 'SECRETS_MANAGER'" } +variable "description" { + type = string + default = "Managed by Terraform" + description = "Short description of the CodeBuild project" +} + +variable "concurrent_build_limit" { + type = number + default = null + description = "Specify a maximum number of concurrent builds for the project. The value specified must be greater than 0 and less than the account concurrent running builds limit." +} + variable "cache_expiration_days" { default = 7 description = "How many days should the build cache be kept. It only works when cache_type is 'S3'"