This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.
CodeDeploy examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with CodeDeploy.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use add-tags-to-on-premises-instances.
- Amazon CLI
 - 
             
                    
To add tags to on-premises instances
The following
add-tags-to-on-premises-instancesexample associates in Amazon CodeDeploy the same on-premises instance tag to two on-premises instances. It does not register the on-premises instances with Amazon CodeDeploy.aws deploy add-tags-to-on-premises-instances \ --instance-namesAssetTag12010298EXAssetTag23121309EX\ --tagsKey=Name,Value=CodeDeployDemo-OnPremThis command produces no output.
- 
                    
For API details, see AddTagsToOnPremisesInstances
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use batch-get-application-revisions.
- Amazon CLI
 - 
             
                    
To retrieve information about application revisions
The following
batch-get-application-revisionsexample retrieves information about the specified revision stored in a GitHub repository.aws deploy batch-get-application-revisions \ --application-namemy-codedeploy-application\ --revisions "[{\"gitHubLocation\": {\"commitId\": \"fa85936EXAMPLEa31736c051f10d77297EXAMPLE\",\"repository\": \"my-github-token/my-repository\"},\"revisionType\": \"GitHub\"}]"Output:
{ "revisions": [ { "genericRevisionInfo": { "description": "Application revision registered by Deployment ID: d-A1B2C3111", "lastUsedTime": 1556912355.884, "registerTime": 1556912355.884, "firstUsedTime": 1556912355.884, "deploymentGroups": [] }, "revisionLocation": { "revisionType": "GitHub", "gitHubLocation": { "commitId": "fa85936EXAMPLEa31736c051f10d77297EXAMPLE", "repository": "my-github-token/my-repository" } } } ], "applicationName": "my-codedeploy-application", "errorMessage": "" }For more information, see BatchGetApplicationRevisions
in the Amazon CodeDeploy API Reference. - 
                    
For API details, see BatchGetApplicationRevisions
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use batch-get-applications.
- Amazon CLI
 - 
             
                    
To get information about multiple applications
The following
batch-get-applicationsexample displays information about multiple applications that are associated with the user's Amazon account.aws deploy batch-get-applications --application-namesWordPress_AppMyOther_AppOutput:
{ "applicationsInfo": [ { "applicationName": "WordPress_App", "applicationId": "d9dd6993-f171-44fa-a811-211e4EXAMPLE", "createTime": 1407878168.078, "linkedToGitHub": false }, { "applicationName": "MyOther_App", "applicationId": "8ca57519-31da-42b2-9194-8bb16EXAMPLE", "createTime": 1407453571.63, "linkedToGitHub": false } ] }- 
                    
For API details, see BatchGetApplications
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use batch-get-deployment-groups.
- Amazon CLI
 - 
             
                    
To retrieve information about one or more deployment groups
The following
batch-get-deployment-groupsexample retrieves information about two of the deployment groups that are associated with the specified CodeDeploy application.aws deploy batch-get-deployment-groups \ --application-namemy-codedeploy-application\ --deployment-group-names "[\"my-deployment-group-1\",\"my-deployment-group-2\"]"Output:
{ "deploymentGroupsInfo": [ { "deploymentStyle": { "deploymentOption": "WITHOUT_TRAFFIC_CONTROL", "deploymentType": "IN_PLACE" }, "autoRollbackConfiguration": { "enabled": false }, "onPremisesTagSet": { "onPremisesTagSetList": [] }, "serviceRoleArn": "arn:aws:iam::123456789012:role/CodeDeployServiceRole", "lastAttemptedDeployment": { "endTime": 1556912366.415, "status": "Failed", "createTime": 1556912355.884, "deploymentId": "d-A1B2C3111" }, "autoScalingGroups": [], "deploymentGroupName": "my-deployment-group-1", "ec2TagSet": { "ec2TagSetList": [ [ { "Type": "KEY_AND_VALUE", "Value": "my-EC2-instance", "Key": "Name" } ] ] }, "deploymentGroupId": "a1b2c3d4-5678-90ab-cdef-11111example", "triggerConfigurations": [], "applicationName": "my-codedeploy-application", "computePlatform": "Server", "deploymentConfigName": "CodeDeployDefault.AllAtOnce" }, { "deploymentStyle": { "deploymentOption": "WITHOUT_TRAFFIC_CONTROL", "deploymentType": "IN_PLACE" }, "autoRollbackConfiguration": { "enabled": false }, "onPremisesTagSet": { "onPremisesTagSetList": [] }, "serviceRoleArn": "arn:aws:iam::123456789012:role/CodeDeployServiceRole", "autoScalingGroups": [], "deploymentGroupName": "my-deployment-group-2", "ec2TagSet": { "ec2TagSetList": [ [ { "Type": "KEY_AND_VALUE", "Value": "my-EC2-instance", "Key": "Name" } ] ] }, "deploymentGroupId": "a1b2c3d4-5678-90ab-cdef-22222example", "triggerConfigurations": [], "applicationName": "my-codedeploy-application", "computePlatform": "Server", "deploymentConfigName": "CodeDeployDefault.AllAtOnce" } ], "errorMessage": "" }For more information, see BatchGetDeploymentGroups
in the Amazon CodeDeploy API Reference. - 
                    
