BatchGetDeploymentTargets - AWS CodeDeploy

BatchGetDeploymentTargets

Returns an array of one or more targets associated with a deployment. This method works with all compute types and should be used instead of the deprecated BatchGetDeploymentInstances. The maximum number of targets that can be returned is 25.

The type of targets returned depends on the deployment's compute platform or deployment method:

  • EC2/On-premises: Information about Amazon EC2 instance targets.

  • AWS Lambda : Information about Lambda functions targets.

  • Amazon ECS: Information about Amazon ECS service targets.

  • CloudFormation: Information about targets of blue/green deployments initiated by a CloudFormation stack update.

Request Syntax

{ "deploymentId": "string", "targetIds": [ "string" ] }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

deploymentId

The unique ID of a deployment.

Type: String

Required: Yes

targetIds

The unique IDs of the deployment targets. The compute platform of the deployment determines the type of the targets and their formats. The maximum number of deployment target IDs you can specify is 25.

  • For deployments that use the EC2/On-premises compute platform, the target IDs are Amazon EC2 or on-premises instances IDs, and their target type is instanceTarget.

  • For deployments that use the AWS Lambda compute platform, the target IDs are the names of Lambda functions, and their target type is instanceTarget.

  • For deployments that use the Amazon ECS compute platform, the target IDs are pairs of Amazon ECS clusters and services specified using the format <clustername>:<servicename>. Their target type is ecsTarget.

  • For deployments that are deployed with AWS CloudFormation, the target IDs are CloudFormation stack IDs. Their target type is cloudFormationTarget.

Type: Array of strings

Required: Yes

Response Syntax

{ "deploymentTargets": [ { "cloudFormationTarget": { "deploymentId": "string", "lastUpdatedAt": number, "lifecycleEvents": [ { "diagnostics": { "errorCode": "string", "logTail": "string", "message": "string", "scriptName": "string" }, "endTime": number, "lifecycleEventName": "string", "startTime": number, "status": "string" } ], "resourceType": "string", "status": "string", "targetId": "string", "targetVersionWeight": number }, "deploymentTargetType": "string", "ecsTarget": { "deploymentId": "string", "lastUpdatedAt": number, "lifecycleEvents": [ { "diagnostics": { "errorCode": "string", "logTail": "string", "message": "string", "scriptName": "string" }, "endTime": number, "lifecycleEventName": "string", "startTime": number, "status": "string" } ], "status": "string", "targetArn": "string", "targetId": "string", "taskSetsInfo": [ { "desiredCount": number, "identifer": "string", "pendingCount": number, "runningCount": number, "status": "string", "targetGroup": { "name": "string" }, "taskSetLabel": "string", "trafficWeight": number } ] }, "instanceTarget": { "deploymentId": "string", "instanceLabel": "string", "lastUpdatedAt": number, "lifecycleEvents": [ { "diagnostics": { "errorCode": "string", "logTail": "string", "message": "string", "scriptName": "string" }, "endTime": number, "lifecycleEventName": "string", "startTime": number, "status": "string" } ], "status": "string", "targetArn": "string", "targetId": "string" }, "lambdaTarget": { "deploymentId": "string", "lambdaFunctionInfo": { "currentVersion": "string", "functionAlias": "string", "functionName": "string", "targetVersion": "string", "targetVersionWeight": number }, "lastUpdatedAt": number, "lifecycleEvents": [ { "diagnostics": { "errorCode": "string", "logTail": "string", "message": "string", "scriptName": "string" }, "endTime": number, "lifecycleEventName": "string", "startTime": number, "status": "string" } ], "status": "string", "targetArn": "string", "targetId": "string" } } ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

deploymentTargets

A list of target objects for a deployment. Each target object contains details about the target, such as its status and lifecycle events. The type of the target objects depends on the deployment' compute platform.

  • EC2/On-premises: Each target object is an Amazon EC2 or on-premises instance.

  • AWS Lambda : The target object is a specific version of an AWS Lambda function.

  • Amazon ECS: The target object is an Amazon ECS service.

  • CloudFormation: The target object is an AWS CloudFormation blue/green deployment.

Type: Array of DeploymentTarget objects

Errors

For information about the errors that are common to all actions, see Common Errors.

DeploymentDoesNotExistException

The deployment with the user or AWS account does not exist.

HTTP Status Code: 400

DeploymentIdRequiredException

At least one deployment ID must be specified.

HTTP Status Code: 400

DeploymentNotStartedException

The specified deployment has not started.

HTTP Status Code: 400

DeploymentTargetDoesNotExistException

The provided target ID does not belong to the attempted deployment.

HTTP Status Code: 400

DeploymentTargetIdRequiredException

A deployment target ID was not provided.

HTTP Status Code: 400

DeploymentTargetListSizeExceededException

The maximum number of targets that can be associated with an Amazon ECS or AWS Lambda deployment was exceeded. The target list of both types of deployments must have exactly one item. This exception does not apply to EC2/On-premises deployments.

HTTP Status Code: 400

InstanceDoesNotExistException

This error has been deprecated.

The specified instance does not exist in the deployment group.

HTTP Status Code: 400

InvalidDeploymentIdException

At least one of the deployment IDs was specified in an invalid format.

HTTP Status Code: 400

InvalidDeploymentTargetIdException

The target ID provided was not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: