CodeDeploy
Introduction
Section titled “Introduction”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.
Getting Started
Section titled “Getting Started”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.
Applications
Section titled “Applications”An application is a CodeDeploy construct that uniquely identifies your targetted application. Create an application with the CreateApplication operation:
awslocal deploy create-application --application-name hello --compute-platform Server
{ "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.
awslocal deploy get-application --application-name hello
{ "application": { "applicationId": "063714b6-f438-4b90-bacb-ce04af7f5e83", "applicationName": "hello", "createTime": 1747663397.271634, "computePlatform": "Server" }}
You can list all application using ListApplications.
awslocal deploy list-applications
{ "applications": [ "hello" ]}
Deployment configuration
Section titled “Deployment configuration”A deployment configuration consists of rules for deployment along with success and failure criteria.
Create a deployment configuration using CreateDeploymentConfig:
awslocal deploy create-deployment-config --deployment-config-name hello-conf \ --compute-platform Server \ --minimum-healthy-hosts '{"type": "HOST_COUNT", "value": 1}'
{ "deploymentConfigId": "0327ce0a-4637-4884-8899-49af7b9423b6"}
ListDeploymentConfigs can be used to list all available configs:
awslocal deploy list-deployment-configs
{ "deploymentConfigsList": [ "hello-conf" ]}
Use GetDeploymentConfig and DeleteDeploymentConfig to manage deployment configurations.
awslocal deploy get-deployment-config --deployment-config-name hello-conf
{ "deploymentConfigInfo": { "deploymentConfigId": "0327ce0a-4637-4884-8899-49af7b9423b6", "deploymentConfigName": "hello-conf", "minimumHealthyHosts": { "type": "HOST_COUNT", "value": 1 }, "createTime": 1747663716.208291, "computePlatform": "Server" }}
Deployment groups
Section titled “Deployment groups”Deployment groups can be managed with:
- CreateDeploymentGroup
- ListDeploymentGroups
- UpdateDeploymentGroup
- GetDeploymentGroup
- DeleteDeploymentGroup
Create a deployment group with CreateDeploymentGroup:
awslocal deploy create-deployment-group \ --application-name hello \ --service-role-arn arn:aws:iam::000000000000:role/role \ --deployment-group-name hello-group
{ "deploymentGroupId": "09506586-9ba9-4005-a1be-840407abb39d"}
List all deployment groups for an application with ListDeploymentGroups:
awslocal deploy list-deployment-groups --application-name hello
{ "deploymentGroups": [ "hello-group" ]}
Get a deployment group with GetDeploymentGroup:
awslocal deploy get-deployment-group --application-name hello \ --deployment-group-name hello-group
{ "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 }}
Deployments
Section titled “Deployments”Operations related to deployment management are:
Create a deployment with CreateDeployment:
awslocal deploy create-deployment \ --application-name hello \ --deployment-group-name hello-group \ --revision '{"revisionType": "S3", "s3Location": {"bucket": "placeholder", "key": "placeholder", "bundleType": "tar"}}'
{ "deploymentId": "d-TU3TNCSTO"}
List all deployments for an application with ListDeployments:
awslocal deploy list-deployments
{ "deployments": [ "d-TU3TNCSTO" ]}
Get a deployment with GetDeployment:
awslocal deploy get-deployment --deployment-id d-TU3TNCSTO
{ "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:
awslocal deploy continue-deployment --deployment-id d-TU3TNCSTO
Stop a deployment with StopDeployment:
awslocal deploy stop-deployment --deployment-id d-TU3TNCSTO
{ "status": "Succeeded", "statusMessage": "Mock deployment stopped"}
Limitations
Section titled “Limitations”All CodeDeploy operations are currently mocked.
API Coverage
Section titled “API Coverage”Operation ▲ | Implemented | Image |
---|