Coder Social home page Coder Social logo

terraformazureactiontemplate's Introduction

TerraformAzureActionTemplate

This repository will have some basic folder structure and a GitHub action for deploying Terraform IaC to Azure. It will serve as a template for future projects/lab work.

Azure Integration

In order for Terraform to be able to connect to Azure you'll need to create a service principal along with a secret. Once you create the service principal add the following secrets to your GitHub Repository under Repository Settings > Secrets and variables > Actions:

  • AZURE_CLIENT_ID
  • AZURE_CLIENT_SECRET
  • AZURE_SUBSCRIPTION_ID
  • AZURE_TENANT_ID

GitHub Actions

There are several workflows in this template which can be found under ./.github/workflows. Keep in mind these are very simple examples meant for my lab, and would not be appropriate for most production deployments.

Terraform-destroy.yml

This workflow installs Terraform and then runs terraform destory. This is helpful for cleaning up lab environments so you don't get billed for something you're not using.

Terraform-docs.yml

This workflow used a pre-built action to run Terraform Docs. There is a config file located in the ./terraform directory which allows for customization. This action also supports more advanced configurations such as nested modules and Atlantis files. This workflow runs on any pull request and ensures that documentation Markdown is generated before merging the pull request.

Terraform-plan-apply.yml

This is the core worklfow which actually applies the IaC (Infrastructure as Code) using Terraform. This workflow performs a number of actions:

  1. TFLint - This step runs a pre-built GitHub action that runs TFLint and leaves appropriate comments directly on the code in the pull-request. reviewdog/action-tflint@master
  2. Terraform Format
  3. Terraform Validate
  4. Terraform Init
  5. Terraform Plan
  6. PR Comment Script - This step runs a custom bash script based on a script provided by Hashicorp. The script takes the output from the previous steps including the full Terraform Plan output and submits them as a comment on the PR for easy review.
  7. Terraform Apply - Once the PR has been merged into the main branch (or upon any commit directly to the main branch) the final action is to run Terraform Apply. This step will only run if the Terraform Apply step was successful.

super-linter.yml

This is a Linter created by GitHub which is capable of checking code in multiple languages. This is helpful for generic templates that may be used with any language. More information and configuration options can be found here.

Terraform Docs

The output from Terrform Docs can be found: here

References

  1. GitHub Actions
  2. Terraform
  3. Terraform Docs
  4. Terraform Linter
  5. Markdown

terraformazureactiontemplate's People

Contributors

github-actions[bot] avatar joey40 avatar

Stargazers

 avatar  avatar

Watchers

 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.