For API details, see BatchGetDeploymentGroups
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use batch-get-deployment-targets.
- Amazon CLI
 - 
             
                    
To retrieve the targets associated with a deployment
The following
batch-get-deployment-targetsexample returns information about one of the targets associated with the specified deployment.aws deploy batch-get-deployment-targets \ --deployment-id"d-1A2B3C4D5"\ --target-ids"i-01a2b3c4d5e6f1111"Output:
{ "deploymentTargets": [ { "deploymentTargetType": "InstanceTarget", "instanceTarget": { "lifecycleEvents": [ { "startTime": 1556918592.162, "lifecycleEventName": "ApplicationStop", "status": "Succeeded", "endTime": 1556918592.247, "diagnostics": { "scriptName": "", "errorCode": "Success", "logTail": "", "message": "Succeeded" } }, { "startTime": 1556918593.193, "lifecycleEventName": "DownloadBundle", "status": "Succeeded", "endTime": 1556918593.981, "diagnostics": { "scriptName": "", "errorCode": "Success", "logTail": "", "message": "Succeeded" } }, { "startTime": 1556918594.805, "lifecycleEventName": "BeforeInstall", "status": "Succeeded", "endTime": 1556918681.807, "diagnostics": { "scriptName": "", "errorCode": "Success", "logTail": "", "message": "Succeeded" } } ], "targetArn": "arn:aws:ec2:us-west-2:123456789012:instance/i-01a2b3c4d5e6f1111", "deploymentId": "d-1A2B3C4D5", "lastUpdatedAt": 1556918687.504, "targetId": "i-01a2b3c4d5e6f1111", "status": "Succeeded" } } ] }For more information, see BatchGetDeploymentTargets
in the Amazon CodeDeploy API Reference. - 
                    
For API details, see BatchGetDeploymentTargets
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use batch-get-deployments.
- Amazon CLI
 - 
             
                    
To get information about multiple deployments
The following
batch-get-deploymentsexample displays information about multiple deployments that are associated with the user's Amazon account.aws deploy batch-get-deployments --deployment-idsd-A1B2C3111d-A1B2C3222Output:
{ "deploymentsInfo": [ { "applicationName": "WordPress_App", "status": "Failed", "deploymentOverview": { "Failed": 0, "InProgress": 0, "Skipped": 0, "Succeeded": 1, "Pending": 0 }, "deploymentConfigName": "CodeDeployDefault.OneAtATime", "creator": "user", "deploymentGroupName": "WordPress_DG", "revision": { "revisionType": "S3", "s3Location": { "bundleType": "zip", "version": "uTecLusEXAMPLEFXtfUcyfV8bEXAMPLE", "bucket": "amzn-s3-demo-bucket", "key": "WordPressApp.zip" } }, "deploymentId": "d-A1B2C3111", "createTime": 1408480721.9, "completeTime": 1408480741.822 }, { "applicationName": "MyOther_App", "status": "Failed", "deploymentOverview": { "Failed": 1, "InProgress": 0, "Skipped": 0, "Succeeded": 0, "Pending": 0 }, "deploymentConfigName": "CodeDeployDefault.OneAtATime", "creator": "user", "errorInformation": { "message": "Deployment failed: Constraint default violated: No hosts succeeded.", "code": "HEALTH_CONSTRAINTS" }, "deploymentGroupName": "MyOther_DG", "revision": { "revisionType": "S3", "s3Location": { "bundleType": "zip", "eTag": "\"dd56cfdEXAMPLE8e768f9d77fEXAMPLE\"", "bucket": "amzn-s3-demo-bucket", "key": "MyOtherApp.zip" } }, "deploymentId": "d-A1B2C3222", "createTime": 1409764576.589, "completeTime": 1409764596.101 } ] }- 
                    
For API details, see BatchGetDeployments
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use batch-get-on-premises-instances.
- Amazon CLI
 - 
             
                    
To get information about one or more on-premises instances
The following
batch-get-on-premises-instancesexample gets information about two on-premises instances.aws deploy batch-get-on-premises-instances --instance-namesAssetTag12010298EXAssetTag23121309EXOutput:
{ "instanceInfos": [ { "iamUserArn": "arn:aws:iam::123456789012:user/AWS/CodeDeploy/AssetTag12010298EX", "tags": [ { "Value": "CodeDeployDemo-OnPrem", "Key": "Name" } ], "instanceName": "AssetTag12010298EX", "registerTime": 1425579465.228, "instanceArn": "arn:aws:codedeploy:us-west-2:123456789012:instance/AssetTag12010298EX_4IwLNI2Alh" }, { "iamUserArn": "arn:aws:iam::123456789012:user/AWS/CodeDeploy/AssetTag23121309EX", "tags": [ { "Value": "CodeDeployDemo-OnPrem", "Key": "Name" } ], "instanceName": "AssetTag23121309EX", "registerTime": 1425595585.988, "instanceArn": "arn:aws:codedeploy:us-west-2:80398EXAMPLE:instance/AssetTag23121309EX_PomUy64Was" } ] }- 
                    
For API details, see BatchGetOnPremisesInstances
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use continue-deployment.
- Amazon CLI
 - 
             
                    
To start rerouting traffic without waiting for a specified wait time to elapse.
The following
continue-deploymentexample starts rerouting traffic from instances in the original environment that are ready to start shifting traffic to instances in the replacement environment.aws deploy continue-deployment \ --deployment-id"d-A1B2C3111"\ --deployment-wait-type"READY_WAIT"This command produces no output.
For more information, see ContinueDeployment
in the Amazon CodeDeploy API Reference. - 
                    
For API details, see ContinueDeployment
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use create-application.
- Amazon CLI
 - 
             
                    
To create an application
The following
create-applicationexample creates an application and associates it with the user's Amazon account.aws deploy create-application --application-nameMyOther_AppOutput:
{ "applicationId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE" }- 
                    
For API details, see CreateApplication
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use create-deployment-config.
- Amazon CLI
 - 
             
                    
To create a custom deployment configuration
The following
create-deployment-configexample creates a custom deployment configuration and associates it with the user's Amazon account.aws deploy create-deployment-config \ --deployment-config-nameThreeQuartersHealthy\ --minimum-healthy-hoststype=FLEET_PERCENT,value=75Output:
{ "deploymentConfigId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE" }- 
                    
For API details, see CreateDeploymentConfig
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use create-deployment-group.
- Amazon CLI
 - 
             
                    
To create a deployment group
The following
create-deployment-groupexample creates a deployment group and associates it with the specified application and the user's Amazon account.aws deploy create-deployment-group \ --application-nameWordPress_App\ --auto-scaling-groupsCodeDeployDemo-ASG\ --deployment-config-nameCodeDeployDefault.OneAtATime\ --deployment-group-nameWordPress_DG\ --ec2-tag-filtersKey=Name,Value=CodeDeployDemo,Type=KEY_AND_VALUE\ --service-role-arnarn:aws:iam::123456789012:role/CodeDeployDemoRoleOutput:
{ "deploymentGroupId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE" }- 
                    
For API details, see CreateDeploymentGroup
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use create-deployment.
- Amazon CLI
 - 
             
                    
Example 1: To create a CodeDeploy deployment using the EC2/On-premises compute platform
The following
create-deploymentexample creates a deployment and associates it with the user's Amazon account.aws deploy create-deployment \ --application-nameWordPress_App\ --deployment-config-nameCodeDeployDefault.OneAtATime\ --deployment-group-nameWordPress_DG\ --description"My demo deployment"\ --s3-locationbucket=amzn-s3-demo-bucket,bundleType=zip,eTag=dd56cfdEXAMPLE8e768f9d77fEXAMPLE,key=WordPressApp.zipOutput:
{ "deploymentId": "d-A1B2C3111" }Example 2: To create a CodeDeploy deployment using the Amazon ECS compute platform
The following
create-deploymentexample uses the following two files to deploy an Amazon ECS service.Contents of
create-deployment.jsonfile:{ "applicationName": "ecs-deployment", "deploymentGroupName": "ecs-deployment-dg", "revision": { "revisionType": "S3", "s3Location": { "bucket": "ecs-deployment-bucket", "key": "appspec.yaml", "bundleType": "YAML" } } }That file, in turn, retrieves the following file
appspec.yamlfrom an S3 bucket calledecs-deployment-bucket.version: 0.0 Resources: - TargetService: Type: AWS::ECS::Service Properties: TaskDefinition: "arn:aws:ecs:region:123456789012:task-definition/ecs-task-def:2" LoadBalancerInfo: ContainerName: "sample-app" ContainerPort: 80 PlatformVersion: "LATEST"Command:
aws deploy create-deployment \ --cli-input-jsonfile://create-deployment.json\ --regionus-east-1Output:
{ "deploymentId": "d-1234ABCDE" }For more information, see CreateDeployment
in the Amazon CodeDeploy API Reference. - 
                    
For API details, see CreateDeployment
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use delete-application.
- Amazon CLI
 - 
             
                    
To delete an application
The following
delete-applicationexample deletes the specified application that is associated with the user's Amazon account.aws deploy delete-application --application-nameWordPress_AppThis command produces no output.
- 
                    
For API details, see DeleteApplication
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use delete-deployment-config.
- Amazon CLI
 - 
             
                    
To delete a deployment configuration
The following
delete-deployment-configexample deletes a custom deployment configuration that is associated with the user's Amazon account.aws deploy delete-deployment-config --deployment-config-nameThreeQuartersHealthyThis command produces no output.
- 
                    
For API details, see DeleteDeploymentConfig
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use delete-deployment-group.
- Amazon CLI
 - 
             
                    
To delete a deployment group
The following
delete-deployment-groupexample deletes a deployment group that is associated with the specified application.aws deploy delete-deployment-group \ --application-nameWordPress_App\ --deployment-group-nameWordPress_DGOutput:
{ "hooksNotCleanedUp": [] }- 
                    
