jevgenyr / jenkins-terraform-pipeline

Jenkins Terraform Pipeline Example

Repository from Github https://github.comjevgenyr/jenkins-terraform-pipelineRepository from Github https://github.comjevgenyr/jenkins-terraform-pipeline

alt text

maintained by Core Solutions GitHub tag Terraform Version License

Jenkins Terraform Pipeline Example

The Jenkins pipeline used in this repo defines of various stages used to initialise, plan, approve and apply terraform configurations

This repo is intended to showcase the simplicity of leveraging Jenkins, Terraform & Ansible together and how to best structure an IaC repo with clear demarcation between Infrastructure as Code & Configuration Management.

Jenkins Dependencies

  • Setup with AWS authentication

  • Terraform 12 installed and working

Setup

In order to run this example pipeline yourself you'll first need to fork this repo, then complete the following changes:

  • Update the BACKEND_BUCKET value

  • Update the filters in data.tf to reference values applicable to your AWS environment

  • Create a new Jenkins pipeline using the location of your forked repo

  • Create a DynamoDB table for state locking defined as terraform-state-lock

You can use the Terraform/Setup configuration to create a test S3 backend bucket / Dynamo table if needed, if you'd prefer to use existing infrastructure just update the values in the Jenkinsfile & terraform.tf accordingly

Usage

Running the pipeline will create everything in the Demo directory for the environment specified, it will pause for manual approval before making any changes, this allows you to fully review the tf plan before proceeding.

Input Parameters

Parameter Options Description
Action build or destroy The action to take on the terraform infrastructure
Colour blue or green The leg to take action on

About

Jenkins Terraform Pipeline Example

License:Apache License 2.0


Languages

Language:HCL 63.8%Language:Ruby 16.0%Language:Dockerfile 11.0%Language:Shell 4.7%Language:HTML 4.4%