Skip to content

david-wells-1/jenkins-vagrant-terraform-pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create a Vagrant Jenkins instance with a Terraform Pipeline

This is a lab to demonstrate running Jenkins on a Vagrant VM and create a Jenkins pipeline which will use terraform to create a security group in AWS

Setup

Use the Vagrantfile to create and install required components (using Virtualbox):

vagrant up

Retrieve the Jenkins initial admin password:

vagrant ssh
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

The Jenkins URL is http://127.0.0.1:8080

After initializing Jenkins; install the recommended plugins and the CloudBees AWS Credentials Plugin https://plugins.jenkins.io/cloudbees-credentials

Install the Blue Ocean plugin (optional) https://plugins.jenkins.io/blueocean

AWS Credentials

You will need IAM user credentials with permissions to create an ec2 Security Group.

Within Jenkins Credentials; add a Global Credential of type AWS Credential

  • Set ID to aws-creds This is used in the pipeline Credentials Binding credentialsId
  • Add your ACCESS_KEY_ID This is used in the pipeline Credentials Binding accessKeyVariable
  • Add your SECRET_ACCESS_KEY This is used in the pipeline Credentials Binding secretKeyVariable

Pipeline

Create a pipeline job:

  • Within the Pipeline configuration set the definition to Pipeline script from SCM
  • Add Git repository URL https://github.com/david-wells-1/jenkins-vagrant-terraform-pipeline.git
  • The Script Path will automatically be set to the Jenkinsfile.

In this example, the Jenkinsfile pipeline will create a security group in the default VPC in eu-west-2

Releases

No releases published

Packages

No packages published

Languages