Giter Club home page Giter Club logo

terraform-with-github-actions's Introduction

Terraform CI/CD for Deploying AWS Services

Terraform GitHub Actions AWS

Overview

This project demonstrates how to create and manage infrastructure using Terraform and automate the deployment process using GitHub Actions as CI/CD.

Table of Contents

Introduction

This repository provides a modular approach to creating AWS resources such as:

  • Application Load Balancer
  • Security Groups
  • EC2 Instances
  • VPC

The deployment process is fully automated using GitHub Actions, triggered on every push to the main branch.

Terraform Modules

  • VPC Module: Creates a Virtual Private Cloud.
  • Security Groups Module: Manages security groups.
  • EC2 Module: Provisions EC2 instances.
  • Application Load Balancer Module: Sets up an ALB.

AWS S3 Remote Backend

We use AWS S3 to store the Terraform state files remotely, enabling team collaboration and state locking.

GitHub Actions Workflow

The GitHub Actions workflow is defined in .github/workflows/deploy.yml and includes the following steps:

  1. Checkout Code: Checks out the repository code.
  2. Set up Terraform: Installs Terraform.
  3. Initialize Terraform: Initializes Terraform configuration.
  4. Validate Terraform: Validates the Terraform configuration.
  5. Apply Terraform: Applies the Terraform configuration to provision resources.
  6. Destroy Terraform: Destroys the infrastructure (commented out).

Getting Started

Prerequisites

  1. Terraform installed
  2. AWS CLI configured with appropriate credentials
  3. GitHub repository with Secrets for AWS credentials
  4. Installation
  • Clone the repository:

git clone https://github.com/parvez76/terraform-with-github-actions

cd iaac

terraform init

Usage

Deploy Infrastructure: Push your changes to the main branch to trigger the GitHub Actions workflow:

git add .

git commit -m "Deploy infrastructure"

git push origin main

Destroy Infrastructure: To destroy the infrastructure, uncomment the Terraform Apply section in the workflow and comment out the Terraform Destroy section, then push the changes.

terraform-with-github-actions's People

Contributors

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