createDeployment method

Future<CreateDeploymentResult> createDeployment({
  1. required DeploymentCommand command,
  2. required String stackId,
  3. String? appId,
  4. String? comment,
  5. String? customJson,
  6. List<String>? instanceIds,
  7. List<String>? layerIds,
})

Runs deployment or stack commands. For more information, see Deploying Apps and Run Stack Commands.

Required Permissions: To use this action, an IAM user must have a Deploy or Manage permissions level for the stack, or an attached policy that explicitly grants permissions. For more information on user permissions, see Managing User Permissions.

May throw ValidationException. May throw ResourceNotFoundException.

Parameter command : A DeploymentCommand object that specifies the deployment command and any associated arguments.

Parameter stackId : The stack ID.

Parameter appId : The app ID. This parameter is required for app deployments, but not for other deployment commands.

Parameter comment : A user-defined comment.

Parameter customJson : A string that contains user-defined, custom JSON. You can use this parameter to override some corresponding default stack configuration JSON values. The string should be in the following format:

"{"key1": "value1", "key2": "value2",...}"

For more information about custom JSON, see Use Custom JSON to Modify the Stack Configuration Attributes and Overriding Attributes With Custom JSON.

Parameter instanceIds : The instance IDs for the deployment targets.

Parameter layerIds : The layer IDs for the deployment targets.

Implementation

Future<CreateDeploymentResult> createDeployment({
  required DeploymentCommand command,
  required String stackId,
  String? appId,
  String? comment,
  String? customJson,
  List<String>? instanceIds,
  List<String>? layerIds,
}) async {
  ArgumentError.checkNotNull(command, 'command');
  ArgumentError.checkNotNull(stackId, 'stackId');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'OpsWorks_20130218.CreateDeployment'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Command': command,
      'StackId': stackId,
      if (appId != null) 'AppId': appId,
      if (comment != null) 'Comment': comment,
      if (customJson != null) 'CustomJson': customJson,
      if (instanceIds != null) 'InstanceIds': instanceIds,
      if (layerIds != null) 'LayerIds': layerIds,
    },
  );

  return CreateDeploymentResult.fromJson(jsonResponse.body);
}