Skip to content

Create the CodeDeploy application

A service role, an application and a deployment group that targets your server by its Name tag.

About 20 min · Verified 8 October 2026

0 of 8 steps done0%

CodeDeploy needs three things: a service role that lets it manage your deployment, an application (a named container for revisions), and a deployment group (which servers, how to deploy, what to do on failure).

The service role#

Open IAMRolesCreate role.

FieldValue
Trusted entity typeAWS service
Use caseCodeDeploy (not CodeDeploy for Lambda or CodeDeploy - ECS)

Choose Next. The managed policy AWSCodeDeployRole is attached for you. Choose Next, name the role shortlink-codedeploy-service-role, and Create role.

The application#

Create the application#

Open CodeDeployApplicationsCreate application.

FieldValue
Application nameshortlink-api
Compute platformEC2/On-premises

Choose Create application.

The deployment group#

Open the deployment group form#

In the application, choose Deployment groupsCreate deployment group.

Name, role and style#

FieldValue
Deployment group nameshortlink-api-prod
Service roleshortlink-codedeploy-service-role
Deployment typeIn-place

Environment configuration#

FieldValue
Environment configurationAmazon EC2 instances
Tag group 1 → KeyName
Tag group 1 → Valueshortlink-api
Agent configuration with AWS Systems ManagerNever (you installed the agent yourself)

Under the tag fields the console should say 1 unique matched instance. That is how you know the tag and the agent are found.

Deployment settings and load balancer#

FieldValue
Deployment settingsCodeDeployDefault.AllAtOnce
Load balancertick Enable load balancing
Load balancer typeApplication Load Balancer or Network Load Balancer
Target groupshortlink-app-tg

With load balancing on, CodeDeploy removes the server from the target group while it updates it, and adds it back only after the health check passes. Without it, the load balancer would send visitors to a half-installed app.

Rollbacks#

Expand Advanced and in Rollbacks tick Enable rollbacks, then choose Roll back when a deployment fails. Choose Create deployment group.

Verify#

Your computerShow the deployment group
aws deploy get-deployment-group --region ap-south-1 \
  --application-name shortlink-api --deployment-group-name shortlink-api-prod \
  --query 'deploymentGroupInfo.{config:deploymentConfigName,style:deploymentStyle,tags:ec2TagSet.ec2TagSetList,lb:loadBalancerInfo.targetGroupInfoList[].name,rollback:autoRollbackConfiguration}' \
  --output json
You should see
config is CodeDeployDefault.AllAtOnce, style.deploymentType is IN_PLACE with WITH_TRAFFIC_CONTROL, the tag is Name = shortlink-api, the target group is shortlink-app-tg, and rollback is enabled for DEPLOYMENT_FAILURE.

Next: connect GitHub.

Found a mistake? Edit this page on GitHub.