updateDistribution2017_03_25 method

Future<UpdateDistributionResult> updateDistribution2017_03_25({
  1. required DistributionConfig distributionConfig,
  2. required String id,
  3. String? ifMatch,
})

Updates the configuration for a web distribution. Perform the following steps.

For information about updating a distribution using the CloudFront console, see Creating or Updating a Web Distribution Using the CloudFront Console in the Amazon CloudFront Developer Guide.

To update a web distribution using the CloudFront API

  1. Submit a GetDistributionConfig request to get the current configuration and an Etag header for the distribution.
  2. Update the XML document that was returned in the response to your GetDistributionConfig request to include the desired changes. You can't change the value of CallerReference. If you try to change this value, CloudFront returns an IllegalUpdate error.
  3. Submit an UpdateDistribution request to update the configuration for your distribution:
    • In the request body, include the XML document that you updated in Step 2. The request body must include an XML document with a DistributionConfig element.
    • Set the value of the HTTP If-Match header to the value of the ETag header that CloudFront returned when you submitted the GetDistributionConfig request in Step 1.
  4. Review the response to the UpdateDistribution request to confirm that the configuration was successfully updated.
  5. Optional: Submit a GetDistribution request to confirm that your changes have propagated. When propagation is complete, the value of Status is Deployed.

May throw AccessDenied. May throw CNAMEAlreadyExists. May throw IllegalUpdate. May throw InvalidIfMatchVersion. May throw MissingBody. May throw NoSuchDistribution. May throw PreconditionFailed. May throw TooManyDistributionCNAMEs. May throw InvalidDefaultRootObject. May throw InvalidRelativePath. May throw InvalidErrorCode. May throw InvalidResponseCode. May throw InvalidArgument. May throw InvalidOriginAccessIdentity. May throw TooManyTrustedSigners. May throw TrustedSignerDoesNotExist. May throw InvalidViewerCertificate. May throw InvalidMinimumProtocolVersion. May throw InvalidRequiredProtocol. May throw NoSuchOrigin. May throw TooManyOrigins. May throw TooManyCacheBehaviors. May throw TooManyCookieNamesInWhiteList. May throw InvalidForwardCookies. May throw TooManyHeadersInForwardedValues. May throw InvalidHeadersForS3Origin. May throw InconsistentQuantities. May throw TooManyCertificates. May throw InvalidLocationCode. May throw InvalidGeoRestrictionParameter. May throw InvalidTTLOrder. May throw InvalidWebACLId. May throw TooManyOriginCustomHeaders. May throw TooManyQueryStringParameters. May throw InvalidQueryStringParameters. May throw TooManyDistributionsWithLambdaAssociations. May throw TooManyLambdaFunctionAssociations. May throw InvalidLambdaFunctionAssociation. May throw InvalidOriginReadTimeout. May throw InvalidOriginKeepaliveTimeout.

Parameter distributionConfig : The distribution's configuration information.

Parameter id : The distribution's id.

Parameter ifMatch : The value of the ETag header that you received when retrieving the distribution's configuration. For example: E2QWRUHAPOMQZL.

Implementation

Future<UpdateDistributionResult> updateDistribution2017_03_25({
  required DistributionConfig distributionConfig,
  required String id,
  String? ifMatch,
}) async {
  ArgumentError.checkNotNull(distributionConfig, 'distributionConfig');
  ArgumentError.checkNotNull(id, 'id');
  final headers = <String, String>{
    if (ifMatch != null) 'If-Match': ifMatch.toString(),
  };
  final $result = await _protocol.sendRaw(
    method: 'PUT',
    requestUri: '/2017-03-25/distribution/${Uri.encodeComponent(id)}/config',
    headers: headers,
    payload: distributionConfig.toXml('DistributionConfig'),
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return UpdateDistributionResult(
    distribution: Distribution.fromXml($elem),
    eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
  );
}