updateDistributionWithStagingConfig method

Future<UpdateDistributionWithStagingConfigResult> updateDistributionWithStagingConfig({
  1. required String id,
  2. String? ifMatch,
  3. String? stagingDistributionId,
})

Copies the staging distribution's configuration to its corresponding primary distribution. The primary distribution retains its Aliases (also known as alternate domain names or CNAMEs) and ContinuousDeploymentPolicyId value, but otherwise its configuration is overwritten to match the staging distribution.

You can use this operation in a continuous deployment workflow after you have tested configuration changes on the staging distribution. After using a continuous deployment policy to move a portion of your domain name's traffic to the staging distribution and verifying that it works as intended, you can use this operation to copy the staging distribution's configuration to the primary distribution. This action will disable the continuous deployment policy and move your domain's traffic back to the primary distribution.

This API operation requires the following IAM permissions:

May throw AccessDenied. May throw CNAMEAlreadyExists. May throw EntityLimitExceeded. May throw EntityNotFound. May throw IllegalFieldLevelEncryptionConfigAssociationWithCacheBehavior. May throw IllegalUpdate. May throw InconsistentQuantities. May throw InvalidArgument. May throw InvalidDefaultRootObject. May throw InvalidErrorCode. May throw InvalidForwardCookies. May throw InvalidFunctionAssociation. May throw InvalidGeoRestrictionParameter. May throw InvalidHeadersForS3Origin. May throw InvalidIfMatchVersion. May throw InvalidLambdaFunctionAssociation. May throw InvalidLocationCode. May throw InvalidMinimumProtocolVersion. May throw InvalidOriginAccessControl. May throw InvalidOriginAccessIdentity. May throw InvalidOriginKeepaliveTimeout. May throw InvalidOriginReadTimeout. May throw InvalidQueryStringParameters. May throw InvalidRelativePath. May throw InvalidRequiredProtocol. May throw InvalidResponseCode. May throw InvalidTTLOrder. May throw InvalidViewerCertificate. May throw InvalidWebACLId. May throw MissingBody. May throw NoSuchCachePolicy. May throw NoSuchDistribution. May throw NoSuchFieldLevelEncryptionConfig. May throw NoSuchOrigin. May throw NoSuchOriginRequestPolicy. May throw NoSuchRealtimeLogConfig. May throw NoSuchResponseHeadersPolicy. May throw PreconditionFailed. May throw RealtimeLogConfigOwnerMismatch. May throw TooManyCacheBehaviors. May throw TooManyCertificates. May throw TooManyCookieNamesInWhiteList. May throw TooManyDistributionCNAMEs. May throw TooManyDistributionsAssociatedToCachePolicy. May throw TooManyDistributionsAssociatedToFieldLevelEncryptionConfig. May throw TooManyDistributionsAssociatedToKeyGroup. May throw TooManyDistributionsAssociatedToOriginAccessControl. May throw TooManyDistributionsAssociatedToOriginRequestPolicy. May throw TooManyDistributionsAssociatedToResponseHeadersPolicy. May throw TooManyDistributionsWithFunctionAssociations. May throw TooManyDistributionsWithLambdaAssociations. May throw TooManyDistributionsWithSingleFunctionARN. May throw TooManyFunctionAssociations. May throw TooManyHeadersInForwardedValues. May throw TooManyKeyGroupsAssociatedToDistribution. May throw TooManyLambdaFunctionAssociations. May throw TooManyOriginCustomHeaders. May throw TooManyOriginGroupsPerDistribution. May throw TooManyOrigins. May throw TooManyQueryStringParameters. May throw TooManyTrustedSigners. May throw TrustedKeyGroupDoesNotExist. May throw TrustedSignerDoesNotExist.

Parameter id : The identifier of the primary distribution to which you are copying a staging distribution's configuration.

Parameter ifMatch : The current versions (ETag values) of both primary and staging distributions. Provide these in the following format:

<primary ETag>, <staging ETag>

Parameter stagingDistributionId : The identifier of the staging distribution whose configuration you are copying to the primary distribution.

Implementation

Future<UpdateDistributionWithStagingConfigResult>
    updateDistributionWithStagingConfig({
  required String id,
  String? ifMatch,
  String? stagingDistributionId,
}) async {
  final headers = <String, String>{
    if (ifMatch != null) 'If-Match': ifMatch.toString(),
  };
  final $query = <String, List<String>>{
    if (stagingDistributionId != null)
      'StagingDistributionId': [stagingDistributionId],
  };
  final $result = await _protocol.sendRaw(
    method: 'PUT',
    requestUri:
        '/2020-05-31/distribution/${Uri.encodeComponent(id)}/promote-staging-config',
    queryParams: $query,
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return UpdateDistributionWithStagingConfigResult(
    distribution: Distribution.fromXml($elem),
    eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
  );
}