batchGetDeploymentTargets method

Future<BatchGetDeploymentTargetsOutput> batchGetDeploymentTargets({
  1. required String deploymentId,
  2. required List<String> targetIds,
})

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.
  • 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.

May throw DeploymentDoesNotExistException. May throw DeploymentIdRequiredException. May throw DeploymentNotStartedException. May throw DeploymentTargetDoesNotExistException. May throw DeploymentTargetIdRequiredException. May throw DeploymentTargetListSizeExceededException. May throw InstanceDoesNotExistException. May throw InvalidDeploymentIdException. May throw InvalidDeploymentTargetIdException.

Parameter deploymentId : The unique ID of a deployment.

Parameter 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 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 . Their target type is ecsTarget.
  • For deployments that are deployed with CloudFormation, the target IDs are CloudFormation stack IDs. Their target type is cloudFormationTarget.

Implementation

Future<BatchGetDeploymentTargetsOutput> batchGetDeploymentTargets({
  required String deploymentId,
  required List<String> targetIds,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeDeploy_20141006.BatchGetDeploymentTargets'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'deploymentId': deploymentId,
      'targetIds': targetIds,
    },
  );

  return BatchGetDeploymentTargetsOutput.fromJson(jsonResponse.body);
}