- AWS CLI Installations:– Click Here
- Configure Service Role for S3.
- Go to IAM
- Click on Role. Select AWS services –> Ec2. Click on Next Permission.
- Select S3FullAccess Click on Tag (optional)–>Click on Review.
- Define Role Name –> Click on Create.
- Configure Service Role for CodeDeploy.
- Go to IAM
- Click on Role. Select AWS services –> CodeDeploy
- Select your Use Case –>CodeDeploy
- Click on Next Permission. Click on Tag(optional)–>Click on Review.
5. Define Role Name –> mycodedeployrole.Click on Create.
Steps to Deployment of Web Application
1. Create an EC-2 Instance.
- Choose an Amazon Machine Image (AMI), find the Amazon Linux AMI at the top of the list and choose Select.
- Choose an Instance Type, choose Next: Configure Instance Details.
- Configure Instance Details, choose Network, and then choose the entry for your default VPC. It should look something like vpc-xxxxxxx (172.31.0.0/16) (default).
- Choose Subnet, and then choose a subnet in any Availability Zone.
- Select IAM role as mys3role.
- Choose Next: Add Storage.
- Choose Next: Tag Instance. (It is very important to assign tag to ec2 instance because code deploy on ec2 based on tag only)
- Configure Security Group, review the contents of this page, ensure that Assign a security group is set to Create a new security group, and verify that the inbound rule being created has the following default values.
- Type: SSH, HTTP
- Protocol: TCP
- Port Range: 22, 80.
- Source: Anywhere 0.0.0.0/0
- Select Key pair. Click on Launch.
- Access EC2-using Putty Click Here
2. Install CodeDeploy agent for EC2(Ubuntu Server)
#sudo yum update
#sudo yum install –y httpd php
#sudo yum install ruby
#sudo yum install wget
Note:- bucket-name is the name of the Amazon S3 bucket where your codedeploy resourcekit files stored region wise. Find your region bucket name.
#chmod +x ./install
#sudo ./install auto
#sudo service codedeploy-agent status
3. Create a developer machine which is connected with AWS CodeDeploy service (Help to upload code to S3)
- Go to the IAM on AWS Console.
- Create User. Name:-cddemouser
- Select programmatic access.
- Assign Permission. Click on existing Policy.
- Click on Create.
- Use Access key & Secret Key in AWS CLI on your Local machine.
- Open Type aws configure
- Enter Access key, Secret key, Default Region (region must be the same as EC2)(skip), Default output format (skip).
Download WebApp code click on demo.zip
- Go to the web app directory.
- Now create bucket in S3. Name –>cddemo
- Now Create your demo.zip and load it into CodeDeploy & Push Code from Local machine(AWS CLI) to s3 using two commands.
- #aws deploy create-application –application-name demo
- #aws deploy push –application-name demo –s3-location s3://<MY_BUCKET_NAME>(cddemo)/demo.zip –ignore-hidden-files
- Now Check in your S3 bucket, demo.zip is uploaded.
4. Now Open CodeDeploy.
- Click on create the application.
- Now click on Create deployment group.
- deployment group name :- demo
- Service Role:- select mycodedeployrole
- Deployment type:- In-Place
- Environment configuration:- select Amazon EC2 instances
- Key:- AppName
- Value:- Demo
- Deployment settings:-CodeDeployDefault.AllAtOnce
- Load balancer:- Uncheck(not required)
- Click on Create deployment and go to the Deployment settings
- Deployment group:- select demo
- Revision type:- My application is stored in Amazon S3
- Revision location:- s3://cddemo/demo.zip
- Remaining things as it is click on Create deployment
OutPut: –Now Go to EC-2 Console copy IP address and open in web browser.
Reference from:- acloudguru, Amazon Web Services.