Maxian Nicu
Maxian Nicu

Reputation: 2294

Jenkins: Deploy application to an EC2 instance

I've been working on a cloud formation template for my environment. I end up with a

But I incurred problem with CodeDeploy configuration with Cloud Formation, as not all features are possible for EC2 instances. After configuring manually CodeDeploy, I get an error while deploying such as "too few unhealthy instances" after which created instances are not destroyed even if rollback is enabled. I'm using right now only one EC2 instance for application, but planning in future to scale.

Is there an alternative for CodeDeploy? I'm interested to trigger deploy from Jenkins Machine.

Upvotes: 0

Views: 1468

Answers (2)

Roshni Nambiar
Roshni Nambiar

Reputation: 11

Ensure that you have assigned the correct IAM role for the EC2 instance by going to the "Instance Settings". This will ensure that your deployment occurs smoothly without throwing that error.

You can also configure the deployment to EC2 using CodeDeploy through jenkins.

Steps to follow:

AWS CodeDeploy:

  1. Create a new CodeDeploy application.
  2. Enter a suitable application name and choose "EC2/On premises" as the compute pleatform.
  3. Add a deployment group under the application. For eg: "test".
  4. Choose in-place deployment.
  5. Add service role as "Codedeploy development". This will allow codedeploy to interact with other AWS services.
  6. Choose a suitable deployment configuration preferably : "OneAtATime" if deploying to a single EC2 instance.
  7. Environment configuration : Choose the EC2 instance in which you want to deploy the application

Jenkins:

  1. On Jenkins, create a job with a suitable application name.
  2. In the "Post Build Action" section, click on "Add Post Build Action" Jenkins - post build configuration
  3. Choose : "Deploy an application to AWS CodeDeploy"
  4. Enter the CodeDeploy and S3 details in the section
  5. S3 bucket will contain all the builds which is used to deploy onto EC2 using Codedeploy

Upvotes: 1

Pyae Phyoe Shein
Pyae Phyoe Shein

Reputation: 13837

For above your requirements, I strongly suggest that using aws elastic beanstalk is better way to deploy codes to aws. Because we could manage those in elastic beanstalk and for code deployment, use codeship is also better way to mange deployment integrated with github instead of aws code deployment.

Upvotes: 1

Related Questions