updateDistribution2020_05_31 method
- required DistributionConfig distributionConfig,
- required String id,
- String? ifMatch,
Updates the configuration for a web distribution.
The update process includes getting the current distribution
configuration, updating the XML document that is returned to make your
changes, and then submitting an UpdateDistribution request to
make the updates.
For information about updating a distribution using the CloudFront console instead, see Creating a Distribution in the Amazon CloudFront Developer Guide.
To update a web distribution using the CloudFront API
-
Submit a GetDistributionConfig
request to get the current configuration and an
Etagheader for the distribution. -
Update the XML document that was returned in the response to your
GetDistributionConfigrequest to include your changes. -
Submit an
UpdateDistributionrequest 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
DistributionConfigelement. -
Set the value of the HTTP
If-Matchheader to the value of theETagheader that CloudFront returned when you submitted theGetDistributionConfigrequest in Step 1.
-
In the request body, include the XML document that you updated in Step 2.
The request body must include an XML document with a
-
Review the response to the
UpdateDistributionrequest to confirm that the configuration was successfully updated. -
Optional: Submit a GetDistribution
request to confirm that your changes have propagated. When propagation is
complete, the value of
StatusisDeployed.
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 TooManyOriginGroupsPerDistribution. 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 TooManyDistributionsWithSingleFunctionARN. May throw TooManyLambdaFunctionAssociations. May throw InvalidLambdaFunctionAssociation. May throw InvalidOriginReadTimeout. May throw InvalidOriginKeepaliveTimeout. May throw NoSuchFieldLevelEncryptionConfig. May throw IllegalFieldLevelEncryptionConfigAssociationWithCacheBehavior. May throw TooManyDistributionsAssociatedToFieldLevelEncryptionConfig. May throw NoSuchCachePolicy. May throw TooManyDistributionsAssociatedToCachePolicy. May throw NoSuchOriginRequestPolicy. May throw TooManyDistributionsAssociatedToOriginRequestPolicy. May throw TooManyDistributionsAssociatedToKeyGroup. May throw TooManyKeyGroupsAssociatedToDistribution. May throw TrustedKeyGroupDoesNotExist.
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> updateDistribution2020_05_31({
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: '/2020-05-31/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'),
);
}