batchGetDeploymentTargets method

Future<BatchGetDeploymentTargetsOutput> batchGetDeploymentTargets({
  1. String? deploymentId,
  2. 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 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.

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

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

Implementation

Future<BatchGetDeploymentTargetsOutput> batchGetDeploymentTargets({
  String? deploymentId,
  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: {
      if (deploymentId != null) 'deploymentId': deploymentId,
      if (targetIds != null) 'targetIds': targetIds,
    },
  );

  return BatchGetDeploymentTargetsOutput.fromJson(jsonResponse.body);
}