This article explains the steps to add Bitbucket to AWS using CodeDeploy. Bobcares, as a part of our 24/7 AWS Support Services, offers solutions to every query that comes our way.
Steps to add Bitbucket to AWS using CodeDeploy
The procedures to automate the delivery of a simple PHP script on an AWS EC2 Instance each time a git push is performed to on bitbucket master repository are as follows:
- Setting up the IAM Group, User, and Role with the permissions.
- Creating an S3 bucket.
- Creating an EC2 Instance.
Setting up the IAM Group, User, and Role with the Permissions
1. IAM Group
-
- Open the IAM console after logging into the AWS Management Console.
- Select Groups from the navigation bar, then select Create New Group.
- Type the group’s name in the Group Name box, then click Next Step.
- Check the boxes next to Policy -AmazonS3FullAccess, AWSCodeDeployFullAccess.
- Select Create Group.
2. IAM User
-
- Select Users from the navigation pane, then select Add user.
- Enter the new user’s user name.
- Select “programmatic access” as the type of access.
- Choose the “Add user to group” permission option on the Set Permissions screen.
- Select the group created in step 1 under the Add User to the group section. Remember to save the Access Key and Secret Access Key.
3. IAM Role
In IAM, create a role called AWSCodeDeployRole and choose the EC2 Service option because our EC2 instance will use that role to communicate with CodeDeploy later on. Add the policies AmazonS3FullAccess and AWSCodeDeployRole to the role. Once the role has been created, modify the Trust Relationship to look like this. Also, set the region to the appropriate one.
{ "Version": "2012–10–17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "ec2.amazonaws.com", "codedeploy.us-east-1.amazonaws.com" ] }, "Action": "sts:AssumeRole" } ] }
S3 Bucket and EC2 Instance creation
S3 Bucket
-
- Open the Amazon S3 console after logging in to the AWS Management Console.
- Select Create bucket.
- Give the new bucket a specific name.
EC2 Instance
Make an EC2 Instance next. Choose an OS based on our needs. The IAM Role-AWSCodeDeployRole that we generated needs to be added. Now that we need to tag it so that AWS Code Deploy can recognize our instance. Then open the appropriate ports in security groups that the application requires, such as port 80 for application.
Install the CodeDeploy Agent on the server after launching the instance. The installation procedure may differ based on the OS. Make sure the Code Deploy agent is running and follows the directions for our OS.
[Looking for a solution to another query? We are just a click away.]
Conclusion
To conclude, we provide the steps from our Support team to automate the delivery of a simple PHP script on an AWS EC2 Instance each time a git push is performed to on bitbucket master repository.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
var google_conversion_label = "owonCMyG5nEQ0aD71QM";
0 Comments