0

I want to automate the process by which when I push my code to my private repository on Bitbucket, it will directly update on my EC2 Instances. For that I gained some knowledge which was like:

AWS CodeDeploy is used for that. What I have learned is:

  • Go to IAM Role and create the role and attach the policy i.e AmazonEC2RoleForCodeDeploy & AWSCodeDeployRole
  • Edit Trust Relationship -> "service": "codedeploy.amazonaws.com"
  • At the time of the creation of EC2 Instance use the IAM Role to the role which we just created.

But I am confused about the YML code which will be paste on Advance Details (at the time of Instance Creation).

I attended many Blogs and youtube tutorials but getting confused about the right implementation.

On some tutorial, used S3 for code deploy. I am a little confused about this problem regarding the automation process.

My simple requirement is When I update/push the code on my personal branch, it will update on my directory which is under my EC2 instance.

Any AWS expert or DevOps will help me with that, Kindly share the best efficient manner to achieve this task. I am Mentioning "expert" because I need the best and optimum solution not the solution to achieve the goal.

Any help or suggestion is really appreciated for that. Pardon me if there is some typo error or any grammatical error on mine query.

Aks
  • 1,092
  • 3
  • 12
  • 29

1 Answers1

0

The basic steps would be:

  1. Add the CodeDeploy addon from from Bitbucket's App Marketplace and configure it.
  2. To add an IAM role that allows Bitbucket to first push code to an intermediate S3 bucket in your account.
  3. Once you've configured the CodeDeploy settings from the Settings page of the Bitbucket console, you can perform a deployment to the Deployment group from your branch and monitor this in the Codedeploy console.

The blog below has clear and detailed steps for this: https://aws.amazon.com/blogs/apn/announcing-atlassian-bitbucket-support-for-aws-codedeploy/

The Yaml file you are confused about is the Appspec file that tells CodeDeploy what actions to perform during a Deployment.

The bare minimum appspec.yml file you can have to deploy all the files from the source package:

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/html

This file is placed in the root of your source code.

Appspec file example: https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-example.html#appspec-file-example-server

shariqmaws
  • 8,152
  • 1
  • 16
  • 35