GithubHelp home page GithubHelp logo

terraform-with-ci-cd's Introduction

This is an image

Project Title -Terraform-with-CI-CD

This project is used to deploy Infrastructure like VPC,subnets through terraform and automating it with the help of Jenkins CI/CD pipeline.

Project Description

This Project contains a full, real-world solution for setting up an environment using DevOps technologies and practices for deploying cloud services/cloud infrastructure like Virtual Private Cloud to AWS.

Technology Used/Details

You will be using the following technologies and platforms to set up a DevOps environment.

  1. AWS
    • AWS will be used to host the application, cloud infrastructure, and any other services we may need to ensure the VPC is deployed properly.
  2. GitHub
    • To store the application and infrastructure/automation code
  3. Terraform
    • To automate the infrastructure deployment on AWS
  4. Jenkins CI/CD
    • Used Jenkins to create CI and CD pipeline
  5. Git bash
    • This tool is ues to SSH in EC2 instance and to push local files to git hub

Prerequisites

  1. AWS EC2 linux/ubuntu instance
  2. Configure Jenkins on the AWS instance by following the steps mentioned here
  3. Install necessay plugin on Jenkins like Terraform, Github.
  4. Install Terraform on the same EC2 instance by following the steps mentioned here
  5. Install git on the instance by sudo yum install git -y
  6. Integrate/Configure Github with Jenkins by following the steps here
  7. Create an IAM role with full administrative access and attach it to the EC2 instance.

Steps Performed in the Project

  1. Create a directory in local machine and create two terraform files in it-

    • Provider.tf to mention the AWS provided with the region defined. Reference
    • VPC.tf to mentione the virtual private cloud components. Reference
  2. Push the code in Github

git init -x main
git add .
git commit -x "initial commit"
git remote add origin  <REMOTE_URL> 
git remote -v
git push origin main/master
  1. Create a new pipeline Project in Jenkins
  2. Mentioned the stages in the groovy script
pipeline{
    agent any
    tools {
        terraform 'terraform-11'
    }
    stages{
        stage('Git Checkout'){
           steps{  
                git credentialsId: '30c1c3e9-2949-4138-971d-xxxxxxxx', url: 'https://github.com/tanuj888/Terraform-with-CI-CD'
            } 
        }
        stage('Terraform init'){
            steps{  
               sh 'terraform init'
            }
        }
        stage('Terraform Apply'){
            steps{  
               sh 'terraform apply --auto-approve'
            }
        }
        stage('Terraform Destroy'){
            steps{  
               sh 'terraform destroy --auto-approve'
            } 
        }
    }    
}
  1. As soon you hit save, click on build now to build this pipeline.

  2. Go to your AWS Console and you'll find a new VPC created.

  3. Clean Up Resources

  • Add a step Terraform destroy in the pipeline as mentioned in the scipt above which will destroy the created infrastructure.

terraform-with-ci-cd's People

Contributors

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