Giter Site home page Giter Site logo

rrey / terraform-test-sample Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 331 KB

Demonstrate testing strategies around Terraform

HCL 3.81% Ruby 85.50% Open Policy Agent 4.36% Python 6.33%
terraform testing kitchen-terraform openpolicyagent conftest pytest

terraform-test-sample's Introduction

Terraform test samples

This repository contains a dummy Terraform module with a Github Actions CI implementing:

  • Integration tests using kitchen-terraform for test orchestration
    • A sample verification using inspec
    • A sample verification using pytest
  • Conformity test using conftest and opa (Open Policy Agent)

Pros and Cons

  • Inpec:
    • Pro: syntax with super easy to read
    • Con: there is a flavor for each cloud provider (inspec-azure, inspec-aws, inspec-gcp) with different support, reactivity and capabilities. I always had to open issues to request a feature addition.
  • Unittest:
    • Pro: Standard test framework that Python developpers will be super confortable with. Using the framework means you will use the cloud provider Python SDK in the tests. No missing feature here.
    • Cons Kitchen is in Ruby, unittest is Python. Combining the 2 means you will have to setup Ruby and Python environment.

Tests are using the module usage example locates in examples/.

Why writting integration tests with Terraform ?

When you write a module, you are using a specific version of Terraform and a specific version of a provider. Can you safely upgrade these 2 components when a major version is released ? Spoiler: No

The providers upgrade can introduce new parameter names that are first displayed as deprecation warning before failing in other release. If you don't follow the releases and update your modules accordingly, you could have several modules that become unusable after a few month. Integration tests can help you detecting the failure and be sure that everything still works as expected after you made a fix.

Module documentation

Requirements

Name Version
azurerm ~> 2.6

Providers

Name Version
azurerm ~> 2.6

Inputs

Name Description Type Default Required
location The resource group location string "westeurope" no
rg_name The resource group name string n/a yes
rg_owner The resource group owner string n/a yes
rg_tags The resource group tags map {} no

Outputs

Name Description
rg The resource group

terraform-test-sample's People

Contributors

dependabot[bot] avatar rrey avatar

Stargazers

 avatar

Watchers

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