Skip to content

CodeDeploy

CodeDeploy is a service that automates application deployments. On AWS, it supports deployments to Amazon EC2 instances, on-premises instances, serverless Lambda functions, or Amazon ECS services. Furthermore, based on the target it is also possible to use an in-place deployment or a blue/green deployment.

LocalStack supports a mocking of CodeDeploy API operations. The supported operations are listed on the API Coverage section.

This guide will walk through the process of creating CodeDeploy applications, deployment configuration, deployment groups, and deployments.

Basic knowledge of the AWS CLI and the awslocal wrapper is expected.

Start LocalStack using your preferred method.

An application is a CodeDeploy construct that uniquely identifies your targetted application. Create an application with the CreateApplication operation:

Terminal window
awslocal deploy create-application --application-name hello --compute-platform Server
Output
{
"applicationId": "063714b6-f438-4b90-bacb-ce04af7f5e83"
}

Make note of the application name, which can be used with other operations such as GetApplication, UpdateApplication and DeleteApplication.

Terminal window
awslocal deploy get-application --application-name hello
Output
{
"application": {
"applicationId": "063714b6-f438-4b90-bacb-ce04af7f5e83",
"applicationName": "hello",
"createTime": 1747663397.271634,
"computePlatform": "Server"
}
}

You can list all application using ListApplications.

Terminal window
awslocal deploy list-applications
Output
{
"applications": [
"hello"
]
}

A deployment configuration consists of rules for deployment along with success and failure criteria.

Create a deployment configuration using CreateDeploymentConfig:

Terminal window
awslocal deploy create-deployment-config --deployment-config-name hello-conf \
--compute-platform Server \
--minimum-healthy-hosts '{"type": "HOST_COUNT", "value": 1}'
Output
{
"deploymentConfigId": "0327ce0a-4637-4884-8899-49af7b9423b6"
}

ListDeploymentConfigs can be used to list all available configs:

Terminal window
awslocal deploy list-deployment-configs
Output
{
"deploymentConfigsList": [
"hello-conf"
]
}

Use GetDeploymentConfig and DeleteDeploymentConfig to manage deployment configurations.

Terminal window
awslocal deploy get-deployment-config --deployment-config-name hello-conf
Output
{
"deploymentConfigInfo": {
"deploymentConfigId": "0327ce0a-4637-4884-8899-49af7b9423b6",
"deploymentConfigName": "hello-conf",
"minimumHealthyHosts": {
"type": "HOST_COUNT",
"value": 1
},
"createTime": 1747663716.208291,
"computePlatform": "Server"
}
}

Deployment groups can be managed with:

Create a deployment group with CreateDeploymentGroup:

Terminal window
awslocal deploy create-deployment-group \
--application-name hello \
--service-role-arn arn:aws:iam::000000000000:role/role \
--deployment-group-name hello-group
Output
{
"deploymentGroupId": "09506586-9ba9-4005-a1be-840407abb39d"
}

List all deployment groups for an application with ListDeploymentGroups:

Terminal window
awslocal deploy list-deployment-groups --application-name hello
Output
{
"deploymentGroups": [
"hello-group"
]
}

Get a deployment group with GetDeploymentGroup:

Terminal window
awslocal deploy get-deployment-group --application-name hello \
--deployment-group-name hello-group
Output
{
"deploymentGroupInfo": {
"applicationName": "hello",
"deploymentGroupId": "09506586-9ba9-4005-a1be-840407abb39d",
"deploymentGroupName": "hello-group",
"deploymentConfigName": "CodeDeployDefault.OneAtATime",
"autoScalingGroups": [],
"serviceRoleArn": "arn:aws:iam::000000000000:role/role",
"triggerConfigurations": [],
"deploymentStyle": {
"deploymentType": "IN_PLACE",
"deploymentOption": "WITHOUT_TRAFFIC_CONTROL"
},
"outdatedInstancesStrategy": "UPDATE",
"computePlatform": "Server",
"terminationHookEnabled": false
}
}

Operations related to deployment management are:

Create a deployment with CreateDeployment:

Terminal window
awslocal deploy create-deployment \
--application-name hello \
--deployment-group-name hello-group \
--revision '{"revisionType": "S3", "s3Location": {"bucket": "placeholder", "key": "placeholder", "bundleType": "tar"}}'
Output
{
"deploymentId": "d-TU3TNCSTO"
}

List all deployments for an application with ListDeployments:

Terminal window
awslocal deploy list-deployments
Output
{
"deployments": [
"d-TU3TNCSTO"
]
}

Get a deployment with GetDeployment:

Terminal window
awslocal deploy get-deployment --deployment-id d-TU3TNCSTO
Output
{
"deploymentInfo": {
"applicationName": "hello",
"deploymentGroupName": "hello-group",
"deploymentConfigName": "CodeDeployDefault.OneAtATime",
"deploymentId": "d-TU3TNCSTO",
"revision": {
"revisionType": "S3",
"s3Location": {
"bucket": "placeholder",
"key": "placeholder",
"bundleType": "tar"
}
},
"status": "Created",
"createTime": 1747750522.133381,
"creator": "user",
"ignoreApplicationStopFailures": false,
"updateOutdatedInstancesOnly": false,
"deploymentStyle": {
"deploymentType": "IN_PLACE",
"deploymentOption": "WITHOUT_TRAFFIC_CONTROL"
},
"instanceTerminationWaitTimeStarted": false,
"fileExistsBehavior": "DISALLOW",
"deploymentStatusMessages": [],
"computePlatform": "Server"
}
}

Furthermore, ContinueDeployment and StopDeployment can be used to control the deployment flows:

Continue a deployment with ContinueDeployment:

Terminal window
awslocal deploy continue-deployment --deployment-id d-TU3TNCSTO

Stop a deployment with StopDeployment:

Terminal window
awslocal deploy stop-deployment --deployment-id d-TU3TNCSTO
Output
{
"status": "Succeeded",
"statusMessage": "Mock deployment stopped"
}

All CodeDeploy operations are currently mocked.

OperationImplementedImage
Page 1 of 0