Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #192 from hashicorp/tf13
Browse files Browse the repository at this point in the history
Update repo to work with TF 0.13
  • Loading branch information
brikis98 authored Oct 15, 2020
2 parents 07ebd11 + 0045407 commit bc8f837
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 34 deletions.
24 changes: 9 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
---
workspace_root: &workspace_root /go/src/github.com/hashicorp/terraform-aws-consul

defaults: &defaults
working_directory: *workspace_root
docker:
- image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:go1.13
- image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:tf13

version: 2
jobs:
validate_terraform:
docker:
- image: hashicorp/terraform
steps:
- checkout
- run:
name: Validate Terraform Formatting
command: '[ -z "$(terraform fmt -write=false)" ] || { terraform fmt -write=false -diff; exit 1; }'

test:
<<: *defaults
steps:
- checkout
- run: echo 'export PATH=$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV
- attach_workspace:
at: *workspace_root
- run:
# Fail the build if the pre-commit hooks don't pass. Note: if you run $ pre-commit install locally within this repo, these hooks will
# execute automatically every time before you commit, ensuring the build never fails at this step!
name: run pre-commit hooks
command: |
pip install pre-commit==1.21.0 cfgv==2.0.1
pre-commit install
pre-commit run --all-files
- run:
command: |
mkdir -p /tmp/logs
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/gruntwork-io/pre-commit
rev: v0.1.10
hooks:
- id: terraform-fmt
- id: gofmt
6 changes: 4 additions & 2 deletions examples/example-with-custom-asg-role/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

# ----------------------------------------------------------------------------------------------------------------------
# REQUIRE A SPECIFIC TERRAFORM VERSION OR HIGHER
# This module has been updated with 0.12 syntax, which means it is no longer compatible with any versions below 0.12.
# ----------------------------------------------------------------------------------------------------------------------
terraform {
required_version = ">= 0.12"
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
# forwards compatible with 0.13.x code.
required_version = ">= 0.12.26"
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions examples/example-with-encryption/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

# ----------------------------------------------------------------------------------------------------------------------
# REQUIRE A SPECIFIC TERRAFORM VERSION OR HIGHER
# This module has been updated with 0.12 syntax, which means it is no longer compatible with any versions below 0.12.
# ----------------------------------------------------------------------------------------------------------------------
terraform {
required_version = ">= 0.12"
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
# forwards compatible with 0.13.x code.
required_version = ">= 0.12.26"
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@
"type": "file",
"source": "{{user `tls_private_key_path`}}",
"destination": "/tmp/consul.key.pem"
},{
"type": "shell",
"inline": ["mkdir -p /tmp/terraform-aws-consul"]
},{
"type": "file",
"source": "{{template_dir}}/../../../../terraform-aws-consul",
"destination": "/tmp"
"source": "{{template_dir}}/../../../",
"destination": "/tmp/terraform-aws-consul"
},{
"type": "shell",
"inline": [
Expand Down
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

# ----------------------------------------------------------------------------------------------------------------------
# REQUIRE A SPECIFIC TERRAFORM VERSION OR HIGHER
# This module has been updated with 0.12 syntax, which means it is no longer compatible with any versions below 0.12.
# ----------------------------------------------------------------------------------------------------------------------
terraform {
required_version = ">= 0.12"
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
# forwards compatible with 0.13.x code.
required_version = ">= 0.12.26"
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions modules/consul-client-security-group-rules/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## ---------------------------------------------------------------------------------------------------------------------
# THESE TEMPLATES REQUIRE TERRAFORM VERSION 0.12 AND ABOVE
# REQUIRE A SPECIFIC TERRAFORM VERSION OR HIGHER
# ---------------------------------------------------------------------------------------------------------------------

terraform {
required_version = ">= 0.12"
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
# forwards compatible with 0.13.x code.
required_version = ">= 0.12.26"
}

## ---------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions modules/consul-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# ----------------------------------------------------------------------------------------------------------------------
# REQUIRE A SPECIFIC TERRAFORM VERSION OR HIGHER
# This module has been updated with 0.12 syntax, which means it is no longer compatible with any versions below 0.12.
# ----------------------------------------------------------------------------------------------------------------------

terraform {
required_version = ">= 0.12"
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
# forwards compatible with 0.13.x code.
required_version = ">= 0.12.26"
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
9 changes: 6 additions & 3 deletions modules/consul-iam-policies/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
### ---------------------------------------------------------------------------------------------------------------------
# THESE TEMPLATES REQUIRE TERRAFORM VERSION 0.12 AND ABOVE
# ---------------------------------------------------------------------------------------------------------------------
# REQUIRE A SPECIFIC TERRAFORM VERSION OR HIGHER
# ---------------------------------------------------------------------------------------------------------------------

terraform {
required_version = ">= 0.12"
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
# forwards compatible with 0.13.x code.
required_version = ">= 0.12.26"
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions modules/consul-security-group-rules/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# ----------------------------------------------------------------------------------------------------------------------
# REQUIRE A SPECIFIC TERRAFORM VERSION OR HIGHER
# This module has been updated with 0.12 syntax, which means it is no longer compatible with any versions below 0.12.
# ----------------------------------------------------------------------------------------------------------------------
terraform {
required_version = ">= 0.12"
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
# forwards compatible with 0.13.x code.
required_version = ">= 0.12.26"
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions test/aws_helpers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package test

import (
"testing"
"github.com/gruntwork-io/terratest/modules/aws"
"testing"
)

// Get the IP address from a randomly chosen EC2 Instance in an Auto Scaling Group of the given name in the given
Expand All @@ -15,4 +15,4 @@ func getIpAddressOfAsgInstance(t *testing.T, asgName string, awsRegion string) s
}

return aws.GetPublicIpOfEc2Instance(t, instanceIds[0], awsRegion)
}
}
6 changes: 6 additions & 0 deletions test/terratest_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package test

import (
"testing"
"time"

"github.com/gruntwork-io/terratest/modules/packer"
)
Expand All @@ -20,6 +21,11 @@ func buildAmi(t *testing.T, packerTemplatePath string, packerBuildName string, a
Env: map[string]string{
CONSUL_AMI_TEMPLATE_VAR_DOWNLOAD_URL: downloadUrl,
},
RetryableErrors: map[string]string{
"Error waiting for AMI: Failed with ResourceNotReady error": "https://www.packer.io/docs/builders/amazon.html#resourcenotready-error",
},
MaxRetries: 3,
TimeBetweenRetries: 10 * time.Second,
}

return packer.BuildAmi(t, options)
Expand Down

0 comments on commit bc8f837

Please sign in to comment.