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

Commit

Permalink
Merge pull request #51 from gruntwork-io/tf13
Browse files Browse the repository at this point in the history
Update repo to work with Terraform 0.13.x
  • Loading branch information
robmorgan authored Nov 24, 2020
2 parents 3ca0fcd + 30b3d6b commit e258f14
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 116 deletions.
101 changes: 59 additions & 42 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,70 @@
version: 2.1

defaults: &defaults
machine: true

env: &env
environment:
GRUNTWORK_INSTALLER_VERSION: v0.0.25
TERRATEST_LOG_PARSER_VERSION: v0.13.24
MODULE_CI_VERSION: v0.18.4
TERRAFORM_VERSION: 0.12.23
GRUNTWORK_INSTALLER_VERSION: v0.0.30
TERRATEST_LOG_PARSER_VERSION: v0.30.4
MODULE_CI_VERSION: v0.29.1
TERRAFORM_VERSION: 0.13.5
TERRAGRUNT_VERSION: NONE
PACKER_VERSION: NONE
GOLANG_VERSION: 1.13.8

install_gruntwork_utils: &install_gruntwork_utils
name: install gruntwork utils
command: |
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}"
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
gruntwork-install --binary-name "terratest_log_parser" --repo "https://github.com/gruntwork-io/terratest" --tag "${TERRATEST_LOG_PARSER_VERSION}"
configure-environment-for-gruntwork-module \
--terraform-version ${TERRAFORM_VERSION} \
--terragrunt-version ${TERRAGRUNT_VERSION} \
--packer-version ${PACKER_VERSION} \
--go-version ${GOLANG_VERSION}
version: 2
jobs:
build:
<<: *defaults
precommit:
<<: *env
docker:
- image: circleci/python:3.8.1
steps:
- checkout
# Install gruntwork utilities
- run:
<<: *install_gruntwork_utils

- run:
name: install dependencies
command: |
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}"
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
configure-environment-for-gruntwork-module \
--terraform-version ${TERRAFORM_VERSION} \
--terragrunt-version NONE \
--packer-version NONE \
--go-version ${GOLANG_VERSION}
# Fail the build if the pre-commit hooks don't pass. Note: if you run pre-commit install locally, these hooks will
# execute automatically every time before you commit, ensuring the build never fails at this step!
- run: pip install pre-commit==1.11.2 cfgv==2.0.1 yapf
- run: pre-commit install
- run: pre-commit run --all-files

- persist_to_workspace:
root: /home/circleci
paths:
- project
- terraform
- packer
- run:
command: |
pip install pre-commit==1.21.0 cfgv==2.0.1 zipp==1.1.0 yapf
pre-commit install
pre-commit run --all-files
test:
<<: *defaults
<<: *env
steps:
- attach_workspace:
at: /home/circleci
- checkout
- run: echo 'export PATH=$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV
- run:
<<: *install_gruntwork_utils
- run: &install_gruntwork_tooling
name: install gruntwork tooling
command: |
sudo apt-get -y update
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}"
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
gruntwork-install --module-name "git-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
gruntwork-install --binary-name "terratest_log_parser" --repo "https://github.com/gruntwork-io/terratest" --tag "${TERRATEST_LOG_PARSER_VERSION}"
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}
# Install external dependencies
- run:
name: update gcloud
command: |
sudo apt-get remove -y google-cloud-sdk
sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update
sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update beta
- run:
name: run tests
command: |
mkdir -p /tmp/logs
# required for gcloud to authenticate correctly
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
Expand All @@ -70,21 +73,35 @@ jobs:
echo $GCLOUD_SERVICE_KEY > /tmp/gcloud.json
export GOOGLE_APPLICATION_CREDENTIALS="/tmp/gcloud.json"
# run the tests
run-go-tests --path test --timeout 60m | tee /tmp/logs/all.log
no_output_timeout: 3600s
mkdir -p /tmp/logs
run-go-tests --path test --timeout 2h | tee /tmp/logs/all.log
no_output_timeout: 1h

- run:
name: parse test output
command: terratest_log_parser --testlog /tmp/logs/all.log --outputdir /tmp/logs
when: always

- store_artifacts:
path: /tmp/logs
- store_test_results:
path: /tmp/logs

workflows:
version: 2
build-and-test:
test:
jobs:
- build
# We have to explicitly tell CircleCI to run on all tags and branches, or tag commits/pushes will not trigger
# builds: https://circleci.com/docs/2.0/workflows/#git-tag-job-execution.
- precommit:
filters:
branches:
only: /.*/
tags:
only: /.*/
- test:
requires:
- build
- precommit
filters:
tags:
only: /^v.*/
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
repos:
- repo: https://github.com/gruntwork-io/pre-commit
rev: v0.0.4
rev: v0.1.10
hooks:
- id: terraform-fmt
#
- id: gofmt

16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
:license: open-source
:built-with: terraform
-->

# Cloud SQL Modules

[![Maintained by Gruntwork.io](https://img.shields.io/badge/maintained%20by-gruntwork.io-%235849a6.svg)](https://gruntwork.io/?ref=repo_google_cloudsql)
[![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)
![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.12.0-blue.svg)
![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.13.0-blue.svg)

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

- [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.

- [examples](https://github.com/gruntwork-io/terraform-google-sql/tree/master/examples): This folder contains
examples of how to use the submodules.

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

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

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

## Manage

Expand All @@ -99,7 +101,3 @@ Please see [Contributing to the Gruntwork Infrastructure as Code Library](https:
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.

Copyright &copy; 2019 Gruntwork, Inc.




9 changes: 5 additions & 4 deletions examples/client-certificate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# ------------------------------------------------------------------------------

provider "google-beta" {
version = "~> 2.7.0"
version = "~> 3.43.0"
project = var.project
region = var.region
}

terraform {
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
# compatible with any versions below 0.12.
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: 5 additions & 4 deletions examples/mysql-private-ip/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# ------------------------------------------------------------------------------

provider "google-beta" {
version = "~> 2.7.0"
version = "~> 3.43.0"
project = var.project
region = var.region
}

terraform {
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
# compatible with any versions below 0.12.
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: 5 additions & 4 deletions examples/mysql-public-ip/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# ------------------------------------------------------------------------------

provider "google-beta" {
version = "~> 2.7.0"
version = "~> 3.43.0"
project = var.project
region = var.region
}

terraform {
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
# compatible with any versions below 0.12.
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: 5 additions & 4 deletions examples/mysql-replicas/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# ------------------------------------------------------------------------------

provider "google-beta" {
version = "~> 2.7.0"
version = "~> 3.43.0"
project = var.project
region = var.region
}

terraform {
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
# compatible with any versions below 0.12.
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: 5 additions & 4 deletions examples/postgres-private-ip/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# ------------------------------------------------------------------------------

provider "google-beta" {
version = "~> 2.7.0"
version = "~> 3.43.0"
project = var.project
region = var.region
}

terraform {
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
# compatible with any versions below 0.12.
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: 5 additions & 4 deletions examples/postgres-public-ip/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# ------------------------------------------------------------------------------

provider "google-beta" {
version = "~> 2.7.0"
version = "~> 3.43.0"
project = var.project
region = var.region
}

terraform {
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
# compatible with any versions below 0.12.
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: 5 additions & 4 deletions examples/postgres-replicas/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# ------------------------------------------------------------------------------

provider "google-beta" {
version = "~> 2.7.0"
version = "~> 3.43.0"
project = var.project
region = var.region
}

terraform {
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
# compatible with any versions below 0.12.
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: 5 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# ------------------------------------------------------------------------------

provider "google-beta" {
version = "~> 2.7.0"
version = "~> 3.43.0"
project = var.project
region = var.region
}

terraform {
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer
# compatible with any versions below 0.12.
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
Loading

0 comments on commit e258f14

Please sign in to comment.