diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0bca29a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -addons: - apt: - packages: - - git - - make - - curl - -install: - - make init - -script: - - make terraform:install - - make terraform:get-plugins - - make terraform:get-modules - - make terraform:lint - - make terraform:validate diff --git a/LICENSE b/LICENSE index 808ecf3..a6e3b3e 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2017-2018 Cloud Posse, LLC + Copyright 2017-2019 Cloud Posse, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 531663e..808e996 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Cloud Posse][logo]](https://cpco.io/homepage) -# terraform-aws-codebuild [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-codebuild.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-codebuild) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-codebuild.svg)](https://github.com/cloudposse/terraform-aws-codebuild/releases) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) +# terraform-aws-codebuild [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-codebuild?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d198705e38a0429d812f7e4) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-codebuild.svg)](https://github.com/cloudposse/terraform-aws-codebuild/releases) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) Terraform module to create AWS CodeBuild project for AWS CodePipeline. @@ -52,21 +52,21 @@ Include this module in your existing terraform code: ```hcl module "build" { source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=master" - namespace = "general" - name = "ci" + namespace = "eg" stage = "staging" + name = "app" # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html - build_image = "aws/codebuild/docker:1.12.1" + build_image = "aws/codebuild/standard:2.0" build_compute_type = "BUILD_GENERAL1_SMALL" - build_timeout = "60" + build_timeout = 60 # These attributes are optional, used as ENV variables when building Docker images and pushing them to ECR # For more info: # http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html # https://www.terraform.io/docs/providers/aws/r/codebuild_project.html - privileged_mode = "true" + privileged_mode = true aws_region = "us-east-1" aws_account_id = "xxxxxxxxxx" image_repo_name = "ecr-repo-name" @@ -89,19 +89,6 @@ module "build" { } ``` -### To hide warnings about unset versions in providers - -Add this to your .tf files -```hcl -provider "random" { - version = "~> 1.0" -} - -provider "null" { - version = "~> 1.0" -} -``` - @@ -121,32 +108,32 @@ Available targets: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| artifact_type | The build output artifact's type. Valid values for this parameter are: CODEPIPELINE, NO_ARTIFACTS or S3. | string | `CODEPIPELINE` | no | -| attributes | Additional attributes (e.g. `policy` or `role`) | list | `` | no | +| artifact_type | The build output artifact's type. Valid values for this parameter are: CODEPIPELINE, NO_ARTIFACTS or S3 | string | `CODEPIPELINE` | no | +| attributes | Additional attributes (e.g. `policy` or `role`) | list(string) | `` | no | | aws_account_id | (Optional) AWS Account ID. 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 | | 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 | -| badge_enabled | Generates a publicly-accessible URL for the projects build badge. Available as badge_url attribute when enabled. | string | `false` | no | +| badge_enabled | Generates a publicly-accessible URL for the projects build badge. Available as badge_url attribute when enabled | bool | `false` | 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 | +| build_image | Docker image for build environment, e.g. 'aws/codebuild/standard:2.0' 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/standard:2.0` | 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 | +| 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 | bool | `true` | no | +| cache_enabled | If cache_enabled is true, create an S3 bucket for storing codebuild cache inside | bool | `true` | no | | cache_expiration_days | How many days should the build cache be kept | string | `7` | no | | delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | -| enabled | A boolean to enable/disable resource creation | string | `true` | no | -| environment_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build. | list | `` | no | +| enabled | A boolean to enable/disable resource creation | bool | `true` | no | +| environment_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build | object | `` | no | | github_token | (Optional) GitHub auth token environment variable (`GITHUB_TOKEN`) | string | `` | no | | image_repo_name | (Optional) ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html | string | `UNSET` | no | | image_tag | (Optional) Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html | string | `latest` | no | -| name | Solution name, e.g. 'app' or 'jenkins' | string | `codebuild` | no | -| namespace | Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse' | string | `global` | no | -| privileged_mode | (Optional) If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | string | `false` | no | -| report_build_status | Set to true to report the status of a build's start and finish to your source provider. This option is only valid when the source_type is BITBUCKET or GITHUB. | string | `false` | no | -| source_location | The location of the source code from git or s3. | string | `` | no | -| source_type | The type of repository that contains the source code to be built. Valid values for this parameter are: CODECOMMIT, CODEPIPELINE, GITHUB, GITHUB_ENTERPRISE, BITBUCKET or S3. | string | `CODEPIPELINE` | no | -| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `default` | no | -| tags | Additional tags (e.g. `map('BusinessUnit', 'XYZ')` | map | `` | no | +| name | Solution name, e.g. 'app' or 'jenkins' | string | - | yes | +| namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | `` | no | +| privileged_mode | (Optional) If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | bool | `false` | no | +| report_build_status | Set to true to report the status of a build's start and finish to your source provider. This option is only valid when the source_type is BITBUCKET or GITHUB | bool | `false` | no | +| source_location | The location of the source code from git or s3 | string | `` | no | +| source_type | The type of repository that contains the source code to be built. Valid values for this parameter are: CODECOMMIT, CODEPIPELINE, GITHUB, GITHUB_ENTERPRISE, BITBUCKET or S3 | string | `CODEPIPELINE` | no | +| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `` | no | +| tags | Additional tags (e.g. `map('BusinessUnit', 'XYZ')` | map(string) | `` | no | ## Outputs diff --git a/README.yaml b/README.yaml index 60e3efe..0a7494c 100644 --- a/README.yaml +++ b/README.yaml @@ -33,9 +33,9 @@ github_repo: cloudposse/terraform-aws-codebuild # Badges to display badges: - - name: "Build Status" - image: "https://travis-ci.org/cloudposse/terraform-aws-codebuild.svg?branch=master" - url: "https://travis-ci.org/cloudposse/terraform-aws-codebuild" + - name: "Codefresh Build Status" + image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-codebuild?type=cf-1" + url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d198705e38a0429d812f7e4" - name: "Latest Release" image: "https://img.shields.io/github/release/cloudposse/terraform-aws-codebuild.svg" url: "https://github.com/cloudposse/terraform-aws-codebuild/releases" @@ -59,21 +59,21 @@ usage: |- ```hcl module "build" { source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=master" - namespace = "general" - name = "ci" + namespace = "eg" stage = "staging" + name = "app" # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html - build_image = "aws/codebuild/docker:1.12.1" + build_image = "aws/codebuild/standard:2.0" build_compute_type = "BUILD_GENERAL1_SMALL" - build_timeout = "60" + build_timeout = 60 # These attributes are optional, used as ENV variables when building Docker images and pushing them to ECR # For more info: # http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html # https://www.terraform.io/docs/providers/aws/r/codebuild_project.html - privileged_mode = "true" + privileged_mode = true aws_region = "us-east-1" aws_account_id = "xxxxxxxxxx" image_repo_name = "ecr-repo-name" @@ -96,19 +96,6 @@ usage: |- } ``` - ### To hide warnings about unset versions in providers - - Add this to your .tf files - ```hcl - provider "random" { - version = "~> 1.0" - } - - provider "null" { - version = "~> 1.0" - } - ``` - # Other files to include in this README from the project folder include: - "docs/targets.md" @@ -125,4 +112,4 @@ contributors: - name: "Jamie Nelson" github: "Jamie-BitfFlight" - name: "Sarkis Varozian" - github: "sarkis" \ No newline at end of file + github: "sarkis" diff --git a/codefresh/test.yml b/codefresh/test.yml new file mode 100644 index 0000000..ddd07f9 --- /dev/null +++ b/codefresh/test.yml @@ -0,0 +1,74 @@ +version: '1.0' + +stages: + - Prepare + - Test + +steps: + wait: + title: Wait + stage: Prepare + image: codefresh/cli:latest + commands: + - codefresh get builds --pipeline=${{CF_REPO_NAME}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id' + retry: + maxAttempts: 10 + delay: 20 + exponentialFactor: 1.1 + + main_clone: + title: "Clone repository" + type: git-clone + stage: Prepare + description: "Initialize" + repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} + git: CF-default + revision: ${{CF_REVISION}} + + clean_init: + title: Prepare build-harness and test-harness + image: ${{TEST_IMAGE}} + stage: Prepare + commands: + - cf_export PATH="/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + - make init + - git -C build-harness checkout master + - make -C test/ clean init TEST_HARNESS_BRANCH=master + - make -C test/src clean init + - find . -type d -name '.terraform' | xargs rm -rf + - find . -type f -name 'terraform.tfstate*' -exec rm -f {} \; + + test: + type: "parallel" + title: "Run tests" + description: "Run all tests in parallel" + stage: Test + steps: + test_readme_lint: + title: "Test README.md updated" + stage: "Test" + image: ${{TEST_IMAGE}} + description: Test "readme/lint" + commands: + - make readme/lint + + test_module: + title: Test module with bats + image: ${{TEST_IMAGE}} + stage: Test + commands: + - make -C test/ module + + test_examples_complete: + title: Test "examples/complete" with bats + image: ${{TEST_IMAGE}} + stage: Test + commands: + - make -C test/ examples/complete + + test_examples_complete_terratest: + title: Test "examples/complete" with terratest + image: ${{TEST_IMAGE}} + stage: Test + commands: + - make -C test/src diff --git a/docs/terraform.md b/docs/terraform.md index 4d6afbd..5fea53c 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -2,32 +2,32 @@ | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| artifact_type | The build output artifact's type. Valid values for this parameter are: CODEPIPELINE, NO_ARTIFACTS or S3. | string | `CODEPIPELINE` | no | -| attributes | Additional attributes (e.g. `policy` or `role`) | list | `` | no | +| artifact_type | The build output artifact's type. Valid values for this parameter are: CODEPIPELINE, NO_ARTIFACTS or S3 | string | `CODEPIPELINE` | no | +| attributes | Additional attributes (e.g. `policy` or `role`) | list(string) | `` | no | | aws_account_id | (Optional) AWS Account ID. 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 | | 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 | -| badge_enabled | Generates a publicly-accessible URL for the projects build badge. Available as badge_url attribute when enabled. | string | `false` | no | +| badge_enabled | Generates a publicly-accessible URL for the projects build badge. Available as badge_url attribute when enabled | bool | `false` | 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 | +| build_image | Docker image for build environment, e.g. 'aws/codebuild/standard:2.0' 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/standard:2.0` | 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 | +| 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 | bool | `true` | no | +| cache_enabled | If cache_enabled is true, create an S3 bucket for storing codebuild cache inside | bool | `true` | no | | cache_expiration_days | How many days should the build cache be kept | string | `7` | no | | delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | -| enabled | A boolean to enable/disable resource creation | string | `true` | no | -| environment_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build. | list | `` | no | +| enabled | A boolean to enable/disable resource creation | bool | `true` | no | +| environment_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build | object | `` | no | | github_token | (Optional) GitHub auth token environment variable (`GITHUB_TOKEN`) | string | `` | no | | image_repo_name | (Optional) ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html | string | `UNSET` | no | | image_tag | (Optional) Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html | string | `latest` | no | -| name | Solution name, e.g. 'app' or 'jenkins' | string | `codebuild` | no | -| namespace | Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse' | string | `global` | no | -| privileged_mode | (Optional) If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | string | `false` | no | -| report_build_status | Set to true to report the status of a build's start and finish to your source provider. This option is only valid when the source_type is BITBUCKET or GITHUB. | string | `false` | no | -| source_location | The location of the source code from git or s3. | string | `` | no | -| source_type | The type of repository that contains the source code to be built. Valid values for this parameter are: CODECOMMIT, CODEPIPELINE, GITHUB, GITHUB_ENTERPRISE, BITBUCKET or S3. | string | `CODEPIPELINE` | no | -| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `default` | no | -| tags | Additional tags (e.g. `map('BusinessUnit', 'XYZ')` | map | `` | no | +| name | Solution name, e.g. 'app' or 'jenkins' | string | - | yes | +| namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | `` | no | +| privileged_mode | (Optional) If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | bool | `false` | no | +| report_build_status | Set to true to report the status of a build's start and finish to your source provider. This option is only valid when the source_type is BITBUCKET or GITHUB | bool | `false` | no | +| source_location | The location of the source code from git or s3 | string | `` | no | +| source_type | The type of repository that contains the source code to be built. Valid values for this parameter are: CODECOMMIT, CODEPIPELINE, GITHUB, GITHUB_ENTERPRISE, BITBUCKET or S3 | string | `CODEPIPELINE` | no | +| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `` | no | +| tags | Additional tags (e.g. `map('BusinessUnit', 'XYZ')` | map(string) | `` | no | ## Outputs diff --git a/examples/complete/fixtures.us-west-1.tfvars b/examples/complete/fixtures.us-west-1.tfvars new file mode 100644 index 0000000..981cef6 --- /dev/null +++ b/examples/complete/fixtures.us-west-1.tfvars @@ -0,0 +1,27 @@ +region = "us-west-1" + +namespace = "eg" + +stage = "test" + +name = "cedebuild-test" + +cache_enabled = true + +cache_bucket_suffix_enabled = false + +environment_variables = [ + { + name = "APP_URL" + value = "https://app.example.com" + }, + { + name = "COMPANY_NAME" + value = "Cloud Posse" + }, + { + name = "TIME_ZONE" + value = "America/Los_Angeles" + + } +] diff --git a/examples/complete/main.tf b/examples/complete/main.tf new file mode 100644 index 0000000..f1a5e85 --- /dev/null +++ b/examples/complete/main.tf @@ -0,0 +1,13 @@ +provider "aws" { + region = var.region +} + +module "codebuild" { + source = "../../" + namespace = var.namespace + stage = var.stage + name = var.name + cache_enabled = var.cache_enabled + cache_bucket_suffix_enabled = var.cache_bucket_suffix_enabled + environment_variables = var.environment_variables +} diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf new file mode 100644 index 0000000..8b7c30a --- /dev/null +++ b/examples/complete/outputs.tf @@ -0,0 +1,34 @@ +output "project_name" { + description = "Project name" + value = module.codebuild.project_name +} + +output "project_id" { + description = "Project ID" + value = module.codebuild.project_id +} + +output "role_id" { + description = "IAM Role ID" + value = module.codebuild.role_id +} + +output "role_arn" { + description = "IAM Role ARN" + value = module.codebuild.role_arn +} + +output "cache_bucket_name" { + description = "Cache S3 bucket name" + value = module.codebuild.cache_bucket_name +} + +output "cache_bucket_arn" { + description = "Cache S3 bucket ARN" + value = module.codebuild.cache_bucket_arn +} + +output "badge_url" { + description = "The URL of the build badge when badge_enabled is enabled" + value = module.codebuild.badge_url +} diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf new file mode 100644 index 0000000..fec990f --- /dev/null +++ b/examples/complete/variables.tf @@ -0,0 +1,45 @@ +variable "region" { + type = string + description = "AWS region" +} + +variable "namespace" { + type = string + description = "Namespace, which could be your organization name, e.g. 'eg' or 'cp'" +} + +variable "stage" { + type = string + description = "Stage, e.g. 'prod', 'staging', 'dev', or 'test'" +} + +variable "name" { + type = string + description = "Solution name, e.g. 'app' or 'jenkins'" +} + +variable "environment_variables" { + type = list(object( + { + name = string + value = string + })) + + default = [ + { + name = "NO_ADDITIONAL_BUILD_VARS" + value = "TRUE" + }] + + description = "A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build" +} + +variable "cache_enabled" { + type = bool + description = "If cache_enabled is true, create an S3 bucket for storing codebuild cache inside" +} + +variable "cache_bucket_suffix_enabled" { + type = bool + description = "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" +} diff --git a/main.tf b/main.tf index 6215f3e..6eb83cf 100644 --- a/main.tf +++ b/main.tf @@ -1,39 +1,41 @@ -data "aws_caller_identity" "default" {} +data "aws_caller_identity" "default" { +} -data "aws_region" "default" {} +data "aws_region" "default" { +} -# Define composite variables for resources module "label" { - source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=tags/0.1.0" - namespace = "${var.namespace}" - name = "${var.name}" - stage = "${var.stage}" - delimiter = "${var.delimiter}" - attributes = "${var.attributes}" - tags = "${var.tags}" + source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=tags/0.4.0" + namespace = var.namespace + name = var.name + stage = var.stage + delimiter = var.delimiter + attributes = var.attributes + tags = var.tags } resource "aws_s3_bucket" "cache_bucket" { - count = "${var.enabled == "true" && var.cache_enabled == "true" ? 1 : 0}" - bucket = "${local.cache_bucket_name_normalised}" + count = var.enabled && var.cache_enabled ? 1 : 0 + bucket = local.cache_bucket_name_normalised acl = "private" force_destroy = true - tags = "${module.label.tags}" + tags = module.label.tags lifecycle_rule { id = "codebuildcache" enabled = true prefix = "/" - tags = "${module.label.tags}" + tags = module.label.tags expiration { - days = "${var.cache_expiration_days}" + days = var.cache_expiration_days } } } resource "random_string" "bucket_prefix" { + count = var.enabled ? 1 : 0 length = 12 number = false upper = false @@ -42,32 +44,37 @@ resource "random_string" "bucket_prefix" { } locals { - cache_bucket_name = "${module.label.id}${var.cache_bucket_suffix_enabled == "true" ? "-${random_string.bucket_prefix.result}" : "" }" + cache_bucket_name = "${module.label.id}${var.cache_bucket_suffix_enabled ? "-${join("", random_string.bucket_prefix.*.result)}" : ""}" ## Clean up the bucket name to use only hyphens, and trim its length to 63 characters. ## As per https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html - cache_bucket_name_normalised = "${substr(join("-", split("_", lower(local.cache_bucket_name))), 0, min(length(local.cache_bucket_name),63))}" + cache_bucket_name_normalised = substr( + join("-", split("_", lower(local.cache_bucket_name))), + 0, + min(length(local.cache_bucket_name), 63), + ) ## This is the magic where a map of a list of maps is generated ## and used to conditionally add the cache bucket option to the ## aws_codebuild_project cache_def = { - "true" = [{ - type = "S3" - location = "${var.enabled == "true" && var.cache_enabled == "true" ? join("", aws_s3_bucket.cache_bucket.*.bucket) : "none" }" - }] - + "true" = [ + { + type = "S3" + location = var.enabled && var.cache_enabled ? join("", aws_s3_bucket.cache_bucket.*.bucket) : "none" + } + ] "false" = [] } # Final Map Selected from above - cache = "${local.cache_def[var.cache_enabled]}" + cache = local.cache_def[var.cache_enabled ? "true" : "false"] } resource "aws_iam_role" "default" { - count = "${var.enabled == "true" ? 1 : 0}" - name = "${module.label.id}" - assume_role_policy = "${data.aws_iam_policy_document.role.json}" + count = var.enabled ? 1 : 0 + name = module.label.id + assume_role_policy = data.aws_iam_policy_document.role.json } data "aws_iam_policy_document" "role" { @@ -88,17 +95,17 @@ data "aws_iam_policy_document" "role" { } resource "aws_iam_policy" "default" { - count = "${var.enabled == "true" ? 1 : 0}" - name = "${module.label.id}" + count = var.enabled ? 1 : 0 + name = module.label.id path = "/service-role/" - policy = "${data.aws_iam_policy_document.permissions.json}" + policy = data.aws_iam_policy_document.permissions.json } resource "aws_iam_policy" "default_cache_bucket" { - count = "${var.enabled == "true" && var.cache_enabled == "true" ? 1 : 0}" + count = var.enabled && var.cache_enabled ? 1 : 0 name = "${module.label.id}-cache-bucket" path = "/service-role/" - policy = "${data.aws_iam_policy_document.permissions_cache_bucket.json}" + policy = join("", data.aws_iam_policy_document.permissions_cache_bucket.*.json) } data "aws_iam_policy_document" "permissions" { @@ -129,7 +136,7 @@ data "aws_iam_policy_document" "permissions" { } data "aws_iam_policy_document" "permissions_cache_bucket" { - count = "${var.enabled == "true" && var.cache_enabled == "true" ? 1 : 0}" + count = var.enabled && var.cache_enabled ? 1 : 0 statement { sid = "" @@ -141,78 +148,90 @@ data "aws_iam_policy_document" "permissions_cache_bucket" { effect = "Allow" resources = [ - "${aws_s3_bucket.cache_bucket.arn}", - "${aws_s3_bucket.cache_bucket.arn}/*", + join("", aws_s3_bucket.cache_bucket.*.arn), + "${join("", aws_s3_bucket.cache_bucket.*.arn)}/*", ] } } resource "aws_iam_role_policy_attachment" "default" { - count = "${var.enabled == "true" ? 1 : 0}" - policy_arn = "${aws_iam_policy.default.arn}" - role = "${aws_iam_role.default.id}" + count = var.enabled ? 1 : 0 + policy_arn = join("", aws_iam_policy.default.*.arn) + role = join("", aws_iam_role.default.*.id) } resource "aws_iam_role_policy_attachment" "default_cache_bucket" { - count = "${var.enabled == "true" && var.cache_enabled == "true" ? 1 : 0}" - policy_arn = "${element(aws_iam_policy.default_cache_bucket.*.arn, count.index)}" - role = "${aws_iam_role.default.id}" + count = var.enabled && var.cache_enabled ? 1 : 0 + policy_arn = join("", aws_iam_policy.default_cache_bucket.*.arn) + role = join("", aws_iam_role.default.*.id) } resource "aws_codebuild_project" "default" { - count = "${var.enabled == "true" ? 1 : 0}" - name = "${module.label.id}" - service_role = "${aws_iam_role.default.arn}" - badge_enabled = "${var.badge_enabled}" - build_timeout = "${var.build_timeout}" + count = var.enabled ? 1 : 0 + name = module.label.id + service_role = join("", aws_iam_role.default.*.arn) + badge_enabled = var.badge_enabled + build_timeout = var.build_timeout artifacts { - type = "${var.artifact_type}" + type = var.artifact_type } - # The cache as a list with a map object inside. - cache = ["${local.cache}"] + dynamic "cache" { + for_each = local.cache + content { + location = lookup(cache.value, "location", null) + modes = lookup(cache.value, "modes", null) + type = lookup(cache.value, "type", null) + } + } environment { - compute_type = "${var.build_compute_type}" - image = "${var.build_image}" + compute_type = var.build_compute_type + image = var.build_image type = "LINUX_CONTAINER" - privileged_mode = "${var.privileged_mode}" + privileged_mode = var.privileged_mode - environment_variable = [{ - "name" = "AWS_REGION" - "value" = "${signum(length(var.aws_region)) == 1 ? var.aws_region : data.aws_region.default.name}" - }, - { - "name" = "AWS_ACCOUNT_ID" - "value" = "${signum(length(var.aws_account_id)) == 1 ? var.aws_account_id : data.aws_caller_identity.default.account_id}" - }, - { - "name" = "IMAGE_REPO_NAME" - "value" = "${signum(length(var.image_repo_name)) == 1 ? var.image_repo_name : "UNSET"}" - }, - { - "name" = "IMAGE_TAG" - "value" = "${signum(length(var.image_tag)) == 1 ? var.image_tag : "latest"}" - }, - { - "name" = "STAGE" - "value" = "${signum(length(var.stage)) == 1 ? var.stage : "UNSET"}" - }, - { - "name" = "GITHUB_TOKEN" - "value" = "${signum(length(var.github_token)) == 1 ? var.github_token : "UNSET"}" - }, - "${var.environment_variables}", - ] + environment_variable { + name = "AWS_REGION" + value = signum(length(var.aws_region)) == 1 ? var.aws_region : data.aws_region.default.name + } + environment_variable { + name = "AWS_ACCOUNT_ID" + value = signum(length(var.aws_account_id)) == 1 ? var.aws_account_id : data.aws_caller_identity.default.account_id + } + environment_variable { + name = "IMAGE_REPO_NAME" + value = signum(length(var.image_repo_name)) == 1 ? var.image_repo_name : "UNSET" + } + environment_variable { + name = "IMAGE_TAG" + value = signum(length(var.image_tag)) == 1 ? var.image_tag : "latest" + } + environment_variable { + name = "STAGE" + value = signum(length(var.stage)) == 1 ? var.stage : "UNSET" + } + environment_variable { + name = "GITHUB_TOKEN" + value = signum(length(var.github_token)) == 1 ? var.github_token : "UNSET" + } + + dynamic "environment_variable" { + for_each = var.environment_variables + content { + name = environment_variable.value.name + value = environment_variable.value.value + } + } } source { - buildspec = "${var.buildspec}" - type = "${var.source_type}" - location = "${var.source_location}" - report_build_status = "${var.report_build_status}" + buildspec = var.buildspec + type = var.source_type + location = var.source_location + report_build_status = var.report_build_status } - tags = "${module.label.tags}" + tags = module.label.tags } diff --git a/outputs.tf b/outputs.tf index 75453c3..0c500a2 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,34 +1,34 @@ output "project_name" { description = "Project name" - value = "${join("", aws_codebuild_project.default.*.name)}" + value = join("", aws_codebuild_project.default.*.name) } output "project_id" { description = "Project ID" - value = "${join("", aws_codebuild_project.default.*.id)}" + value = join("", aws_codebuild_project.default.*.id) } output "role_id" { description = "IAM Role ID" - value = "${join("", aws_iam_role.default.*.id)}" + value = join("", aws_iam_role.default.*.id) } output "role_arn" { description = "IAM Role ARN" - value = "${join("", aws_iam_role.default.*.arn)}" + value = join("", aws_iam_role.default.*.arn) } output "cache_bucket_name" { description = "Cache S3 bucket name" - value = "${var.enabled == "true" && var.cache_enabled == "true" ? join("", aws_s3_bucket.cache_bucket.*.bucket) : "UNSET" }" + value = var.enabled && var.cache_enabled ? join("", aws_s3_bucket.cache_bucket.*.bucket) : "UNSET" } output "cache_bucket_arn" { description = "Cache S3 bucket ARN" - value = "${var.enabled == "true" && var.cache_enabled == "true" ? join("", aws_s3_bucket.cache_bucket.*.arn) : "UNSET" }" + value = var.enabled && var.cache_enabled ? join("", aws_s3_bucket.cache_bucket.*.arn) : "UNSET" } output "badge_url" { description = "The URL of the build badge when badge_enabled is enabled" - value = "${join("", aws_codebuild_project.default.*.badge_url)}" + value = join("", aws_codebuild_project.default.*.badge_url) } diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..442804a --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +.test-harness diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..17b2fe7 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,43 @@ +TEST_HARNESS ?= https://github.com/cloudposse/test-harness.git +TEST_HARNESS_BRANCH ?= master +TEST_HARNESS_PATH = $(realpath .test-harness) +BATS_ARGS ?= --tap +BATS_LOG ?= test.log + +# Define a macro to run the tests +define RUN_TESTS +@echo "Running tests in $(1)" +@cd $(1) && bats $(BATS_ARGS) $(addsuffix .bats,$(addprefix $(TEST_HARNESS_PATH)/test/terraform/,$(TESTS))) +endef + +default: all + +-include Makefile.* + +## Provision the test-harnesss +.test-harness: + [ -d $@ ] || git clone --depth=1 -b $(TEST_HARNESS_BRANCH) $(TEST_HARNESS) $@ + +## Initialize the tests +init: .test-harness + +## Install all dependencies (OS specific) +deps:: + @exit 0 + +## Clean up the test harness +clean: + [ "$(TEST_HARNESS_PATH)" == "/" ] || rm -rf $(TEST_HARNESS_PATH) + +## Run all tests +all: module examples/complete + +## Run basic sanity checks against the module itself +module: export TESTS ?= installed lint get-modules module-pinning get-plugins provider-pinning validate terraform-docs input-descriptions output-descriptions +module: deps + $(call RUN_TESTS, ../) + +## Run tests against example +examples/complete: export TESTS ?= installed lint get-modules get-plugins validate +examples/complete: deps + $(call RUN_TESTS, ../$@) diff --git a/test/Makefile.alpine b/test/Makefile.alpine new file mode 100644 index 0000000..7925b18 --- /dev/null +++ b/test/Makefile.alpine @@ -0,0 +1,5 @@ +ifneq (,$(wildcard /sbin/apk)) +## Install all dependencies for alpine +deps:: init + @apk add --update terraform-docs@cloudposse json2hcl@cloudposse +endif diff --git a/test/src/.gitignore b/test/src/.gitignore new file mode 100644 index 0000000..31b0219 --- /dev/null +++ b/test/src/.gitignore @@ -0,0 +1,2 @@ +.gopath +vendor/ diff --git a/test/src/Gopkg.lock b/test/src/Gopkg.lock new file mode 100644 index 0000000..87bb6bd --- /dev/null +++ b/test/src/Gopkg.lock @@ -0,0 +1,92 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" + name = "github.com/davecgh/go-spew" + packages = ["spew"] + pruneopts = "UT" + revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" + version = "v1.1.1" + +[[projects]] + digest = "1:75d6042fc66aebc974cc49b0c6c7cc3b9adb5f8130fbfa0dbec0820d990afa25" + name = "github.com/gruntwork-io/terratest" + packages = [ + "modules/collections", + "modules/customerrors", + "modules/files", + "modules/logger", + "modules/retry", + "modules/shell", + "modules/ssh", + "modules/terraform", + ] + pruneopts = "UT" + revision = "892abb2c35878d0808101bbfe6559e931dc2d354" + version = "v0.16.0" + +[[projects]] + digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" + name = "github.com/pmezard/go-difflib" + packages = ["difflib"] + pruneopts = "UT" + revision = "792786c7400a136282c1664665ae0a8db921c6c2" + version = "v1.0.0" + +[[projects]] + digest = "1:5da8ce674952566deae4dbc23d07c85caafc6cfa815b0b3e03e41979cedb8750" + name = "github.com/stretchr/testify" + packages = [ + "assert", + "require", + ] + pruneopts = "UT" + revision = "ffdc059bfe9ce6a4e144ba849dbedead332c6053" + version = "v1.3.0" + +[[projects]] + branch = "master" + digest = "1:831470c2758c8b733941144f2803a0ccad0632c5a767415b777ebd296b5f463e" + name = "golang.org/x/crypto" + packages = [ + "curve25519", + "ed25519", + "ed25519/internal/edwards25519", + "internal/chacha20", + "internal/subtle", + "poly1305", + "ssh", + "ssh/agent", + ] + pruneopts = "UT" + revision = "22d7a77e9e5f409e934ed268692e56707cd169e5" + +[[projects]] + branch = "master" + digest = "1:76ee51c3f468493aff39dbacc401e8831fbb765104cbf613b89bef01cf4bad70" + name = "golang.org/x/net" + packages = ["context"] + pruneopts = "UT" + revision = "f3200d17e092c607f615320ecaad13d87ad9a2b3" + +[[projects]] + branch = "master" + digest = "1:181f3fd33e620b958b5ab77da177cf775cdcccd7db82963607875fbd09ae995e" + name = "golang.org/x/sys" + packages = [ + "cpu", + "unix", + ] + pruneopts = "UT" + revision = "9cd6430ef91e39e1a0ec0470cf1321a33ef1b887" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + input-imports = [ + "github.com/gruntwork-io/terratest/modules/terraform", + "github.com/stretchr/testify/assert", + ] + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/test/src/Gopkg.toml b/test/src/Gopkg.toml new file mode 100644 index 0000000..995bac5 --- /dev/null +++ b/test/src/Gopkg.toml @@ -0,0 +1,7 @@ +[[constraint]] + name = "github.com/stretchr/testify" + version = "1.2.2" + +[prune] + go-tests = true + unused-packages = true diff --git a/test/src/Makefile b/test/src/Makefile new file mode 100644 index 0000000..3b2e3f7 --- /dev/null +++ b/test/src/Makefile @@ -0,0 +1,50 @@ +PACKAGE = terraform-aws-codebuild +GOEXE ?= /usr/bin/go +GOPATH = $(CURDIR)/.gopath +GOBIN = $(GOPATH)/bin +BASE = $(GOPATH)/src/$(PACKAGE) +PATH := $(PATH):$(GOBIN) + +export TF_DATA_DIR ?= $(CURDIR)/.terraform +export TF_CLI_ARGS_init ?= -get-plugins=true +export GOPATH + +.PHONY: all +## Default target +all: test + +ifneq (,$(wildcard /sbin/apk)) +## Install go, if not installed +$(GOEXE): + apk add --update go +endif + +ifeq ($(shell uname -s),Linux) +## Install all `dep`, if not installed +$(GOBIN)/dep: + @mkdir -p $(GOBIN) + @curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh +endif + +## Prepare the GOPATH +$(BASE): $(GOEXE) + @mkdir -p $(dir $@) + @ln -sf $(CURDIR) $@ + +## Download vendor dependencies to vendor/ +$(BASE)/vendor: $(BASE) $(GOBIN)/dep + cd $(BASE) && dep ensure + +.PHONY : init +## Initialize tests +init: $(BASE)/vendor + +.PHONY : test +## Run tests +test: init + cd $(BASE) && go test -v -timeout 30m -run TestExamplesComplete + +.PHONY : clean +## Clean up files +clean: + rm -rf .gopath/ vendor/ $(TF_DATA_DIR) diff --git a/test/src/examples_complete_test.go b/test/src/examples_complete_test.go new file mode 100644 index 0000000..0de1da6 --- /dev/null +++ b/test/src/examples_complete_test.go @@ -0,0 +1,41 @@ +package test + +import ( + "testing" + + "github.com/gruntwork-io/terratest/modules/terraform" + "github.com/stretchr/testify/assert" +) + +// Test the Terraform module in examples/complete using Terratest. +func TestExamplesComplete(t *testing.T) { + t.Parallel() + + terraformOptions := &terraform.Options{ + // The path to where our Terraform code is located + TerraformDir: "../../examples/complete", + Upgrade: true, + // Variables to pass to our Terraform code using -var-file options + VarFiles: []string{"fixtures.us-west-1.tfvars"}, + } + + // At the end of the test, run `terraform destroy` to clean up any resources that were created + defer terraform.Destroy(t, terraformOptions) + + // This will run `terraform init` and `terraform apply` and fail the test if there are any errors + terraform.InitAndApply(t, terraformOptions) + + // Run `terraform output` to get the value of an output variable + projectName := terraform.Output(t, terraformOptions, "project_name") + + expectedProjectName := "eg-test-cedebuild-test" + // Verify we're getting back the outputs we expect + assert.Equal(t, expectedProjectName, projectName) + + // Run `terraform output` to get the value of an output variable + cacheS3BucketName := terraform.Output(t, terraformOptions, "cache_bucket_name") + + expectedCacheS3BucketName := "eg-test-cedebuild-test" + // Verify we're getting back the outputs we expect + assert.Equal(t, expectedCacheS3BucketName, cacheS3BucketName) +} diff --git a/variables.tf b/variables.tf index dab7fc5..e11d25e 100644 --- a/variables.tf +++ b/variables.tf @@ -1,160 +1,162 @@ variable "namespace" { - type = "string" - default = "global" - description = "Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse'" + type = string + default = "" + description = "Namespace, which could be your organization name, e.g. 'eg' or 'cp'" } variable "stage" { - type = "string" - default = "default" + type = string + default = "" description = "Stage, e.g. 'prod', 'staging', 'dev', or 'test'" } variable "name" { - type = "string" - default = "codebuild" + type = string description = "Solution name, e.g. 'app' or 'jenkins'" } variable "environment_variables" { - type = "list" - - default = [{ - "name" = "NO_ADDITIONAL_BUILD_VARS" - "value" = "TRUE" + type = list(object( + { + name = string + value = string + })) + + default = [ + { + name = "NO_ADDITIONAL_BUILD_VARS" + value = "TRUE" }] - description = "A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build." + description = "A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build" } variable "enabled" { - type = "string" - default = "true" + type = bool + default = true description = "A boolean to enable/disable resource creation" } variable "cache_enabled" { - type = "string" - default = "true" + type = bool + default = true description = "If cache_enabled is true, create an S3 bucket for storing codebuild cache inside" } variable "cache_expiration_days" { - type = "string" - default = "7" + default = 7 description = "How many days should the build cache be kept" } variable "cache_bucket_suffix_enabled" { - type = "string" - default = "true" + type = bool + default = true description = "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" } variable "badge_enabled" { - type = "string" - default = "false" - description = "Generates a publicly-accessible URL for the projects build badge. Available as badge_url attribute when enabled." + type = bool + default = false + description = "Generates a publicly-accessible URL for the projects build badge. Available as badge_url attribute when enabled" } variable "build_image" { - type = "string" - default = "aws/codebuild/docker:1.12.1" - description = "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" + type = string + default = "aws/codebuild/standard:2.0" + description = "Docker image for build environment, e.g. 'aws/codebuild/standard:2.0' 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" } variable "build_compute_type" { - type = "string" + type = string default = "BUILD_GENERAL1_SMALL" 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." + 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" + type = string default = "" description = "Optional buildspec declaration to use for building the project" } variable "delimiter" { - type = "string" + type = string default = "-" description = "Delimiter to be used between `name`, `namespace`, `stage`, etc." } variable "attributes" { - type = "list" + type = list(string) default = [] description = "Additional attributes (e.g. `policy` or `role`)" } variable "tags" { - type = "map" + type = map(string) default = {} description = "Additional tags (e.g. `map('BusinessUnit', 'XYZ')`" } variable "privileged_mode" { - type = "string" - default = "false" + type = bool + default = false description = "(Optional) If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images" } variable "github_token" { - type = "string" + type = string default = "" description = "(Optional) GitHub auth token environment variable (`GITHUB_TOKEN`)" } variable "aws_region" { - type = "string" + type = string default = "" description = "(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" } variable "aws_account_id" { - type = "string" + type = string default = "" description = "(Optional) AWS Account ID. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html" } variable "image_repo_name" { - type = "string" + type = string default = "UNSET" description = "(Optional) ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html" } variable "image_tag" { - type = "string" + type = string default = "latest" description = "(Optional) Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html" } variable "source_type" { - type = "string" + type = string default = "CODEPIPELINE" - description = "The type of repository that contains the source code to be built. Valid values for this parameter are: CODECOMMIT, CODEPIPELINE, GITHUB, GITHUB_ENTERPRISE, BITBUCKET or S3." + description = "The type of repository that contains the source code to be built. Valid values for this parameter are: CODECOMMIT, CODEPIPELINE, GITHUB, GITHUB_ENTERPRISE, BITBUCKET or S3" } variable "source_location" { - type = "string" + type = string default = "" - description = "The location of the source code from git or s3." + description = "The location of the source code from git or s3" } variable "artifact_type" { - type = "string" + type = string default = "CODEPIPELINE" - description = "The build output artifact's type. Valid values for this parameter are: CODEPIPELINE, NO_ARTIFACTS or S3." + description = "The build output artifact's type. Valid values for this parameter are: CODEPIPELINE, NO_ARTIFACTS or S3" } variable "report_build_status" { - type = "string" - default = "false" - description = "Set to true to report the status of a build's start and finish to your source provider. This option is only valid when the source_type is BITBUCKET or GITHUB." + type = bool + default = false + description = "Set to true to report the status of a build's start and finish to your source provider. This option is only valid when the source_type is BITBUCKET or GITHUB" } diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..517cebf --- /dev/null +++ b/versions.tf @@ -0,0 +1,11 @@ +terraform { + required_version = "~> 0.12.0" + + required_providers { + aws = "~> 2.0" + template = "~> 2.0" + local = "~> 1.2" + random = "~> 2.1" + null = "~> 2.0" + } +}