Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit e258f14

Browse files
authored
Merge pull request #51 from gruntwork-io/tf13
Update repo to work with Terraform 0.13.x
2 parents 3ca0fcd + 30b3d6b commit e258f14

File tree

15 files changed

+230
-116
lines changed

15 files changed

+230
-116
lines changed

.circleci/config.yml

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,70 @@
1+
version: 2.1
2+
13
defaults: &defaults
24
machine: true
5+
6+
env: &env
37
environment:
4-
GRUNTWORK_INSTALLER_VERSION: v0.0.25
5-
TERRATEST_LOG_PARSER_VERSION: v0.13.24
6-
MODULE_CI_VERSION: v0.18.4
7-
TERRAFORM_VERSION: 0.12.23
8+
GRUNTWORK_INSTALLER_VERSION: v0.0.30
9+
TERRATEST_LOG_PARSER_VERSION: v0.30.4
10+
MODULE_CI_VERSION: v0.29.1
11+
TERRAFORM_VERSION: 0.13.5
812
TERRAGRUNT_VERSION: NONE
913
PACKER_VERSION: NONE
1014
GOLANG_VERSION: 1.13.8
1115

12-
install_gruntwork_utils: &install_gruntwork_utils
13-
name: install gruntwork utils
14-
command: |
15-
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}"
16-
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
17-
gruntwork-install --binary-name "terratest_log_parser" --repo "https://github.com/gruntwork-io/terratest" --tag "${TERRATEST_LOG_PARSER_VERSION}"
18-
configure-environment-for-gruntwork-module \
19-
--terraform-version ${TERRAFORM_VERSION} \
20-
--terragrunt-version ${TERRAGRUNT_VERSION} \
21-
--packer-version ${PACKER_VERSION} \
22-
--go-version ${GOLANG_VERSION}
23-
version: 2
2416
jobs:
25-
build:
26-
<<: *defaults
17+
precommit:
18+
<<: *env
19+
docker:
20+
- image: circleci/python:3.8.1
2721
steps:
2822
- checkout
29-
# Install gruntwork utilities
30-
- run:
31-
<<: *install_gruntwork_utils
3223

24+
- run:
25+
name: install dependencies
26+
command: |
27+
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}"
28+
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
29+
configure-environment-for-gruntwork-module \
30+
--terraform-version ${TERRAFORM_VERSION} \
31+
--terragrunt-version NONE \
32+
--packer-version NONE \
33+
--go-version ${GOLANG_VERSION}
3334
# Fail the build if the pre-commit hooks don't pass. Note: if you run pre-commit install locally, these hooks will
3435
# execute automatically every time before you commit, ensuring the build never fails at this step!
35-
- run: pip install pre-commit==1.11.2 cfgv==2.0.1 yapf
36-
- run: pre-commit install
37-
- run: pre-commit run --all-files
38-
39-
- persist_to_workspace:
40-
root: /home/circleci
41-
paths:
42-
- project
43-
- terraform
44-
- packer
36+
- run:
37+
command: |
38+
pip install pre-commit==1.21.0 cfgv==2.0.1 zipp==1.1.0 yapf
39+
pre-commit install
40+
pre-commit run --all-files
4541
4642
test:
4743
<<: *defaults
44+
<<: *env
4845
steps:
49-
- attach_workspace:
50-
at: /home/circleci
5146
- checkout
52-
- run: echo 'export PATH=$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV
53-
- run:
54-
<<: *install_gruntwork_utils
47+
- run: &install_gruntwork_tooling
48+
name: install gruntwork tooling
49+
command: |
50+
sudo apt-get -y update
51+
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}"
52+
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
53+
gruntwork-install --module-name "git-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
54+
gruntwork-install --binary-name "terratest_log_parser" --repo "https://github.com/gruntwork-io/terratest" --tag "${TERRATEST_LOG_PARSER_VERSION}"
55+
configure-environment-for-gruntwork-module --go-src-path ./test --terraform-version ${TERRAFORM_VERSION} --terragrunt-version ${TERRAGRUNT_VERSION} --packer-version ${PACKER_VERSION} --go-version ${GOLANG_VERSION}
56+
57+
# Install external dependencies
5558
- run:
5659
name: update gcloud
5760
command: |
5861
sudo apt-get remove -y google-cloud-sdk
5962
sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update
6063
sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update beta
64+
6165
- run:
6266
name: run tests
6367
command: |
64-
mkdir -p /tmp/logs
6568
# required for gcloud to authenticate correctly
6669
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
6770
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
@@ -70,21 +73,35 @@ jobs:
7073
echo $GCLOUD_SERVICE_KEY > /tmp/gcloud.json
7174
export GOOGLE_APPLICATION_CREDENTIALS="/tmp/gcloud.json"
7275
# run the tests
73-
run-go-tests --path test --timeout 60m | tee /tmp/logs/all.log
74-
no_output_timeout: 3600s
76+
mkdir -p /tmp/logs
77+
run-go-tests --path test --timeout 2h | tee /tmp/logs/all.log
78+
no_output_timeout: 1h
79+
7580
- run:
81+
name: parse test output
7682
command: terratest_log_parser --testlog /tmp/logs/all.log --outputdir /tmp/logs
7783
when: always
84+
7885
- store_artifacts:
7986
path: /tmp/logs
8087
- store_test_results:
8188
path: /tmp/logs
8289

