GithubHelp home page GithubHelp logo

terraform-aws-jenkins's Introduction

terraform-aws-jenkins

An AWS EC2 setup running Jenkins provisioned via Terraform.

Requirements

  • Terraform 0.9+

Prerequisites

  • Please ensure you have the aws cli application working

  • Before you run this repo, ensure you've ran the terraform-aws-init repo. That will ensure you have the terraform-states s3 bucket and a root-ssh-key for shell access to jenkins.

Instructions

The scripts can be called with the following parameters:

tf-plan.sh <env_name> <region> <availability_zones> <ssh_key_name>

You can leave these blank if you provisioned in us-west-2 and just launch ./tf-plan.sh

Once the plan runs and everything looks good, you can provision your jenkins instance by running ./tf-apply.sh

That is all there is to it! You can then see the IP of your Jenkins instance and ssh or browse to it.

To ssh ssh [email protected]

Jenkins UI can be seen browsed at x.x.x.x:8080 where x.x.x.x is the output IP address of the ec2 instance.

Important Notes

If you provision this Jenkins terraform script with something that deletes and creates a new Jenkins instance, (because yes that can happen) don't freak out. You can login to the AWS EC2->Volumes page and detach the new drive and add the old one back. All your Jenkins/Docker data should be stored on this volume.

  1. SSH into Jenkins and stop Jenkins sudo service jenkins stop
  2. Unmount the new drive sudo umount /dev/xvdf
  3. Detach the volume in the AWS dashboard.

Delete drives not in use anymore as they will pile up even after a terraform destroy.

Destroying

Just run ./tf-destroy.sh but in order to finalize cleanup you'll need to delete one last thing manually.

There is a 250 GB drive mounted to Jenkins that is not destroyed when you destroy the instance with terraform, you have to manually goto AWS EC2 Volumes and destroy the drive that way.

This is to prevent critical production data from getting destroyed but yea, I even keep forgetting to kill these drives...

TODOs

This could probably be further improved by using Ansible, Puppet, Chef, or something like that to provision any OS. This is really locked to Debian at the moment.

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.