Skip to content

Commit

Permalink
Feature/build timeout (#30)
Browse files Browse the repository at this point in the history
* (Feature) Build Timeout

* Adds the `build_timeout` variable - How long in minutes, from 5 to 480 (8 hours), for AWS CodeBuild to wait until timing out any related build that does not get marked as completed.
* Defaults to 60 as per terraform docs - https://www.terraform.io/docs/providers/aws/r/codebuild_project.html#build_timeout

* (Chore) Generate README

* Adds `build_timeout` documentation
  • Loading branch information
Stretch96 authored and aknysh committed Jan 4, 2019
1 parent 1ad718e commit a761530
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module "build" {
# https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
build_image = "aws/codebuild/docker:1.12.1"
build_compute_type = "BUILD_GENERAL1_SMALL"
build_timeout = "60"
# These attributes are optional, used as ENV variables when building Docker images and pushing them to ECR
# For more info:
Expand Down Expand Up @@ -122,6 +123,7 @@ Available targets:
| aws_region | (Optional) AWS Region, e.g. us-east-1. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html | string | `` | no |
| build_compute_type | Instance type of the build instance | string | `BUILD_GENERAL1_SMALL` | no |
| build_image | Docker image for build environment, e.g. 'aws/codebuild/docker:1.12.1' or 'aws/codebuild/eb-nodejs-6.10.0-amazonlinux-64:4.0.0'. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html | string | `aws/codebuild/docker:1.12.1` | no |
| build_timeout | How long in minutes, from 5 to 480 (8 hours), for AWS CodeBuild to wait until timing out any related build that does not get marked as completed. | string | `60` | no |
| buildspec | Optional buildspec declaration to use for building the project | string | `` | no |
| 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 | string | `true` | no |
| cache_enabled | If cache_enabled is true, create an S3 bucket for storing codebuild cache inside | string | `true` | no |
Expand Down Expand Up @@ -229,7 +231,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

## Copyright

Copyright © 2017-2018 [Cloud Posse, LLC](https://cpco.io/copyright)
Copyright © 2017-2019 [Cloud Posse, LLC](https://cpco.io/copyright)



Expand Down
1 change: 1 addition & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ usage: |-
# https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
build_image = "aws/codebuild/docker:1.12.1"
build_compute_type = "BUILD_GENERAL1_SMALL"
build_timeout = "60"
# These attributes are optional, used as ENV variables when building Docker images and pushing them to ECR
# For more info:
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| aws_region | (Optional) AWS Region, e.g. us-east-1. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html | string | `` | no |
| build_compute_type | Instance type of the build instance | string | `BUILD_GENERAL1_SMALL` | no |
| build_image | Docker image for build environment, e.g. 'aws/codebuild/docker:1.12.1' or 'aws/codebuild/eb-nodejs-6.10.0-amazonlinux-64:4.0.0'. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html | string | `aws/codebuild/docker:1.12.1` | no |
| build_timeout | How long in minutes, from 5 to 480 (8 hours), for AWS CodeBuild to wait until timing out any related build that does not get marked as completed. | string | `60` | no |
| buildspec | Optional buildspec declaration to use for building the project | string | `` | no |
| 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 | string | `true` | no |
| cache_enabled | If cache_enabled is true, create an S3 bucket for storing codebuild cache inside | string | `true` | no |
Expand Down
7 changes: 4 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ resource "aws_iam_role_policy_attachment" "default_cache_bucket" {
}

resource "aws_codebuild_project" "default" {
count = "${var.enabled == "true" ? 1 : 0}"
name = "${module.label.id}"
service_role = "${aws_iam_role.default.arn}"
count = "${var.enabled == "true" ? 1 : 0}"
name = "${module.label.id}"
service_role = "${aws_iam_role.default.arn}"
build_timeout = "${var.build_timeout}"

artifacts {
type = "${var.artifact_type}"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ variable "build_compute_type" {
description = "Instance type of the build instance"
}

variable "build_timeout" {
type = "string"
default = "60"
description = "How long in minutes, from 5 to 480 (8 hours), for AWS CodeBuild to wait until timing out any related build that does not get marked as completed."
}

variable "buildspec" {
type = "string"
default = ""
Expand Down

0 comments on commit a761530

Please sign in to comment.