Skip to content

Instantly share code, notes, and snippets.

@VireshDoshi
Last active February 26, 2018 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VireshDoshi/b2f78c3d7137196a6e975bb819761211 to your computer and use it in GitHub Desktop.
Save VireshDoshi/b2f78c3d7137196a6e975bb819761211 to your computer and use it in GitHub Desktop.
Deploy to AWS Jenkinsfile
pipeline {
agent {
docker {
image 'vireshdoshi/jen-build-node-app-aws:latest'
}
}
stages {
stage('pre-setup') {
steps {
sh 'echo "setup actions go here"'
deleteDir()
}
}
stage('AWS Deployment') {
steps {
withCredentials([
usernamePassword(credentialsId: 'AWS_ACCESS_ID', passwordVariable: 'AWS_SECRET', usernameVariable: 'AWS_KEY'),
usernamePassword(credentialsId: 'GIT_ACCESS_ID', passwordVariable: 'REPO_PASS', usernameVariable: 'REPO_USER'),
]) {
sh 'rm -rf node-app-terraform'
sh 'git clone https://github.com/vireshdoshi/node-app-terraform.git .'
sh '''
terraform init
terraform apply -auto-approve -var access_key=${AWS_KEY} -var secret_key=${AWS_SECRET}
git add terraform.tfstate
git -c user.name="Viresh Doshi" -c user.email="vireshdoshi@time2test.co.uk" commit -m "terraform state update from Jenkins"
git push https://${REPO_USER}:${REPO_PASS}@github.com/vireshdoshi/node-app-terraform.git master
terraform output
'''
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment