createDeploymentConfig method

Future<CreateDeploymentConfigOutput> createDeploymentConfig({
  1. required String deploymentConfigName,
  2. ComputePlatform? computePlatform,
  3. MinimumHealthyHosts? minimumHealthyHosts,
  4. TrafficRoutingConfig? trafficRoutingConfig,
  5. ZonalConfig? zonalConfig,
})

Creates a deployment configuration.

May throw DeploymentConfigAlreadyExistsException. May throw DeploymentConfigLimitExceededException. May throw DeploymentConfigNameRequiredException. May throw InvalidComputePlatformException. May throw InvalidDeploymentConfigNameException. May throw InvalidMinimumHealthyHostValueException. May throw InvalidTrafficRoutingConfigurationException. May throw InvalidZonalDeploymentConfigurationException.

Parameter deploymentConfigName : The name of the deployment configuration to create.

Parameter computePlatform : The destination platform type for the deployment (Lambda, Server, or ECS).

Parameter minimumHealthyHosts : The minimum number of healthy instances that should be available at any time during the deployment. There are two parameters expected in the input: type and value.

The type parameter takes either of the following values:

  • HOST_COUNT: The value parameter represents the minimum number of healthy instances as an absolute value.
  • FLEET_PERCENT: The value parameter represents the minimum number of healthy instances as a percentage of the total number of instances in the deployment. If you specify FLEET_PERCENT, at the start of the deployment, CodeDeploy converts the percentage to the equivalent number of instances and rounds up fractional instances.
The value parameter takes an integer.

For example, to set a minimum of 95% healthy instance, specify a type of FLEET_PERCENT and a value of 95.

Parameter trafficRoutingConfig : The configuration that specifies how the deployment traffic is routed.

Parameter zonalConfig : Configure the ZonalConfig object if you want CodeDeploy to deploy your application to one Availability Zone at a time, within an Amazon Web Services Region.

For more information about the zonal configuration feature, see zonal configuration in the CodeDeploy User Guide.

Implementation

Future<CreateDeploymentConfigOutput> createDeploymentConfig({
  required String deploymentConfigName,
  ComputePlatform? computePlatform,
  MinimumHealthyHosts? minimumHealthyHosts,
  TrafficRoutingConfig? trafficRoutingConfig,
  ZonalConfig? zonalConfig,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeDeploy_20141006.CreateDeploymentConfig'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'deploymentConfigName': deploymentConfigName,
      if (computePlatform != null) 'computePlatform': computePlatform.value,
      if (minimumHealthyHosts != null)
        'minimumHealthyHosts': minimumHealthyHosts,
      if (trafficRoutingConfig != null)
        'trafficRoutingConfig': trafficRoutingConfig,
      if (zonalConfig != null) 'zonalConfig': zonalConfig,
    },
  );

  return CreateDeploymentConfigOutput.fromJson(jsonResponse.body);
}