Giter VIP home page Giter VIP logo

oscarsantosmu / terraform-preview-envs Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 195 KB

A repo using GitHub actions and Terraform to create cloud services using the GitHub Flow to preview the changes in ephemeral environments before being deployed to production.

License: MIT License

Dockerfile 6.61% Python 14.32% Shell 8.33% HCL 70.74%
cloud-services github-flow iac preview-environment terraform

terraform-preview-envs's Introduction

terraform-preview-envs

Conference at Talent Land 2023

This repository contains infrastructure as code written in Terraform that creates cloud services using GitHub actions, allowing changes to be previewed in ephemeral environments before being deployed to production.

Workflows

tf-unit-tests.yml: Runs unit tests for Terraform code and creates code scanning reports.

tf-drift.yml: Detects drifts between Terraform configuration and the actual state of the cloud resources, then creates issue.

tf-plan-apply.yml: Applies the Terraform changes in the cloud production environment.

tf-prev.yml: Creates a preview environment for a pull request, allowing changes to be tested before they are merged.

Getting started

  1. Create an Azure Storage account.
  2. Update Storage account info on main.tf at the backend block.
  3. Create 2 apps on Azure Active Directory (Write and Read)
  4. Register federated credentials for each of them (using environments, pull requests and branches)
  5. Assign RBAC to the Storage Account with Reader and Data Access to both apps.
  6. Assign RBAC to your Azure Subscription with Contributor for the Write app and Reader for the other app.
  7. Get Client Id, Object Id and Tenant Id from both apps.
  8. Register them as GitHub secrets and separating Client Id on environment secrets.
  9. Create a branch called prevenvs
  10. Create a branch with your feature and make a pr. Compare it with prevenvs.
  11. A GitHub Action workflow will be triggered

  1. Once deployed and success on the checks. Merge the pull request and check the ephemeral environments has gone.

Contributing

Contributions to this project are welcome. If you would like to contribute, please read the CONTRIBUTING.md file for guidelines.

Resources

Terraform

Tutorials

Examples

Terraform

Docker sample

terraform-preview-envs's People

Contributors

oscarsantosmu avatar

Watchers

 avatar

terraform-preview-envs's Issues

[FEATURE] Add a sample project to show GitHub flow on action

Is your feature request related to a problem? Please describe.
This will clarify how useful are preview environments.

Describe the solution you'd like
Add a sample project.

Describe alternatives you've considered
Use other repositories at the bash script without actually having it at the current repository.

Additional context
Can or cannot use project source code to deploy a preview environment.

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.