Skip to content

Commit 4f8cbec

Browse files
authored
Update Terraform requirement to 0.14 and update testing (#75)
1 parent 1411d06 commit 4f8cbec

File tree

11 files changed

+1265
-39
lines changed

11 files changed

+1265
-39
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Available targets:
111111

112112
| Name | Version |
113113
|------|---------|
114-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
114+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14 |
115115
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.40 |
116116

117117
## Providers

docs/terraform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
| Name | Version |
55
|------|---------|
6-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14 |
77
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.40 |
88

99
## Providers

examples/complete/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ provider "aws" {
44

55
module "zone" {
66
source = "cloudposse/route53-cluster-zone/aws"
7-
version = "0.12.0"
7+
version = "0.14.0"
88
parent_zone_name = var.parent_zone_name
99
zone_name = "$${name}.$${parent_zone_name}"
1010

examples/complete/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 0.13"
2+
required_version = ">= 0.14"
33

44
required_providers {
55
aws = {

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ locals {
44
process_domain_validation_options = local.enabled && var.process_domain_validation_options && var.validation_method == "DNS"
55
domain_validation_options_set = local.process_domain_validation_options ? aws_acm_certificate.default[0].domain_validation_options : toset([])
66
public_enabled = var.certificate_authority_arn == null
7-
private_enabled = ! local.public_enabled
7+
private_enabled = !local.public_enabled
88
}
99

1010
resource "aws_acm_certificate" "default" {

test/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ clean:
3333
all: module examples/complete
3434

3535
## Run basic sanity checks against the module itself
36-
module: export TESTS ?= installed lint get-modules module-pinning get-plugins provider-pinning validate terraform-docs input-descriptions output-descriptions
36+
module: export TESTS ?= installed lint module-pinning provider-pinning validate terraform-docs input-descriptions output-descriptions
3737
module: deps
3838
$(call RUN_TESTS, ../)
3939

4040
## Run tests against example
41-
examples/complete: export TESTS ?= installed lint get-modules get-plugins validate
41+
examples/complete: export TESTS ?= installed lint validate
4242
examples/complete: deps
4343
$(call RUN_TESTS, ../$@)

test/src/Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
export TF_CLI_ARGS_init ?= -get-plugins=true
2-
export TERRAFORM_VERSION ?= $(shell curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version' | cut -d. -f1-2)
1+
export TERRAFORM_VERSION ?= $(shell curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version' | cut -d. -f1)
32

43
.DEFAULT_GOAL : all
54
.PHONY: all
@@ -16,7 +15,7 @@ init:
1615
## Run tests
1716
test: init
1817
go mod download
19-
go test -v -timeout 60m -run TestExamplesComplete
18+
go test -v -timeout 20m
2019

2120
## Run tests in docker container
2221
docker/test:
@@ -27,4 +26,4 @@ docker/test:
2726
.PHONY : clean
2827
## Clean up files
2928
clean:
30-
rm -rf ../../examples/complete/*.tfstate*
29+
rm -rf ../../examples/complete/*.tfstate* ../../examples/complete/.terraform* terraform.tfstate.backup *.planfile *.terraform.tfvars.json

test/src/examples_complete_test.go

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,57 @@
11
package test
22

33
import (
4+
"github.com/gruntwork-io/terratest/modules/logger"
5+
"github.com/gruntwork-io/terratest/modules/random"
6+
test_structure "github.com/gruntwork-io/terratest/modules/test-structure"
7+
"github.com/stretchr/testify/require"
8+
"os"
9+
"strings"
410
"testing"
511

612
"github.com/gruntwork-io/terratest/modules/terraform"
713
"github.com/stretchr/testify/assert"
814
)
915

16+
func cleanup(t *testing.T, terraformOptions *terraform.Options, tempTestFolder string) {
17+
terraform.Destroy(t, terraformOptions)
18+
os.RemoveAll(tempTestFolder)
19+
}
20+
1021
// Test the Terraform module in examples/complete using Terratest.
1122
func TestExamplesComplete(t *testing.T) {
1223
t.Parallel()
24+
randID := strings.ToLower(random.UniqueId())
25+
attributes := []string{randID}
26+
27+
rootFolder := "../../"
28+
terraformFolderRelativeToRoot := "examples/complete"
29+
varFiles := []string{"fixtures.us-west-1.tfvars"}
30+
31+
tempTestFolder := test_structure.CopyTerraformFolderToTemp(t, rootFolder, terraformFolderRelativeToRoot)
1332

1433
terraformOptions := &terraform.Options{
1534
// The path to where our Terraform code is located
16-
TerraformDir: "../../examples/complete",
35+
TerraformDir: tempTestFolder,
1736
Upgrade: true,
1837
// Variables to pass to our Terraform code using -var-file options
19-
VarFiles: []string{"fixtures.us-west-1.tfvars"},
38+
VarFiles: varFiles,
39+
Vars: map[string]interface{}{
40+
"attributes": attributes,
41+
},
42+
}
43+
// Keep the output quiet
44+
if !testing.Verbose() {
45+
terraformOptions.Logger = logger.Discard
2046
}
2147

2248
// At the end of the test, run `terraform destroy` to clean up any resources that were created
23-
defer terraform.Destroy(t, terraformOptions)
49+
defer cleanup(t, terraformOptions, tempTestFolder)
2450

2551
// This will run `terraform init` and `terraform apply` and fail the test if there are any errors
26-
terraform.InitAndApply(t, terraformOptions)
52+
if _, err := terraform.InitAndApplyE(t, terraformOptions); err != nil {
53+
require.FailNow(t, "Terraform \"apply\" failed, skipping the rest of the tests")
54+
}
2755

2856
// Run `terraform output` to get the value of an output variable
2957
zoneName := terraform.Output(t, terraformOptions, "zone_name")
@@ -38,3 +66,57 @@ func TestExamplesComplete(t *testing.T) {
3866
// Verify we're getting back the outputs we expect
3967
assert.Contains(t, certificateArn, "arn:aws:acm:us-west-1:126450723953:certificate/")
4068
}
69+
70+
func TestExamplesCompleteDisabled(t *testing.T) {
71+
t.Parallel()
72+
randID := strings.ToLower(random.UniqueId())
73+
attributes := []string{randID}
74+
75+
rootFolder := "../../"
76+
terraformFolderRelativeToRoot := "examples/complete"
77+
varFiles := []string{"fixtures.us-west-1.tfvars"}
78+
79+
tempTestFolder := test_structure.CopyTerraformFolderToTemp(t, rootFolder, terraformFolderRelativeToRoot)
80+
81+
terraformOptions := &terraform.Options{
82+
// The path to where our Terraform code is located
83+
TerraformDir: tempTestFolder,
84+
Upgrade: true,
85+
// Variables to pass to our Terraform code using -var-file options
86+
VarFiles: varFiles,
87+
Vars: map[string]interface{}{
88+
"attributes": attributes,
89+
"enabled": "false",
90+
},
91+
}
92+
// Keep the output quiet
93+
if !testing.Verbose() {
94+
terraformOptions.Logger = logger.Discard
95+
}
96+
97+
// At the end of the test, run `terraform destroy` to clean up any resources that were created
98+
defer cleanup(t, terraformOptions, tempTestFolder)
99+
100+
// This will run `terraform init` and `terraform apply` and fail the test if there are any errors
101+
terraform.InitAndApply(t, terraformOptions)
102+
103+
// Get all the output and lookup a field. Pass if the field is missing or empty.
104+
// Get all the output and lookup a field. Pass if the field is missing or empty.
105+
allOutputs := terraform.OutputAll(t, terraformOptions)
106+
107+
// Verify we're getting back the outputs we expect
108+
assert.Empty(t, allOutputs["id"], "When disabled, 'id' output should be empty.")
109+
assert.Empty(t, allOutputs["arn"], "When disabled, 'arn' output should be empty.")
110+
assert.Empty(t, allOutputs["domain_validation_options"], "When disabled, 'domain_validation_options' output should be empty.")
111+
assert.Empty(t, allOutputs["validation_id"], "When disabled, 'validation_id' output should be empty.")
112+
assert.Empty(t, allOutputs["validation_certificate_arn"], "When disabled, 'validation_certificate_arn' output should be empty.")
113+
assert.Empty(t, allOutputs["parent_zone_id"], "When disabled, 'parent_zone_id' output should be empty.")
114+
assert.Empty(t, allOutputs["parent_zone_name"], "When disabled, 'parent_zone_name' output should be empty.")
115+
assert.Empty(t, allOutputs["zone_id"], "When disabled, 'zone_id' output should be empty.")
116+
assert.Empty(t, allOutputs["zone_name"], "When disabled, 'zone_name' output should be empty.")
117+
assert.Empty(t, allOutputs["zone_fqdn"], "When disabled, 'zone_fqdn' output should be empty.")
118+
assert.Empty(t, allOutputs["certificate_id"], "When disabled, 'certificate_id' output should be empty.")
119+
assert.Empty(t, allOutputs["certificate_arn"], "When disabled, 'certificate_arn' output should be empty.")
120+
assert.Empty(t, allOutputs["certificate_domain_validation_options"], "When disabled, 'certificate_domain_validation_options' output should be empty.")
121+
assert.Empty(t, allOutputs["validation_certificate_arn"], "When disabled, 'validation_certificate_arn' output should be empty.")
122+
}

test/src/go.mod

Lines changed: 102 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,108 @@
11
module github.com/cloudposse/terraform-aws-acm-request-certificate
22

3-
go 1.14
3+
go 1.21
44

55
require (
6-
github.com/aws/aws-sdk-go v1.35.37 // indirect
6+
// Known security flaws in terratest dependencies prior to v0.40.15
7+
github.com/gruntwork-io/terratest v0.46.11
8+
github.com/stretchr/testify v1.8.4
9+
)
10+
11+
require (
12+
cloud.google.com/go v0.112.1 // indirect
13+
cloud.google.com/go/compute v1.24.0 // indirect
14+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
15+
cloud.google.com/go/iam v1.1.6 // indirect
16+
cloud.google.com/go/storage v1.38.0 // indirect
17+
github.com/agext/levenshtein v1.2.3 // indirect
18+
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
19+
github.com/aws/aws-sdk-go v1.50.26 // indirect
20+
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
21+
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
22+
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
723
github.com/davecgh/go-spew v1.1.1 // indirect
8-
github.com/go-sql-driver/mysql v1.5.0 // indirect
9-
github.com/google/uuid v1.1.2 // indirect
10-
github.com/gruntwork-io/terratest v0.16.0
11-
github.com/pquerna/otp v1.3.0 // indirect
12-
github.com/stretchr/testify v1.3.0
24+
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
25+
github.com/felixge/httpsnoop v1.0.4 // indirect
26+
github.com/go-errors/errors v1.0.2-0.20180813162953-d98b870cc4e0 // indirect
27+
github.com/go-logr/logr v1.4.1 // indirect
28+
github.com/go-logr/stdr v1.2.2 // indirect
29+
github.com/go-openapi/jsonpointer v0.19.6 // indirect
30+
github.com/go-openapi/jsonreference v0.20.2 // indirect
31+
github.com/go-openapi/swag v0.22.3 // indirect
32+
github.com/go-sql-driver/mysql v1.4.1 // indirect
33+
github.com/gogo/protobuf v1.3.2 // indirect
34+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
35+
github.com/golang/protobuf v1.5.3 // indirect
36+
github.com/google/gnostic-models v0.6.8 // indirect
37+
github.com/google/go-cmp v0.6.0 // indirect
38+
github.com/google/gofuzz v1.2.0 // indirect
39+
github.com/google/s2a-go v0.1.7 // indirect
40+
github.com/google/uuid v1.6.0 // indirect
41+
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
42+
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
43+
github.com/gruntwork-io/go-commons v0.8.0 // indirect
44+
github.com/hashicorp/errwrap v1.1.0 // indirect
45+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
46+
github.com/hashicorp/go-getter v1.7.3 // indirect
47+
github.com/hashicorp/go-multierror v1.1.1 // indirect
48+
github.com/hashicorp/go-safetemp v1.0.0 // indirect
49+
github.com/hashicorp/go-version v1.6.0 // indirect
50+
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
51+
github.com/hashicorp/terraform-json v0.21.0 // indirect
52+
github.com/imdario/mergo v0.3.11 // indirect
53+
github.com/jinzhu/copier v0.4.0 // indirect
54+
github.com/jmespath/go-jmespath v0.4.0 // indirect
55+
github.com/josharian/intern v1.0.0 // indirect
56+
github.com/json-iterator/go v1.1.12 // indirect
57+
github.com/klauspost/compress v1.17.7 // indirect
58+
github.com/mailru/easyjson v0.7.7 // indirect
59+
github.com/mattn/go-zglob v0.0.4 // indirect
60+
github.com/mitchellh/go-homedir v1.1.0 // indirect
61+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
62+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
63+
github.com/moby/spdystream v0.2.0 // indirect
64+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
65+
github.com/modern-go/reflect2 v1.0.2 // indirect
66+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
67+
github.com/pmezard/go-difflib v1.0.0 // indirect
68+
github.com/pquerna/otp v1.2.0 // indirect
69+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
70+
github.com/spf13/pflag v1.0.5 // indirect
71+
github.com/tmccombs/hcl2json v0.6.1 // indirect
72+
github.com/ulikunitz/xz v0.5.11 // indirect
73+
github.com/urfave/cli v1.22.2 // indirect
74+
github.com/zclconf/go-cty v1.14.2 // indirect
75+
go.opencensus.io v0.24.0 // indirect
76+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
77+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
78+
go.opentelemetry.io/otel v1.24.0 // indirect
79+
go.opentelemetry.io/otel/metric v1.24.0 // indirect
80+
go.opentelemetry.io/otel/trace v1.24.0 // indirect
81+
golang.org/x/crypto v0.20.0 // indirect
82+
golang.org/x/net v0.21.0 // indirect
83+
golang.org/x/oauth2 v0.17.0 // indirect
84+
golang.org/x/sync v0.6.0 // indirect
85+
golang.org/x/sys v0.17.0 // indirect
86+
golang.org/x/term v0.17.0 // indirect
87+
golang.org/x/text v0.14.0 // indirect
88+
golang.org/x/time v0.5.0 // indirect
89+
google.golang.org/api v0.167.0 // indirect
90+
google.golang.org/appengine v1.6.8 // indirect
91+
google.golang.org/genproto v0.0.0-20240221002015-b0ce06bbee7c // indirect
92+
google.golang.org/genproto/googleapis/api v0.0.0-20240221002015-b0ce06bbee7c // indirect
93+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
94+
google.golang.org/grpc v1.62.0 // indirect
95+
google.golang.org/protobuf v1.32.0 // indirect
96+
gopkg.in/inf.v0 v0.9.1 // indirect
97+
gopkg.in/yaml.v2 v2.4.0 // indirect
98+
gopkg.in/yaml.v3 v3.0.1 // indirect
99+
k8s.io/api v0.28.4 // indirect
100+
k8s.io/apimachinery v0.28.4 // indirect
101+
k8s.io/client-go v0.28.4 // indirect
102+
k8s.io/klog/v2 v2.100.1 // indirect
103+
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
104+
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
105+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
106+
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
107+
sigs.k8s.io/yaml v1.3.0 // indirect
13108
)

0 commit comments

Comments
 (0)