createTargetGroup method

Future<CreateTargetGroupResponse> createTargetGroup({
  1. required String name,
  2. required TargetGroupType type,
  3. String? clientToken,
  4. TargetGroupConfig? config,
  5. Map<String, String>? tags,
})

Creates a target group. A target group is a collection of targets, or compute resources, that run your application or service. A target group can only be used by a single service.

For more information, see Target groups in the Amazon VPC Lattice User Guide.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter name : The name of the target group. The name must be unique within the account. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.

Parameter type : The type of target group.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token and parameters, the retry succeeds without performing any actions. If the parameters aren't identical, the retry fails.

Parameter config : The target group configuration.

Parameter tags : The tags for the target group.

Implementation

Future<CreateTargetGroupResponse> createTargetGroup({
  required String name,
  required TargetGroupType type,
  String? clientToken,
  TargetGroupConfig? config,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'name': name,
    'type': type.value,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (config != null) 'config': config,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/targetgroups',
    exceptionFnMap: _exceptionFns,
  );
  return CreateTargetGroupResponse.fromJson(response);
}