For API details, see DeleteDeploymentGroup
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use delete-git-hub-account-token.
- Amazon CLI
 - 
             
                    
To deletes a GitHub account connection
The following
delete-git-hub-account-tokenexample deletes the connection of the specified GitHub account.aws deploy delete-git-hub-account-token --token-namemy-github-accountOutput:
{ "tokenName": "my-github-account" }For more information, see DeleteGitHubAccountToken
in the Amazon CodeDeploy API Reference. - 
                    
For API details, see DeleteGitHubAccountToken
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use deregister-on-premises-instance.
- Amazon CLI
 - 
             
                    
To deregister an on-premises instance
The following
deregister-on-premises-instanceexample deregisters an on-premises instance with Amazon CodeDeploy, but it does not delete the IAM user associated with the instance, nor does it disassociate in Amazon CodeDeploy the on-premises instance tags from the instance. It also does not uninstall the Amazon CodeDeploy Agent from the instance nor remove the on-premises configuration file from the instance.aws deploy deregister-on-premises-instance --instance-nameAssetTag12010298EXThis command produces no output.
- 
                    
For API details, see DeregisterOnPremisesInstance
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use deregister.
- Amazon CLI
 - 
             
                    
To deregister an on-premises instance
The following
deregisterexample deregisters an on-premises instance with Amazon CodeDeploy. It does not delete the IAM user that is associated with the instance. It disassociates in Amazon CodeDeploy the on-premises tags from the instance. It does not uninstall the Amazon CodeDeploy Agent from the instance nor remove the on-premises configuration file from the instance.aws deploy deregister \ --instance-nameAssetTag12010298EX\ --no-delete-iam-user \ --regionus-west-2Output:
Retrieving on-premises instance information... DONE IamUserArn: arn:aws:iam::80398EXAMPLE:user/AWS/CodeDeploy/AssetTag12010298EX Tags: Key=Name,Value=CodeDeployDemo-OnPrem Removing tags from the on-premises instance... DONE Deregistering the on-premises instance... DONE Run the following command on the on-premises instance to uninstall the codedeploy-agent: aws deploy uninstall- 
                    
For API details, see Deregister
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use get-application-revision.
- Amazon CLI
 - 
             
                    
To get information about an application revision
The following
get-application-revisionexample displays information about an application revision that is associated with the specified application.aws deploy get-application-revision \ --application-nameWordPress_App\ --s3-locationbucket=amzn-s3-demo-bucket,bundleType=zip,eTag=dd56cfdEXAMPLE8e768f9d77fEXAMPLE,key=WordPressApp.zipOutput:
{ "applicationName": "WordPress_App", "revisionInfo": { "description": "Application revision registered by Deployment ID: d-A1B2C3111", "registerTime": 1411076520.009, "deploymentGroups": "WordPress_DG", "lastUsedTime": 1411076520.009, "firstUsedTime": 1411076520.009 }, "revision": { "revisionType": "S3", "s3Location": { "bundleType": "zip", "eTag": "dd56cfdEXAMPLE8e768f9d77fEXAMPLE", "bucket": "amzn-s3-demo-bucket", "key": "WordPressApp.zip" } } }- 
                    
For API details, see GetApplicationRevision
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use get-application.
- Amazon CLI
 - 
             
                    
