createDeployment method
Creates a continuous deployment for a target, which is a 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, 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. 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.
For more information, see the Create deployments in the IoT Greengrass V2 Developer Guide.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw RequestAlreadyInProgressException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw ValidationException.
Parameter targetArn :
The ARN
of the target IoT thing or thing group. When creating a subdeployment, the
targetARN can only be a thing group.
Parameter clientToken :
A unique, case-sensitive identifier that you can provide to ensure that
the request is idempotent. Idempotency means that the request is
successfully processed only once, even if you send the request multiple
times. When a request succeeds, and you specify the same client token for
subsequent successful requests, the IoT Greengrass V2 service returns the
successful response that it caches from the previous request. IoT
Greengrass V2 caches successful responses for idempotent requests for up
to 8 hours.
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.
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 parentTargetArn :
The parent deployment's target ARN
within a subdeployment.
Parameter tags :
A list of key-value pairs that contain metadata for the resource. For more
information, see Tag
your resources in the IoT Greengrass V2 Developer Guide.
Implementation
Future<CreateDeploymentResponse> createDeployment({
required String targetArn,
String? clientToken,
Map<String, ComponentDeploymentSpecification>? components,
String? deploymentName,
DeploymentPolicies? deploymentPolicies,
DeploymentIoTJobConfiguration? iotJobConfiguration,
String? parentTargetArn,
Map<String, String>? tags,
}) async {
final $payload = <String, dynamic>{
'targetArn': targetArn,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (components != null) 'components': components,
if (deploymentName != null) 'deploymentName': deploymentName,
if (deploymentPolicies != null) 'deploymentPolicies': deploymentPolicies,
if (iotJobConfiguration != null)
'iotJobConfiguration': iotJobConfiguration,
if (parentTargetArn != null) 'parentTargetArn': parentTargetArn,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/greengrass/v2/deployments',
exceptionFnMap: _exceptionFns,
);
return CreateDeploymentResponse.fromJson(response);
}