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
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#
Create shortlink-codedeploy-service-role#
Open IAMRolesCreate role.
| Field | Value |
|---|---|
| Trusted entity type | AWS service |
| Use case | CodeDeploy (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.
| Field | Value |
|---|---|
| Application name | shortlink-api |
| Compute platform | EC2/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#
| Field | Value |
|---|---|
| Deployment group name | shortlink-api-prod |
| Service role | shortlink-codedeploy-service-role |
| Deployment type | In-place |
Environment configuration#
| Field | Value |
|---|---|
| Environment configuration | Amazon EC2 instances |
| Tag group 1 → Key | Name |
| Tag group 1 → Value | shortlink-api |
| Agent configuration with AWS Systems Manager | Never (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#
| Field | Value |
|---|---|
| Deployment settings | CodeDeployDefault.AllAtOnce |
| Load balancer | tick Enable load balancing |
| Load balancer type | Application Load Balancer or Network Load Balancer |
| Target group | shortlink-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#
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 jsonconfig 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.