8390
workflows:
8491
version: 2
85-
build-and-test:
92+
test:
8693
jobs:
87-
- build
94+
# We have to explicitly tell CircleCI to run on all tags and branches, or tag commits/pushes will not trigger
95+
# builds: https://circleci.com/docs/2.0/workflows/#git-tag-job-execution.
96+
- precommit:
97+
filters:
98+
branches:
99+
only: /.*/
100+
tags:
101+
only: /.*/
88102
- test:
89103
requires:
90-
- build
104+
- precommit
105+
filters:
106+
tags:
107+
only: /^v.*/

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
repos:
22
- repo: https://github.com/gruntwork-io/pre-commit
3-
rev: v0.0.4
3+
rev: v0.1.10
44
hooks:
55
- id: terraform-fmt
6-
#
6+
- id: gofmt
7+

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
:license: open-source
1010
:built-with: terraform
1111
-->
12+
1213
# Cloud SQL Modules
14+
1315
[![Maintained by Gruntwork.io](https://img.shields.io/badge/maintained%20by-gruntwork.io-%235849a6.svg)](https://gruntwork.io/?ref=repo_google_cloudsql)
1416
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/gruntwork-io/terraform-google-sql.svg?label=latest)](http://github.com/gruntwork-io/terraform-google-sql/releases/latest)
15-
![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.12.0-blue.svg)
17+
![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.13.0-blue.svg)
1618

1719
This repo contains modules for running relational databases such as MySQL and PostgreSQL on
1820
[Google Cloud Platform (GCP)](https://cloud.google.com/) using [Cloud SQL](https://cloud.google.com/sql/).
@@ -52,7 +54,7 @@ This repo has the following folder structure:
5254
The primary module is:
5355

5456
- [cloud-sql](https://github.com/gruntwork-io/terraform-google-sql/tree/master/modules/cloud-sql): Deploy a Cloud SQL [MySQL](https://cloud.google.com/sql/docs/mysql/) or [PostgreSQL](https://cloud.google.com/sql/docs/postgres/) database.
55-
57+
5658
- [examples](https://github.com/gruntwork-io/terraform-google-sql/tree/master/examples): This folder contains
5759
examples of how to use the submodules.
5860

@@ -71,9 +73,9 @@ If you just want to try this repo out for experimenting and learning, check out
7173

7274
If you want to deploy this repo in production, check out the following resources:
7375

74-
- [cloud-sql module in the GCP Reference Architecture](https://github.com/gruntwork-io/infrastructure-modules-google/tree/master/data-stores/cloud-sql):
75-
Production-ready sample code from the GCP Reference Architecture. Note that the repository is private and accessible only with
76-
Gruntwork subscription. To get access, [subscribe now](https://www.gruntwork.io/pricing/) or contact us at [support@gruntwork.io](mailto:support@gruntwork.io) for more information.
76+
- [cloud-sql module in the GCP Reference Architecture](https://github.com/gruntwork-io/infrastructure-modules-google/tree/master/data-stores/cloud-sql):
77+
Production-ready sample code from the GCP Reference Architecture. Note that the repository is private and accessible only with
78+
Gruntwork subscription. To get access, [subscribe now](https://www.gruntwork.io/pricing/) or contact us at [support@gruntwork.io](mailto:support@gruntwork.io) for more information.
7779

7880
## Manage
7981

@@ -99,7 +101,3 @@ Please see [Contributing to the Gruntwork Infrastructure as Code Library](https:
99101
Please see [LICENSE](https://github.com/gruntwork-io/terraform-google-sql/blob/master/LICENSE.txt) for details on how the code in this repo is licensed.
100102

101103
Copyright &copy; 2019 Gruntwork, Inc.
102-
103-
104-
105-

examples/client-certificate/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
# ------------------------------------------------------------------------------
88

99
provider "google-beta" {
10-
version = "~> 2.7.0"
10+
version = "~> 3.43.0"
1111
project = var.project
1212
region = var.region
1313
}
1414

1515
terraform {
16-
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
17-
# compatible with any versions below 0.12.
18-
required_version = ">= 0.12"
16+
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
17+
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
18+
# forwards compatible with 0.13.x code.
19+
required_version = ">= 0.12.26"
1920
}
2021

2122
# ------------------------------------------------------------------------------

examples/mysql-private-ip/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
# ------------------------------------------------------------------------------
88

99
provider "google-beta" {
10-
version = "~> 2.7.0"
10+
version = "~> 3.43.0"
1111
project = var.project
1212
region = var.region
1313
}
1414

1515
terraform {
16-
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
17-
# compatible with any versions below 0.12.
18-
required_version = ">= 0.12"
16+
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
17+
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
18+
# forwards compatible with 0.13.x code.
19+
required_version = ">= 0.12.26"
1920
}
2021

2122
# ------------------------------------------------------------------------------

examples/mysql-public-ip/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
# ------------------------------------------------------------------------------
88

99
provider "google-beta" {
10-
version = "~> 2.7.0"
10+
version = "~> 3.43.0"
1111
project = var.project
1212
region = var.region
1313
}
1414

1515
terraform {
16-
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
17-
# compatible with any versions below 0.12.
18-
required_version = ">= 0.12"
16+
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
17+
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
18+
# forwards compatible with 0.13.x code.
19+
required_version = ">= 0.12.26"
1920
}
2021

2122
# ------------------------------------------------------------------------------

examples/mysql-replicas/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
# ------------------------------------------------------------------------------
88

99
provider "google-beta" {
10-
version = "~> 2.7.0"
10+
version = "~> 3.43.0"
1111
project = var.project
1212
region = var.region
1313
}
1414

1515
terraform {
16-
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
17-
# compatible with any versions below 0.12.
18-
required_version = ">= 0.12"
16+
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
17+
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
18+
# forwards compatible with 0.13.x code.
19+
required_version = ">= 0.12.26"
1920
}
2021

2122
# ------------------------------------------------------------------------------

examples/postgres-private-ip/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
# ------------------------------------------------------------------------------
88

99
provider "google-beta" {
10-
version = "~> 2.7.0"
10+
version = "~> 3.43.0"
1111
project = var.project
1212
region = var.region
1313
}
1414

1515
terraform {
16-
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
17-
# compatible with any versions below 0.12.
18-
required_version = ">= 0.12"
16+
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
17+
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
18+
# forwards compatible with 0.13.x code.
19+
required_version = ">= 0.12.26"
1920
}
2021

2122
# ------------------------------------------------------------------------------

examples/postgres-public-ip/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
# ------------------------------------------------------------------------------
88

99
provider "google-beta" {
10-
version = "~> 2.7.0"
10+
version = "~> 3.43.0"
1111
project = var.project
1212
region = var.region
1313
}
1414

1515
terraform {
16-
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
17-
# compatible with any versions below 0.12.
18-
required_version = ">= 0.12"
16+
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
17+
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
18+
# forwards compatible with 0.13.x code.
19+
required_version = ">= 0.12.26"
1920
}
2021

2122
# ------------------------------------------------------------------------------

examples/postgres-replicas/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
# ------------------------------------------------------------------------------
88

99
provider "google-beta" {
10-
version = "~> 2.7.0"
10+
version = "~> 3.43.0"
1111
project = var.project
1212
region = var.region
1313
}
1414

1515
terraform {
16-
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
17-
# compatible with any versions below 0.12.
18-
required_version = ">= 0.12"
16+
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
17+
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
18+
# forwards compatible with 0.13.x code.
19+
required_version = ">= 0.12.26"
1920
}
2021

2122
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)