GithubHelp home page GithubHelp logo

isabella232 / terraform-bq-scheduled-queries Goto Github PK

View Code? Open in Web Editor NEW

This project forked from doitintl/terraform-bq-scheduled-queries

0.0 0.0 0.0 6 KB

This is a demo project to use Terraform to manage BigQuery scheduled queries with Cloud Build CI/CD

License: MIT License

Makefile 19.78% HCL 73.15% Shell 7.07%

terraform-bq-scheduled-queries's Introduction

Manage BigQuery scheduled queries with Terraform, Cloud Build and CI/CD

This is a demo project to use Terraform to manage BigQuery scheduled queries. All the CI/CD tasks are run on Google Cloud Build.

Architecture diagram

image

CI

Cloud Build Triggers

Dev

name: tf-dev-plan
description: Run Terraform plan for Dev environment
filename: .cloudbuild/dev-plan.yaml
github:
  name: terraform-bq-scheduled-queries
  owner: derrickqin
  push:
    branch: .*

Prod

name: tf-prod-plan
description: Run Terraform plan for Prod environment
filename: .cloudbuild/prod-plan.yaml
github:
  name: terraform-bq-scheduled-queries
  owner: derrickqin
  push:
    branch: .*

CI tasks

Any new code commit will trigger a Cloud Build build to run the CI process. It contains two steps:

  1. Validate BigQuery SQL query using bq cli with dry-run parameters.
  2. Terraform plan to validate and show new changes.

CD

Cloud Build Triggers

Dev

name: tf-dev-apply
description: Run Terraform apply for Dev environment
filename: .cloudbuild/dev-apply.yaml
github:
  name: terraform-bq-scheduled-queries
  owner: derrickqin
  push:
    tag: dev.*

Prod

name: tf-prod-apply
description: Run Terraform apply for Dev environment
filename: .cloudbuild/prod-apply.yaml
github:
  name: terraform-bq-scheduled-queries
  owner: derrickqin
  push:
    tag: prod.*

CD task

Any tag pushed to Github that matches the regexes will trigger a CloudBuild task to run Terraform apply

To create a tag and push to Github:

For Dev: git tag dev-1.0 && git push origin --tags For Prod: git tag prod-1.0 && git push origin --tags

How to run

  1. Update GCP project IDs in dev.tfvars and prod.tfvars
  2. Initialize TF states by running
    • ENV=dev make init
    • ENV=prod make init
  3. Fork this repo on Github
  4. Connect Github repo on Cloud Build follow this guide
  5. Create CloudBuild triggers as per information in #CI and #CD sessions
  6. Trigger the CI process with git commit --allow-empty -m "Trigger Build" && git push
  7. Trigger the CD process with git tag dev-1.0 && git push origin --tags

terraform-bq-scheduled-queries's People

Contributors

derrickqin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.