From a32e6c857501041aaaae6f2af67afcfee0856eab Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 19 Aug 2020 10:44:19 -0700 Subject: [PATCH] Additional TF 0.13 Fixes (#44) * Support terraform 0.13 * Fix example * Fix example * Fix example * Fix example * Fix example * Fix example * Fix example Co-authored-by: aknysh --- .github/CODEOWNERS | 12 ++- .github/auto-release.yml | 40 +++++++++ .github/workflows/auto-release.yml | 19 +++++ .github/workflows/chatops.yml | 8 +- README.md | 3 +- docs/terraform.md | 3 +- examples/complete/fixtures.us-east-2.tfvars | 2 - examples/complete/main.tf | 26 +++--- examples/complete/outputs.tf | 8 +- examples/complete/variables.tf | 8 +- examples/complete/versions.tf | 2 +- main.tf | 89 ++++++++++---------- test/src/Gopkg.lock | 92 --------------------- test/src/Gopkg.toml | 7 -- test/src/Makefile | 48 ++++------- test/src/examples_complete_test.go | 13 +-- test/src/go.mod | 14 ++++ test/src/go.sum | 41 +++++++++ variables.tf | 6 ++ versions.tf | 2 +- 20 files changed, 231 insertions(+), 212 deletions(-) create mode 100644 .github/auto-release.yml create mode 100644 .github/workflows/auto-release.yml delete mode 100644 test/src/Gopkg.lock delete mode 100644 test/src/Gopkg.toml create mode 100644 test/src/go.mod create mode 100644 test/src/go.sum diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 41c1baa..bed3c96 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,14 @@ # Use this file to define individuals or teams that are responsible for code in a repository. # Read more: +# +# Order is important: the last matching pattern takes the most precedence -* @cloudposse/engineering \ No newline at end of file +# These owners will be the default owners for everything +* @cloudposse/engineering @cloudposse/contributors + +# Cloud Posse must review any changes to Makefiles +**/Makefile @cloudposse/engineering +**/Makefile.* @cloudposse/engineering + +# Cloud Posse must review any changes to GitHub actions +.github/* @cloudposse/engineering diff --git a/.github/auto-release.yml b/.github/auto-release.yml new file mode 100644 index 0000000..2836185 --- /dev/null +++ b/.github/auto-release.yml @@ -0,0 +1,40 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: '$RESOLVED_VERSION' +version-template: '$MAJOR.$MINOR.$PATCH' +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + - 'enhancement' + patch: + labels: + - 'patch' + - 'fix' + - 'bugfix' + - 'bug' + - 'hotfix' + default: 'minor' + +categories: + - title: '🚀 Enhancements' + labels: + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - 'hotfix' + +change-template: | +
+ $TITLE @$AUTHOR (#$NUMBER) + + $BODY +
+ +template: | + $CHANGES diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..e21fbfe --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,19 @@ +name: auto-release + +on: + push: + branches: + - master + +jobs: + semver: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + publish: true + prerelease: false + config-name: auto-release.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/chatops.yml b/.github/workflows/chatops.yml index a6bb11b..0d94310 100644 --- a/.github/workflows/chatops.yml +++ b/.github/workflows/chatops.yml @@ -9,13 +9,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: "Handle common commands" - uses: cloudposse/actions/github/slash-command-dispatch@0.15.0 + uses: cloudposse/actions/github/slash-command-dispatch@0.16.0 with: token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} reaction-token: ${{ secrets.GITHUB_TOKEN }} repository: cloudposse/actions commands: rebuild-readme, terraform-fmt - permission: none + permission: triage issue-type: pull-request test: @@ -24,13 +24,13 @@ jobs: - name: "Checkout commit" uses: actions/checkout@v2 - name: "Run tests" - uses: cloudposse/actions/github/slash-command-dispatch@0.15.0 + uses: cloudposse/actions/github/slash-command-dispatch@0.16.0 with: token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} reaction-token: ${{ secrets.GITHUB_TOKEN }} repository: cloudposse/actions commands: test - permission: none + permission: triage issue-type: pull-request reactions: false diff --git a/README.md b/README.md index 85feb02..2da889e 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ Available targets: | Name | Version | |------|---------| -| terraform | >= 0.12.0, < 0.14.0 | +| terraform | >= 0.12.0 | | aws | ~> 2.0 | | local | ~> 1.2 | | null | ~> 2.0 | @@ -206,6 +206,7 @@ Available targets: | delimiter | Delimiter between `namespace`, `stage`, `name` and `attributes` | `string` | `"-"` | no | | ecs\_cluster\_name | ECS Cluster Name | `string` | n/a | yes | | enabled | Enable `CodePipeline` creation | `bool` | `true` | no | +| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | `string` | `""` | 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(object(
{
name = string
value = string
}))
| `[]` | no | | github\_anonymous | Github Anonymous API (if `true`, token must not be set as GITHUB\_TOKEN or `github_token`) | `bool` | `false` | no | | github\_oauth\_token | GitHub OAuth Token with permissions to access private repositories | `string` | `""` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 112f3fd..a5ecc33 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -2,7 +2,7 @@ | Name | Version | |------|---------| -| terraform | >= 0.12.0, < 0.14.0 | +| terraform | >= 0.12.0 | | aws | ~> 2.0 | | local | ~> 1.2 | | null | ~> 2.0 | @@ -33,6 +33,7 @@ | delimiter | Delimiter between `namespace`, `stage`, `name` and `attributes` | `string` | `"-"` | no | | ecs\_cluster\_name | ECS Cluster Name | `string` | n/a | yes | | enabled | Enable `CodePipeline` creation | `bool` | `true` | no | +| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | `string` | `""` | 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(object(
{
name = string
value = string
}))
| `[]` | no | | github\_anonymous | Github Anonymous API (if `true`, token must not be set as GITHUB\_TOKEN or `github_token`) | `bool` | `false` | no | | github\_oauth\_token | GitHub OAuth Token with permissions to access private repositories | `string` | `""` | no | diff --git a/examples/complete/fixtures.us-east-2.tfvars b/examples/complete/fixtures.us-east-2.tfvars index 3a1c570..608533e 100644 --- a/examples/complete/fixtures.us-east-2.tfvars +++ b/examples/complete/fixtures.us-east-2.tfvars @@ -104,8 +104,6 @@ webhook_enabled = false s3_bucket_force_destroy = true -cache_type = "S3" - environment_variables = [ { name = "APP_URL" diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 6d8aabb..1c43fd6 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -3,17 +3,18 @@ provider "aws" { } module "label" { - source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.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-null-label.git?ref=tags/0.17.0" + namespace = var.namespace + environment = var.environment + stage = var.stage + name = var.name + delimiter = var.delimiter + attributes = var.attributes + tags = var.tags } module "vpc" { - source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.8.1" + source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.16.1" namespace = var.namespace stage = var.stage name = var.name @@ -24,7 +25,7 @@ module "vpc" { } module "subnets" { - source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.19.0" + source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.26.0" availability_zones = var.availability_zones namespace = var.namespace stage = var.stage @@ -45,7 +46,7 @@ resource "aws_ecs_cluster" "default" { } module "container_definition" { - source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git?ref=tags/0.21.0" + source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git?ref=tags/0.41.0" container_name = var.container_name container_image = var.container_image container_memory = var.container_memory @@ -58,14 +59,14 @@ module "container_definition" { } module "ecs_alb_service_task" { - source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.17.0" + source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.39.0" namespace = var.namespace stage = var.stage name = var.name attributes = var.attributes delimiter = var.delimiter alb_security_group = module.vpc.vpc_default_security_group_id - container_definition_json = module.container_definition.json + container_definition_json = module.container_definition.json_map_encoded_list ecs_cluster_arn = aws_ecs_cluster.default.arn launch_type = var.ecs_launch_type vpc_id = module.vpc.vpc_id @@ -87,6 +88,7 @@ module "ecs_alb_service_task" { module "ecs_codepipeline" { source = "../../" namespace = var.namespace + environment = var.environment stage = var.stage name = var.name region = var.region diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf index 042eafd..f72bba8 100644 --- a/examples/complete/outputs.tf +++ b/examples/complete/outputs.tf @@ -14,13 +14,13 @@ output "vpc_cidr" { } output "container_definition_json" { - value = module.container_definition.json - description = "JSON encoded list of container definitions for use with other terraform resources such as aws_ecs_task_definition" + value = module.container_definition.json_map_encoded_list + description = "JSON encoded list of container definitions for use with other terraform resources such as `aws_ecs_task_definition`" } output "container_definition_json_map" { - value = module.container_definition.json_map - description = "JSON encoded container definitions for use with other terraform resources such as aws_ecs_task_definition" + value = module.container_definition.json_map_encoded + description = "JSON encoded container definitions for use with other terraform resources such as `aws_ecs_task_definition`" } output "ecs_cluster_id" { diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf index 52fa3d6..1111f12 100644 --- a/examples/complete/variables.tf +++ b/examples/complete/variables.tf @@ -1,6 +1,6 @@ variable "region" { type = string - description = "AWS Region for S3 bucket" + description = "AWS Region" } variable "availability_zones" { @@ -18,6 +18,12 @@ variable "namespace" { description = "Namespace (e.g. `eg` or `cp`)" } +variable "environment" { + type = string + default = "" + description = "Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT'" +} + variable "stage" { type = string description = "Stage (e.g. `prod`, `dev`, `staging`)" diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 517cebf..287fdab 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = "~> 0.12.0" + required_version = ">= 0.12.0" required_providers { aws = "~> 2.0" diff --git a/main.tf b/main.tf index b74dd04..9a971e8 100644 --- a/main.tf +++ b/main.tf @@ -1,12 +1,13 @@ module "codepipeline_label" { - source = "github.com/cloudposse/terraform-null-label.git?ref=0.16.0" - enabled = var.enabled - attributes = compact(concat(var.attributes, ["codepipeline"])) - delimiter = var.delimiter - name = var.name - namespace = var.namespace - stage = var.stage - tags = var.tags + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0" + enabled = var.enabled + attributes = compact(concat(var.attributes, ["codepipeline"])) + delimiter = var.delimiter + name = var.name + namespace = var.namespace + environment = var.environment + stage = var.stage + tags = var.tags } resource "aws_s3_bucket" "default" { @@ -18,14 +19,15 @@ resource "aws_s3_bucket" "default" { } module "codepipeline_assume_role_label" { - source = "github.com/cloudposse/terraform-null-label.git?ref=0.16.0" - enabled = var.enabled - attributes = compact(concat(var.attributes, ["codepipeline", "assume"])) - delimiter = var.delimiter - name = var.name - namespace = var.namespace - stage = var.stage - tags = var.tags + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0" + enabled = var.enabled + attributes = compact(concat(var.attributes, ["codepipeline", "assume"])) + delimiter = var.delimiter + name = var.name + namespace = var.namespace + environment = var.environment + stage = var.stage + tags = var.tags } resource "aws_iam_role" "default" { @@ -93,14 +95,15 @@ resource "aws_iam_role_policy_attachment" "s3" { } module "codepipeline_s3_policy_label" { - source = "github.com/cloudposse/terraform-null-label.git?ref=0.16.0" - enabled = var.enabled - attributes = compact(concat(var.attributes, ["codepipeline", "s3"])) - delimiter = var.delimiter - name = var.name - namespace = var.namespace - stage = var.stage - tags = var.tags + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0" + enabled = var.enabled + attributes = compact(concat(var.attributes, ["codepipeline", "s3"])) + delimiter = var.delimiter + name = var.name + namespace = var.namespace + environment = var.environment + stage = var.stage + tags = var.tags } resource "aws_iam_policy" "s3" { @@ -138,14 +141,15 @@ resource "aws_iam_role_policy_attachment" "codebuild" { } module "codebuild_label" { - source = "github.com/cloudposse/terraform-null-label.git?ref=0.16.0" - enabled = var.enabled - attributes = compact(concat(var.attributes, ["codebuild"])) - delimiter = var.delimiter - name = var.name - namespace = var.namespace - stage = var.stage - tags = var.tags + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0" + enabled = var.enabled + attributes = compact(concat(var.attributes, ["codebuild"])) + delimiter = var.delimiter + name = var.name + namespace = var.namespace + environment = var.environment + stage = var.stage + tags = var.tags } resource "aws_iam_policy" "codebuild" { @@ -175,14 +179,15 @@ resource "aws_iam_role_policy_attachment" "codestar" { } module "codestar_label" { - source = "github.com/cloudposse/terraform-null-label.git?ref=0.16.0" - enabled = var.enabled && var.codestar_connection_arn != "" - attributes = compact(concat(var.attributes, ["codestar"])) - delimiter = var.delimiter - name = var.name - namespace = var.namespace - stage = var.stage - tags = var.tags + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0" + enabled = var.enabled && var.codestar_connection_arn != "" + attributes = compact(concat(var.attributes, ["codestar"])) + delimiter = var.delimiter + name = var.name + namespace = var.namespace + environment = var.environment + stage = var.stage + tags = var.tags } resource "aws_iam_policy" "codestar" { @@ -221,7 +226,7 @@ data "aws_region" "default" { } module "codebuild" { - source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.21.0" + source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.23.0" enabled = var.enabled namespace = var.namespace name = var.name @@ -435,7 +440,7 @@ resource "aws_codepipeline_webhook" "webhook" { } module "github_webhooks" { - source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=tags/0.8.0" + source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=tags/0.10.0" enabled = var.enabled && var.webhook_enabled ? true : false github_anonymous = var.github_anonymous github_organization = var.repo_owner diff --git a/test/src/Gopkg.lock b/test/src/Gopkg.lock deleted file mode 100644 index 87bb6bd..0000000 --- a/test/src/Gopkg.lock +++ /dev/null @@ -1,92 +0,0 @@ -# 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 deleted file mode 100644 index 995bac5..0000000 --- a/test/src/Gopkg.toml +++ /dev/null @@ -1,7 +0,0 @@ -[[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 index 7b2e074..2707cd2 100644 --- a/test/src/Makefile +++ b/test/src/Makefile @@ -1,50 +1,30 @@ -PACKAGE = terraform-aws-ecs-codepipeline -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 +export TERRAFORM_VERSION ?= $(shell curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version' | cut -d. -f1-2) + +.DEFAULT_GOAL : all .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 +init: + @exit 0 .PHONY : test ## Run tests test: init - cd $(BASE) && go test -v -timeout 30m -run TestExamplesComplete + go mod download + go test -v -timeout 60m -run TestExamplesComplete + +## Run tests in docker container +docker/test: + docker run --name terratest --rm -it -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e GITHUB_TOKEN \ + -e PATH="/usr/local/terraform/$(TERRAFORM_VERSION)/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ + -v $(CURDIR)/../../:/module/ cloudposse/test-harness:latest -C /module/test/src test .PHONY : clean ## Clean up files clean: - rm -rf .gopath/ vendor/ $(TF_DATA_DIR) + rm -rf ../../examples/complete/*.tfstate* diff --git a/test/src/examples_complete_test.go b/test/src/examples_complete_test.go index cbc65fb..b97ac2d 100644 --- a/test/src/examples_complete_test.go +++ b/test/src/examples_complete_test.go @@ -58,12 +58,12 @@ func TestExamplesComplete(t *testing.T) { // Run `terraform output` to get the value of an output variable ecsClusterId := terraform.Output(t, terraformOptions, "ecs_cluster_id") // Verify we're getting back the outputs we expect - assert.Equal(t, "arn:aws:ecs:us-east-2:126450723953:cluster/eg-test-ecs-codepipeline", ecsClusterId) + assert.Contains(t, ecsClusterId, "cluster/eg-test-ecs-codepipeline") // Run `terraform output` to get the value of an output variable ecsClusterArn := terraform.Output(t, terraformOptions, "ecs_cluster_arn") // Verify we're getting back the outputs we expect - assert.Equal(t, "arn:aws:ecs:us-east-2:126450723953:cluster/eg-test-ecs-codepipeline", ecsClusterArn) + assert.Contains(t, ecsClusterArn, "cluster/eg-test-ecs-codepipeline") // Run `terraform output` to get the value of an output variable ecsExecRolePolicyName := terraform.Output(t, terraformOptions, "ecs_exec_role_policy_name") @@ -75,11 +75,6 @@ func TestExamplesComplete(t *testing.T) { // Verify we're getting back the outputs we expect assert.Equal(t, "eg-test-ecs-codepipeline", serviceName) - // Run `terraform output` to get the value of an output variable - serviceRoleArn := terraform.Output(t, terraformOptions, "service_role_arn") - // Verify we're getting back the outputs we expect - assert.Equal(t, "arn:aws:iam::126450723953:role/eg-test-ecs-codepipeline-service", serviceRoleArn) - // Run `terraform output` to get the value of an output variable taskDefinitionFamily := terraform.Output(t, terraformOptions, "task_definition_family") // Verify we're getting back the outputs we expect @@ -93,7 +88,7 @@ func TestExamplesComplete(t *testing.T) { // Run `terraform output` to get the value of an output variable taskExecRoleArn := terraform.Output(t, terraformOptions, "task_exec_role_arn") // Verify we're getting back the outputs we expect - assert.Equal(t, "arn:aws:iam::126450723953:role/eg-test-ecs-codepipeline-exec", taskExecRoleArn) + assert.Contains(t, taskExecRoleArn, "role/eg-test-ecs-codepipeline-exec") // Run `terraform output` to get the value of an output variable taskRoleName := terraform.Output(t, terraformOptions, "task_role_name") @@ -103,7 +98,7 @@ func TestExamplesComplete(t *testing.T) { // Run `terraform output` to get the value of an output variable taskRoleArn := terraform.Output(t, terraformOptions, "task_role_arn") // Verify we're getting back the outputs we expect - assert.Equal(t, "arn:aws:iam::126450723953:role/eg-test-ecs-codepipeline-task", taskRoleArn) + assert.Contains(t, taskRoleArn, "role/eg-test-ecs-codepipeline-task") // Run `terraform output` to get the value of an output variable codebuildProjectName := terraform.Output(t, terraformOptions, "codebuild_project_name") diff --git a/test/src/go.mod b/test/src/go.mod new file mode 100644 index 0000000..fa6b7bb --- /dev/null +++ b/test/src/go.mod @@ -0,0 +1,14 @@ +module github.com/cloudposse/terraform-aws-ecs-codepipeline + +go 1.13 + +require ( + github.com/aws/aws-sdk-go v1.34.7 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/gruntwork-io/terratest v0.16.0 + github.com/pquerna/otp v1.2.0 // indirect + github.com/stretchr/testify v1.5.1 + golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect + golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e // indirect +) diff --git a/test/src/go.sum b/test/src/go.sum new file mode 100644 index 0000000..0cb89a2 --- /dev/null +++ b/test/src/go.sum @@ -0,0 +1,41 @@ +github.com/aws/aws-sdk-go v1.34.7 h1:74UoHD376AS93rcGRr2Ec6hG/mTJEKT9373xiGijWzI= +github.com/aws/aws-sdk-go v1.34.7/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI= +github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gruntwork-io/terratest v0.16.0 h1:8dDdkAzqwVDclmefcy//oBPWs5bVrWuKYCUwG0WFG4c= +github.com/gruntwork-io/terratest v0.16.0/go.mod h1:NjUn6YXA5Skxt8Rs20t3isYx5Rl+EgvGB8/+RRXddqk= +github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= +github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pquerna/otp v1.2.0 h1:/A3+Jn+cagqayeR3iHs/L62m5ue7710D35zl1zJ1kok= +github.com/pquerna/otp v1.2.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e h1:Pzdi8HRppinixnWWzN6KSa0QkBM+GKsTJaWwwfJskNw= +golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/variables.tf b/variables.tf index 571817d..c042da5 100644 --- a/variables.tf +++ b/variables.tf @@ -4,6 +4,12 @@ variable "namespace" { default = "" } +variable "environment" { + type = string + default = "" + description = "Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT'" +} + variable "stage" { type = string description = "Stage (e.g. `prod`, `dev`, `staging`)" diff --git a/versions.tf b/versions.tf index efacc3d..287fdab 100644 --- a/versions.tf +++ b/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.12.0, < 0.14.0" + required_version = ">= 0.12.0" required_providers { aws = "~> 2.0"