createDeploymentConfig method

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

Creates a deployment configuration.

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

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

Implementation

Future<CreateDeploymentConfigOutput> createDeploymentConfig({
  required String deploymentConfigName,
  ComputePlatform? computePlatform,
  MinimumHealthyHosts? minimumHealthyHosts,
  TrafficRoutingConfig? trafficRoutingConfig,
}) async {
  ArgumentError.checkNotNull(deploymentConfigName, 'deploymentConfigName');
  _s.validateStringLength(
    'deploymentConfigName',
    deploymentConfigName,
    1,
    100,
    isRequired: true,
  );
  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.toValue(),
      if (minimumHealthyHosts != null)
        'minimumHealthyHosts': minimumHealthyHosts,
      if (trafficRoutingConfig != null)
        'trafficRoutingConfig': trafficRoutingConfig,
    },
  );

  return CreateDeploymentConfigOutput.fromJson(jsonResponse.body);
}