To get information about an application
The following
get-applicationexample displays information about an application that is associated with the user's Amazon account.aws deploy get-application --application-nameWordPress_AppOutput:
{ "application": { "applicationName": "WordPress_App", "applicationId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "createTime": 1407878168.078, "linkedToGitHub": false } }- 
                    
For API details, see GetApplication
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use get-deployment-config.
- Amazon CLI
 - 
             
                    
To get information about a deployment configuration
The following
get-deployment-configexample displays information about a deployment configuration that is associated with the user's Amazon account.aws deploy get-deployment-config --deployment-config-nameThreeQuartersHealthyOutput:
{ "deploymentConfigInfo": { "deploymentConfigId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "minimumHealthyHosts": { "type": "FLEET_PERCENT", "value": 75 }, "createTime": 1411081164.379, "deploymentConfigName": "ThreeQuartersHealthy" } }- 
                    
For API details, see GetDeploymentConfig
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use get-deployment-group.
- Amazon CLI
 - 
             
                    
To view information about a deployment group
The following
get-deployment-groupexample displays information about a deployment group that is associated with the specified application.aws deploy get-deployment-group \ --application-nameWordPress_App\ --deployment-group-nameWordPress_DGOutput:
{ "deploymentGroupInfo": { "applicationName": "WordPress_App", "autoScalingGroups": [ "CodeDeployDemo-ASG" ], "deploymentConfigName": "CodeDeployDefault.OneAtATime", "ec2TagFilters": [ { "Type": "KEY_AND_VALUE", "Value": "CodeDeployDemo", "Key": "Name" } ], "deploymentGroupId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "serviceRoleArn": "arn:aws:iam::123456789012:role/CodeDeployDemoRole", "deploymentGroupName": "WordPress_DG" } }- 
                    
For API details, see GetDeploymentGroup
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use get-deployment-instance.
- Amazon CLI
 - 
             
                    
To get information about a deployment instance
The following
get-deployment-instanceexample displays information about a deployment instance that is associated with the specified deployment.aws deploy get-deployment-instance --deployment-idd-QA4G4F9EX--instance-idi-902e9fEXOutput:
{ "instanceSummary": { "instanceId": "arn:aws:ec2:us-east-1:80398EXAMPLE:instance/i-902e9fEX", "lifecycleEvents": [ { "status": "Succeeded", "endTime": 1408480726.569, "startTime": 1408480726.437, "lifecycleEventName": "ApplicationStop" }, { "status": "Succeeded", "endTime": 1408480728.016, "startTime": 1408480727.665, "lifecycleEventName": "DownloadBundle" }, { "status": "Succeeded", "endTime": 1408480729.744, "startTime": 1408480729.125, "lifecycleEventName": "BeforeInstall" }, { "status": "Succeeded", "endTime": 1408480730.979, "startTime": 1408480730.844, "lifecycleEventName": "Install" }, { "status": "Failed", "endTime": 1408480732.603, "startTime": 1408480732.1, "lifecycleEventName": "AfterInstall" }, { "status": "Skipped", "endTime": 1408480732.606, "lifecycleEventName": "ApplicationStart" }, { "status": "Skipped", "endTime": 1408480732.606, "lifecycleEventName": "ValidateService" } ], "deploymentId": "d-QA4G4F9EX", "lastUpdatedAt": 1408480733.152, "status": "Failed" } }- 
                    
For API details, see GetDeploymentInstance
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use get-deployment-target.
- Amazon CLI
 - 
             
                    
To return information about a deployment target
The following
get-deployment-targetexample returns information about a deployment target that is associated with the specified deployment.aws deploy get-deployment-target \ --deployment-id"d-A1B2C3111"\ --target-id"i-a1b2c3d4e5f611111"Output:
{ "deploymentTarget": { "deploymentTargetType": "InstanceTarget", "instanceTarget": { "lastUpdatedAt": 1556918687.504, "targetId": "i-a1b2c3d4e5f611111", "targetArn": "arn:aws:ec2:us-west-2:123456789012:instance/i-a1b2c3d4e5f611111", "status": "Succeeded", "lifecycleEvents": [ { "status": "Succeeded", "diagnostics": { "errorCode": "Success", "message": "Succeeded", "logTail": "", "scriptName": "" }, "lifecycleEventName": "ApplicationStop", "startTime": 1556918592.162, "endTime": 1556918592.247 }, { "status": "Succeeded", "diagnostics": { "errorCode": "Success", "message": "Succeeded", "logTail": "", "scriptName": "" }, "lifecycleEventName": "DownloadBundle", "startTime": 1556918593.193, "endTime": 1556918593.981 }, { "status": "Succeeded", "diagnostics": { "errorCode": "Success", "message": "Succeeded", "logTail": "", "scriptName": "" }, "lifecycleEventName": "BeforeInstall", "startTime": 1556918594.805, "endTime": 1556918681.807 }, { "status": "Succeeded", "diagnostics": { "errorCode": "Success", "message": "Succeeded", "logTail": "", "scriptName": "" }, "lifecycleEventName": "Install", "startTime": 1556918682.696, "endTime": 1556918683.005 }, { "status": "Succeeded", "diagnostics": { "errorCode": "Success", "message": "Succeeded", "logTail": "", "scriptName": "" }, "lifecycleEventName": "AfterInstall", "startTime": 1556918684.135, "endTime": 1556918684.216 }, { "status": "Succeeded", "diagnostics": { "errorCode": "Success", "message": "Succeeded", "logTail": "", "scriptName": "" }, "lifecycleEventName": "ApplicationStart", "startTime": 1556918685.211, "endTime": 1556918685.295 }, { "status": "Succeeded", "diagnostics": { "errorCode": "Success", "message": "Succeeded", "logTail": "", "scriptName": "" }, "lifecycleEventName": "ValidateService", "startTime": 1556918686.65, "endTime": 1556918686.747 } ], "deploymentId": "d-A1B2C3111" } } }For more information, see GetDeploymentTarget
in the Amazon CodeDeploy API Reference. - 
                    
For API details, see GetDeploymentTarget
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use get-deployment.
- Amazon CLI
 - 
             
                    
To get information about a deployment
The following
get-deploymentexample displays information about a deployment that is associated with the user's Amazon account.aws deploy get-deployment --deployment-idd-A1B2C3123Output:
{ "deploymentInfo": { "applicationName": "WordPress_App", "status": "Succeeded", "deploymentOverview": { "Failed": 0, "InProgress": 0, "Skipped": 0, "Succeeded": 1, "Pending": 0 }, "deploymentConfigName": "CodeDeployDefault.OneAtATime", "creator": "user", "description": "My WordPress app deployment", "revision": { "revisionType": "S3", "s3Location": { "bundleType": "zip", "eTag": "\"dd56cfdEXAMPLE8e768f9d77fEXAMPLE\"", "bucket": "amzn-s3-demo-bucket", "key": "WordPressApp.zip" } }, "deploymentId": "d-A1B2C3123", "deploymentGroupName": "WordPress_DG", "createTime": 1409764576.589, "completeTime": 1409764596.101, "ignoreApplicationStopFailures": false } }- 
                    
For API details, see GetDeployment
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use get-on-premises-instance.
- Amazon CLI
 - 
             
                    
To get information about an on-premises instance
The following
get-on-premises-instanceexample retrieves information about the specified on-premises instance.aws deploy get-on-premises-instance --instance-nameAssetTag12010298EXOutput:
{ "instanceInfo": { "iamUserArn": "arn:aws:iam::123456789012:user/AWS/CodeDeploy/AssetTag12010298EX", "tags": [ { "Value": "CodeDeployDemo-OnPrem", "Key": "Name" } ], "instanceName": "AssetTag12010298EX", "registerTime": 1425579465.228, "instanceArn": "arn:aws:codedeploy:us-east-1:123456789012:instance/AssetTag12010298EX_4IwLNI2Alh" } }- 
                    
For API details, see GetOnPremisesInstance
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use install.
- Amazon CLI
 - 
             
                    
To install an on-premises instance
The following
installexample copies the on-premises configuration file from the specified location on the instance to the location on the instance that the Amazon CodeDeploy Agent expects to find it. It also installs the Amazon CodeDeploy Agent on the instance. It does not create any IAM user, nor register the on-premises instance with Amazon CodeDeploy, nor associate any on-premises instance tags in Amazon CodeDeploy for the instance.aws deploy install \ --override-config \ --config-file C:\temp\codedeploy.onpremises.yml \ --regionus-west-2\ --agent-installers3://aws-codedeploy-us-west-2/latest/codedeploy-agent.msiOutput:
Creating the on-premises instance configuration file... DONE Installing the AWS CodeDeploy Agent... DONE- 
                    
For API details, see Install
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-application-revisions.
- Amazon CLI
 - 
             
                    
To get information about application revisions
The following
list-application-revisionsexample displays information about all application revisions that are associated with the specified application.aws deploy list-application-revisions \ --application-nameWordPress_App\ --s-3-bucketamzn-s3-demo-bucket\ --deployedexclude\ --s-3-key-prefixWordPress_\ --sort-bylastUsedTime\ --sort-orderdescendingOutput:
{ "revisions": [ { "revisionType": "S3", "s3Location": { "version": "uTecLusvCB_JqHFXtfUcyfV8bEXAMPLE", "bucket": "amzn-s3-demo-bucket", "key": "WordPress_App.zip", "bundleType": "zip" } }, { "revisionType": "S3", "s3Location": { "version": "tMk.UxgDpMEVb7V187ZM6wVAWEXAMPLE", "bucket": "amzn-s3-demo-bucket", "key": "WordPress_App_2-0.zip", "bundleType": "zip" } } ] }- 
                    
For API details, see ListApplicationRevisions
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-applications.
- Amazon CLI
 - 
             
                    
To get information about applications
The following
list-applicationsexample displays information about all applications that are associated with the user's Amazon account.aws deploy list-applicationsOutput:
{ "applications": [ "WordPress_App", "MyOther_App" ] }- 
                    
For API details, see ListApplications
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-deployment-configs.
- Amazon CLI
 - 
             
                    
To get information about deployment configurations
The following
list-deployment-configsexample displays information about all deployment configurations that are associated with the user's Amazon account.aws deploy list-deployment-configsOutput:
{ "deploymentConfigsList": [ "ThreeQuartersHealthy", "CodeDeployDefault.AllAtOnce", "CodeDeployDefault.HalfAtATime", "CodeDeployDefault.OneAtATime" ] }- 
                    
For API details, see ListDeploymentConfigs
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-deployment-groups.
- Amazon CLI
 - 
             
                    
To get information about deployment groups
The following
list-deployment-groupsexample displays information about all deployment groups that are associated with the specified application.aws deploy list-deployment-groups --application-nameWordPress_AppOutput:
{ "applicationName": "WordPress_App", "deploymentGroups": [ "WordPress_DG", "WordPress_Beta_DG" ] }- 
                    
For API details, see ListDeploymentGroups
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-deployment-instances.
- Amazon CLI
 - 
             
                    
To get information about deployment instances
The following
list-deployment-instancesexample displays information about all deployment instances that are associated with the specified deployment.aws deploy list-deployment-instances \ --deployment-idd-A1B2C3111\ --instance-status-filterSucceededOutput:
{ "instancesList": [ "i-EXAMPLE11", "i-EXAMPLE22" ] }- 
                    
For API details, see ListDeploymentInstances
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-deployment-targets.
- Amazon CLI
 - 
             
                    
To retrieve a list of target IDs that are associated with a deployment
The following
list-deployment-targetsexample retrieves a list of target IDs associated with deployments that have a status of "Failed" or "InProgress."aws deploy list-deployment-targets \ --deployment-id"d-A1B2C3111"\ --target-filters "{\"TargetStatus\":[\"Failed\",\"InProgress\"]}"Output:
{ "targetIds": [ "i-0f1558aaf90e5f1f9" ] }For more information, see ListDeploymentTargets
in the Amazon CodeDeploy API Reference. - 
                    
For API details, see ListDeploymentTargets
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-deployments.
- Amazon CLI
 - 
             
                    
To get information about deployments
The following
list-deploymentsexample displays information about all deployments that are associated with the specified application and deployment group.aws deploy list-deployments \ --application-nameWordPress_App\ --create-time-rangestart=2014-08-19T00:00:00,end=2014-08-20T00:00:00\ --deployment-group-nameWordPress_DG\ --include-only-statusesFailedOutput:
{ "deployments": [ "d-EXAMPLE11", "d-EXAMPLE22", "d-EXAMPLE33" ] }- 
                    
For API details, see ListDeployments
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-git-hub-account-token-names.
- Amazon CLI
 - 
             
                    
To lists the names of stored connections to GitHub accounts
The following
list-git-hub-account-token-namesexample lists the names of the stored connections to GitHub accounts for the current Amazon user.aws deploy list-git-hub-account-token-namesOutput:
{ "tokenNameList": [ "my-first-token", "my-second-token", "my-third-token" ] }For more information, see ListGitHubAccountTokenNames
in the Amazon CodeDeploy API Reference. - 
                    
For API details, see ListGitHubAccountTokenNames
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-on-premises-instances.
- Amazon CLI
 - 
             
                    
To get information about one or more on-premises instances
The following
list-on-premises-instancesexample retrieves a list of available on-premises instance names for instances that are registered in Amazon CodeDeploy and also have the specified on-premises instance tag associated in Amazon CodeDeploy with the instance.aws deploy list-on-premises-instances \ --registration-statusRegistered\ --tag-filtersKey=Name,Value=CodeDeployDemo-OnPrem,Type=KEY_AND_VALUEOutput:
{ "instanceNames": [ "AssetTag12010298EX" ] }- 
                    
For API details, see ListOnPremisesInstances
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use list-tags-for-resource.
- Amazon CLI
 - 
             
                    
To list tags for a resource (application)
The following
list-tags-for-resourceexample lists the tags applied to an application named testApp in CodeDeploy.aws deploy list-tags-for-resource \ --resource-arnarn:aws:codedeploy:us-west-2:111122223333:application:testAppOutput:
{ "Tags": [ { "Key": "Type", "Value": "testType" }, { "Key": "Name", "Value": "testName" } ] }For more information, see Tagging instances for deployment groups in CodeDeploy
in the Amazon CodeDeploy User Guide. - 
                    
For API details, see ListTagsForResource
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use push.
- Amazon CLI
 - 
             
                    
To bundle and deploy an Amazon CodeDeploy compatible application revision to Amazon S3
The following
pushexample bundles and deploys an application revision to Amazon S3 and then associates the application revision with the specified application.aws deploy push \ --application-nameWordPress_App\ --description"This is my deployment"\ --ignore-hidden-files \ --s3-locations3://amzn-s3-demo-bucket/WordPressApp.zip\ --source/tmp/MyLocalDeploymentFolder/The output describes how to use the
create-deploymentcommand to create a deployment that uses the uploaded application revision.To deploy with this revision, run: aws deploy create-deployment --application-name WordPress_App --deployment-config-name <deployment-config-name> --deployment-group-name <deployment-group-name> --s3-location bucket=amzn-s3-demo-bucket,key=WordPressApp.zip,bundleType=zip,eTag="cecc9b8EXAMPLE50a6e71fdb88EXAMPLE",version=LFsJAUdEXAMPLEfvKtvi79L8EXAMPLE- 
                    
For API details, see Push
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use register-application-revision.
- Amazon CLI
 - 
             
                    
To register information about an already-uploaded application revision
The following
register-application-revisionexample registers information about an already-uploaded application revision stored in Amazon S3 with Amazon CodeDeploy.aws deploy register-application-revision \ --application-nameWordPress_App\ --description"Revised WordPress application"\ --s3-locationbucket=amzn-s3-demo-bucket,key=RevisedWordPressApp.zip,bundleType=zip,eTag=cecc9b8a08eac650a6e71fdb88EXAMPLEThis command produces no output.
- 
                    
For API details, see RegisterApplicationRevision
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use register-on-premises-instance.
- Amazon CLI
 - 
             
                    
To register an on-premises instance
The following
register-on-premises-instanceexample registers an on-premises instance with Amazon CodeDeploy. It does not create the specified IAM user, nor does it associate in Amazon CodeDeploy any on-premises instances tags with the registered instance.aws deploy register-on-premises-instance \ --instance-nameAssetTag12010298EX\ --iam-user-arnarn:aws:iam::80398EXAMPLE:user/CodeDeployDemoUser-OnPremThis command produces no output.
- 
                    
For API details, see RegisterOnPremisesInstance
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use register.
- Amazon CLI
 - 
             
                    
To register an on-premises instance
The following
registerexample registers an on-premises instance with Amazon CodeDeploy, associates in Amazon CodeDeploy the specified on-premises instance tag with the registered instance, and creates an on-premises configuration file that can be copied to the instance. It does not create the IAM user, nor does it install the Amazon CodeDeploy Agent on the instance.aws deploy register \ --instance-nameAssetTag12010298EX\ --iam-user-arnarn:aws:iam::80398EXAMPLE:user/CodeDeployUser-OnPrem\ --tagsKey=Name,Value=CodeDeployDemo-OnPrem\ --regionus-west-2Output:
Registering the on-premises instance... DONE Adding tags to the on-premises instance... DONE Copy the on-premises configuration file named codedeploy.onpremises.yml to the on-premises instance, and run the following command on the on-premises instance to install and configure the AWS CodeDeploy Agent: aws deploy install --config-file codedeploy.onpremises.yml- 
                    
For API details, see Register
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use remove-tags-from-on-premises-instances.
- Amazon CLI
 - 
             
                    
To remove tags from one or more on-premises instances
The following
remove-tags-from-on-premises-instancesexample disassociates the specified on-premises tags in Amazon CodeDeploy from on-premises instances. It does not deregister the on-premises instances in Amazon CodeDeploy, nor uninstall the Amazon CodeDeploy Agent from the instance, nor remove the on-premises configuration file from the instances, nor delete the IAM users that are associated with the instances.aws deploy remove-tags-from-on-premises-instances \ --instance-namesAssetTag12010298EXAssetTag23121309EX\ --tagsKey=Name,Value=CodeDeployDemo-OnPremThis command produces no output.
- 
                    
For API details, see RemoveTagsFromOnPremisesInstances
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use stop-deployment.
- Amazon CLI
 - 
             
                    
To attempt to stop a deployment
The following
stop-deploymentexample attempts to stop an in-progress deployment that is associated with the user's Amazon account.aws deploy stop-deployment --deployment-id d-A1B2C3111
Output:
{ "status": "Succeeded", "statusMessage": "No more commands will be scheduled for execution in the deployment instances" }- 
                    
For API details, see StopDeployment
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use tag-resource.
- Amazon CLI
 - 
             
                    
To tag a resoure (application)
The following
tag-resourceexample adds two tags with keys Name and Type, and values testName and testType to an application named testApp in CodeDeploy.:aws deploy tag-resource \ --resource-arnarn:aws:codedeploy:us-west-2:111122223333:application:testApp\ --tagsKey=Name,Value=testNameKey=Type,Value=testTypeIf successful, this command produces no output.
For more information, see Tagging instances for deployment groups in CodeDeploy
in the Amazon CodeDeploy User Guide. - 
                    
For API details, see TagResource
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use uninstall.
- Amazon CLI
 - 
             
                    
To uninstall an on-premises instance
The following
uninstallexample uninstalls the Amazon CodeDeploy Agent from the on-premises instance and removes the on-premises configuration file from the instance. It doesn't deregister the instance in Amazon CodeDeploy, nor disassociate any on-premises instance tags in Amazon CodeDeploy from the instance, nor delete the IAM user that is associated with the instance.aws deploy uninstallThis command produces no output.
- 
                    
For API details, see Uninstall
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use untag-resource.
- Amazon CLI
 - 
             
                    
To remove tags from a resource (application)
The following
untag-resourceexample removes two tags with keys Name and Type from an application named testApp in CodeDeploy.aws deploy untag-resource \ --resource-arnarn:aws:codedeploy:us-west-2:111122223333:application:testApp\ --tag-keysNameTypeIf successful, this command produces no output.
For more information, see Tagging instances for deployment groups in CodeDeploy
in the Amazon CodeDeploy User Guide. - 
                    
For API details, see UntagResource
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use update-application.
- Amazon CLI
 - 
             
                    
To change details of an application
The following
update-applicationexample changes the name of an application that is associated with the user's Amazon account.aws deploy update-application \ --application-nameWordPress_App\ --new-application-nameMy_WordPress_AppThis command produces no output.
- 
                    
For API details, see UpdateApplication
in Amazon CLI Command Reference.  
 - 
                    
 
The following code example shows how to use update-deployment-group.
- Amazon CLI
 - 
             
                    
To change information about a deployment group
The following
update-deployment-groupexample changes the settings of a deployment group that is associated with the specified application.aws deploy update-deployment-group \ --application-nameWordPress_App\ --auto-scaling-groupsMy_CodeDeployDemo_ASG\ --current-deployment-group-nameWordPress_DG\ --deployment-config-nameCodeDeployDefault.AllAtOnce\ --ec2-tag-filtersKey=Name,Type=KEY_AND_VALUE,Value=My_CodeDeployDemo\ --new-deployment-group-nameMy_WordPress_DepGroup\ --service-role-arnarn:aws:iam::80398EXAMPLE:role/CodeDeployDemo-2This command produces no output.
- 
                    
For API details, see UpdateDeploymentGroup
in Amazon CLI Command Reference.  
 -