Hi all,
As a budding DevOps engineer, I was curious how an application created would build a job and deploy to the Instances where the Application is deployed .
Lets learn a simple Architecture to deploy an application to an ASG.
Use Case
Whenever the code is pushed to Git, it should trigger deployment to the instances in AutoScaling Group(ASG) . The code uses a Jenkins server , as the intermediator and uses AWS CodeDeploy to build and push the latest code to instances in ASG.
Basic Steps:
Step 1:Create 2 IAM Roles - An IAM Role when created ,would allow the user (to which the role is attached to) to publish code to CodeDeploy. Another IAM Role would enable the user to publish files to S3 bucket. The file would contain the information about build in CodeDeploy.
Step 2: Create 4 EC2 Instances (for ASG ), S3 bucket to store files related to CodeDeploy .
Step 3: Create an AMI from one of the instances, which we would need to provide to update in Launch Configuration.
Step 4: Create Target Group & ALB (in configure routing step, we need to add target group and select the instances that are part of the ASG)
Step 5: Create Launch Configuration specifying details of the AMI , Rules-protocols
Step 6: Create an ASG(need to add launch configuration, load balancer, max/desired/min instance)
Step 7: Create Jenkins instance.
Step 8 : Create a Deployment Group in AWS CodeDeploy service, attaching the service role and ASG
Step 9: Create Jenkins pipeline to deploy code to CodeDeploy , use POLL SCM. In post build action > deploy an application to AWS CodeDeploy.
Copy the Elastic Load Balancer DNS in the browser & voila , we see that the application is deployed on the instances . Please note that the AWS services used here is not free and will incur costs.