createDeployment method

Future<CreateDeploymentResponse> createDeployment({
  1. required String targetArn,
  2. Map<String, ComponentDeploymentSpecification>? components,
  3. String? deploymentName,
  4. DeploymentPolicies? deploymentPolicies,
  5. DeploymentIoTJobConfiguration? iotJobConfiguration,
  6. Map<String, String>? tags,
})

Creates a continuous deployment for a target, which is a AWS IoT Greengrass core device or group of core devices. When you add a new core device to a group of core devices that has a deployment, AWS IoT Greengrass deploys that group's deployment to the new device.

You can define one deployment for each target. When you create a new deployment for a target that has an existing deployment, you replace the previous deployment. AWS IoT Greengrass applies the new deployment to the target devices.

Every deployment has a revision number that indicates how many deployment revisions you define for a target. Use this operation to create a new revision of an existing deployment. This operation returns the revision number of the new deployment when you create it.

For more information, see the Create deployments in the AWS IoT Greengrass V2 Developer Guide.

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

Parameter targetArn : The ARN of the target AWS IoT thing or thing group.

Parameter components : The components to deploy. This is a dictionary, where each key is the name of a component, and each key's value is the version and configuration to deploy for that component.

Parameter deploymentName : The name of the deployment.

You can create deployments without names. If you create a deployment without a name, the AWS IoT Greengrass V2 console shows the deployment name as <targetType>:<targetName>, where targetType and targetName are the type and name of the deployment target.

Parameter deploymentPolicies : The deployment policies for the deployment. These policies define how the deployment updates components and handles failure.

Parameter iotJobConfiguration : The job configuration for the deployment configuration. The job configuration specifies the rollout, timeout, and stop configurations for the deployment configuration.

Parameter tags : A list of key-value pairs that contain metadata for the resource. For more information, see Tag your resources in the AWS IoT Greengrass V2 Developer Guide.

Implementation

Future<CreateDeploymentResponse> createDeployment({
  required String targetArn,
  Map<String, ComponentDeploymentSpecification>? components,
  String? deploymentName,
  DeploymentPolicies? deploymentPolicies,
  DeploymentIoTJobConfiguration? iotJobConfiguration,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(targetArn, 'targetArn');
  _s.validateStringLength(
    'deploymentName',
    deploymentName,
    1,
    1152921504606846976,
  );
  final $payload = <String, dynamic>{
    'targetArn': targetArn,
    if (components != null) 'components': components,
    if (deploymentName != null) 'deploymentName': deploymentName,
    if (deploymentPolicies != null) 'deploymentPolicies': deploymentPolicies,
    if (iotJobConfiguration != null)
      'iotJobConfiguration': iotJobConfiguration,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/greengrass/v2/deployments',
    exceptionFnMap: _exceptionFns,
  );
  return CreateDeploymentResponse.fromJson(response);
}