Coder Social home page Coder Social logo

terraform-jenkins's Introduction

Terraform-Jenkins

This repository helps to build infrastructure such as AWS using Terraform with Jenkins Pipeline.

Jenkins and Terraform and AWS

Screen Shot 2021-07-01 at 4 43 17 PM

Jenkins

Install Terraform plugin

To Install Terraform plugin,

Go to Manage Jenkins > Manage Plugins >Available > search Terraform > Choose to install Terraform plugin.

Add AWS Credentiols

To configure AWS credentials in Jenkins:

  1. Install Pipeline: AWS Steps navigate to Manage Jenkins > Manage Plugins under the Available tab of the Jenkins dashboard. Choose to install the Pipeline: AWS Steps plugin without a restart.

  2. Add Aws credentials: You can add credentials by navigating to Manage Jenkins > Manage Credentials > Jenkins (global) > Global Credentials > Add Credentials. Choose kind as AWS credentials and enter "terraform-credentials" as the ID. Enter the access key ID and access key secret, then select OK. 1cred Note! if you can not see the AWS credentials after adding the plugin. please go to Manage Jenkins > Configure Credential Providers > change Providers to all available and change types to all availlable. 2 credentioalproviders

Add Terraform Pipeline

To add Terraform Pipeline, Go to new item > Enter an item name > choose Pipline > Click OK. Then, To add Jenkinsfile: Go to Advanced Project Options > In Pipline Section > Select "Pipline script from SCM" . > Select "Git" in SCM section > Insert Repository URL (https://github.com/Omidznlp/Terraform-Jenkins.git) in Repositoriis Section

ec2modual

In Section Branches to build, Insert (*/master) > In Script Path, Insert (Jenkinsfile) > Click Save.

ec22

Jenkins Nodes Label

I used agent with "master" label to build Terraform Pipile, In Jenkinsfile into repositoy you can find it.

    agent {
      node {
        label "master"
      } 
`    }

I gave my Jenkins server the label "master," and then I ran Terraform on it. Go to Manage Jenkins > Click "Manage nodes and clouds" > Select setting (left side of the list of nodes) > Under the label section, add "master" > Save it.

nodelabel

Note! Simply, you can change the label on the Jenkinsfile or choose your node from your node lists from which you would like to execute terraform and then add the "master" label to it.

Run Jenkins Pipline

Build with parameters: choose an action "apply or destroy"? choose param

Before "TF Apply" or TF Destroy" stage, you must approve it manually in the Approval and Removal Stage by clicking on it and selecting "Proceed.".

pipiline1

terraform-jenkins's People

Contributors

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