Skip to content

Automated testing terraform using terratest, writting in Go

Notifications You must be signed in to change notification settings

fourirakbar/go-terratest-gcs-example

Repository files navigation

Terratest Example

Description

Simple terratest example with GCS modules. By the way special thanks to @romen for teaching me about terratest.

Feature(s)

What you can do on top of this repository:

  • Create a test for your module terraform
  • Test create a real env on your google project, then destroy it

Prerequisite(s)

To smoothly interact with this repository please install following application in your local device:

  • Linux only (apt install build-essential)
  • Golang (tested on go1.13.1)
  • Terraform (tested on v0.12.19)
  • pre-commit (tested on v1.17.0)
  • Text editor (Vim, Visual Studio Code, Intellij Idea, etc.)

How to Use This Repo

Clone this repository

First thing first, make sure that all prerequisite(s) installed in your device, then clone this repository (make sure you have access to it)

~ git clone git@github.com:fourirakbar/go-terratest-example.git

Setup .pre-commit

~ cd go-terratest-example
~ make setup

Test your code using terratest

~ go mod init test
~ cd test
~ go test -v gcp_gcs_test.go

To Do

  • Integrate with jenkins
  • Integrate with gitlab-ci
  • Add more complex testing
  • Add integration testing with other module

Inputs

Name Description Type Default Required
force_destroy Force destroy when deleting bucket string n/a yes
location Location of the bucket string n/a yes
name The name of the bucket string n/a yes
project Project of the bucket string n/a yes
storage_class Storage class of the bucket string n/a yes

Outputs

Name Description
bucket_url Bucket URL of the bucket
force_destroy Force destroy of the bucket
location Location of the bucker
name Name of the bucket
project Project of the bucker
storage_class Storage class of the bucket

About

Automated testing terraform using terratest, writting in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published