Integrate and deploy code from GitHub to aws ec2 - elastic beanstalk
This is a continuous of CI CD process .
Visit and configure all parts before doing this.
Part One | Part Two | Part Three
Navigate to the Jenkins and click on New Item to set up a new project.
Next, navigate to github and select the project repository, which want to integrate and deploy using CI CD.
Here using a Node Js application. And this is a git url https://github.com/avinashkumar-github/elasticbeanstalk-nodejs-sample-app.git
Copy the URL and navigate to the Jenkins page.
Add a new webhooks
In the payload URL : <Jenkins URL>/github-webhooks/
Make sure to use the trailing slash
Now, navigate back to the Jenkins. and shoose the execute shell, under the Build section. And add the below code. This will be vary based on the region and platform you are using.
All these information, you can collect from the AWS console.
#!/bin/bash -xeAPPLICATION=YOUR_APPLICATION_NAME_HEREREGION=YOUR_REGION_NAME_HEREENVIRONMENT=YOUR_ENVIRONMENT_NAME_HEREPLATFORM=YOUR_PLATFORM_HERE# confirm the role being usedaws sts get-caller-identity# intialize the applicationeb init "${APPLICATION}" --platform "${PLATFORM}" --region "${REGION}"# select the environmenteb use "${ENVIRONMENT}"# deploy the applicationeb deploy# get the deployment's health and status informationeb healtheb status
All is set now, make any changes now in your project repository in github, commit and push the code . Automatically a build gets triggered in Jenkins using github webhook. and the build pull and integrate the code from github, and deploy it to the elastic beanstalk application.
This way a CI CD process can be set up .
To get the URL of beanstalk application, navigate to the EC2 dashboard or beanstalk dashboard, a public URL will be there to access.
















0 Comments