Skip to content

Example Terraform project for GCP showing how to integrate Forseti Validator into CI.

Notifications You must be signed in to change notification settings

GSA/odp-terraform-validator-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Terraform

Overview

This is an Terraform project that runs the Forseti Terraform Validator within it's CI Pipeline. This project can be used to as a template for creating future Terraform projects or projects that integrate Terraform into their CI Pipelines.

Table of Contents

Project Contents

Folder / File Description
.circleci/config.yml CircleCI Configuration file that controls the CI Pipeline
master The directory containing the Terraform files that will be tested via the CI Pipeline when changes are made to the master branch.

Project Setup

Variables

The following variables need to be set either by setting proper environment variables or editing the variables.tf file:

Variable Type Description
project_id string GCP ProjectID
cloudsql_db_name string Database name
cloudsql_username string Database primary username
cloudsql_password string Database primary user's password
cloudsql_tier string Instance tier to deploy your CloudSQL database to.
region string Region to deploy your CloudSQL database to.

Setting environment variables

With Terraform you can set / override any Terraform variables using the TF_VAR_ format. This works great for CI Pipelines, and it is the method we employ in this project's .circleci folder.

  • Example setting the region variable :

    export TF_VAR_region="us-east1"

You can also set your variables in a file named .tfvars or .tfvars.json. You can specify your variables file using the command line:

terraform apply -var-file="testing.tfvars"

Remote State

You can setup or remove the configration for a remote state manually by editing or removing the backend.cfg file.

You can alternatively configure the bucket and `prefix varariables from the commandline allowing for variable interpolation:

terraform init -backend-config="bucket=${STATE_BUCKET}" -backend-config="prefix=${STATE_PREFIX}"

Modules

odp_tf_google_sql

See Module README.md for Module details.

CircleCI Configuration

See CircleCI README.md for details

About

Example Terraform project for GCP showing how to integrate Forseti Validator into CI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages