updateExpressGatewayService method

Future<UpdateExpressGatewayServiceResponse> updateExpressGatewayService({
  1. required String serviceArn,
  2. String? cpu,
  3. String? executionRoleArn,
  4. String? healthCheckPath,
  5. String? memory,
  6. ExpressGatewayServiceNetworkConfiguration? networkConfiguration,
  7. ExpressGatewayContainer? primaryContainer,
  8. ExpressGatewayScalingTarget? scalingTarget,
  9. String? taskRoleArn,
})

Updates an existing Express service configuration. Modifies container settings, resource allocation, auto-scaling configuration, and other service parameters without recreating the service.

Amazon ECS creates a new service revision with updated configuration and performs a rolling deployment to replace existing tasks. The service remains available during updates, ensuring zero-downtime deployments.

Some parameters like the infrastructure role cannot be modified after service creation and require creating a new service.

May throw AccessDeniedException. May throw ClientException. May throw ClusterNotFoundException. May throw InvalidParameterException. May throw ServerException. May throw ServiceNotActiveException. May throw ServiceNotFoundException. May throw UnsupportedFeatureException.

Parameter serviceArn : The Amazon Resource Name (ARN) of the Express service to update.

Parameter cpu : The number of CPU units used by the task.

Parameter executionRoleArn : The Amazon Resource Name (ARN) of the task execution role for the Express service.

Parameter healthCheckPath : The path on the container for Application Load Balancer health checks.

Parameter memory : The amount of memory (in MiB) used by the task.

Parameter networkConfiguration : The network configuration for the Express service tasks. By default, the network configuration for an Express service uses the default VPC.

Parameter primaryContainer : The primary container configuration for the Express service.

Parameter scalingTarget : The auto-scaling configuration for the Express service.

Parameter taskRoleArn : The Amazon Resource Name (ARN) of the IAM role for containers in this task.

Implementation

Future<UpdateExpressGatewayServiceResponse> updateExpressGatewayService({
  required String serviceArn,
  String? cpu,
  String? executionRoleArn,
  String? healthCheckPath,
  String? memory,
  ExpressGatewayServiceNetworkConfiguration? networkConfiguration,
  ExpressGatewayContainer? primaryContainer,
  ExpressGatewayScalingTarget? scalingTarget,
  String? taskRoleArn,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target':
        'AmazonEC2ContainerServiceV20141113.UpdateExpressGatewayService'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'serviceArn': serviceArn,
      if (cpu != null) 'cpu': cpu,
      if (executionRoleArn != null) 'executionRoleArn': executionRoleArn,
      if (healthCheckPath != null) 'healthCheckPath': healthCheckPath,
      if (memory != null) 'memory': memory,
      if (networkConfiguration != null)
        'networkConfiguration': networkConfiguration,
      if (primaryContainer != null) 'primaryContainer': primaryContainer,
      if (scalingTarget != null) 'scalingTarget': scalingTarget,
      if (taskRoleArn != null) 'taskRoleArn': taskRoleArn,
    },
  );

  return UpdateExpressGatewayServiceResponse.fromJson(jsonResponse.body);
}