Updates the configuration for a web distribution.
cloudfront_update_distribution(DistributionConfig, Id, IfMatch)
[required] The distribution\'s configuration information.
[required] The distribution\'s id.
The value of the ETag
header that you received when retrieving the
distribution\'s configuration. For example: E2QWRUHAPOMQZL
.
svc$update_distribution( DistributionConfig = list( CallerReference = "string", Aliases = list( Quantity = 123, Items = list( "string" ) ), DefaultRootObject = "string", Origins = list( Quantity = 123, Items = list( list( Id = "string", DomainName = "string", OriginPath = "string", CustomHeaders = list( Quantity = 123, Items = list( list( HeaderName = "string", HeaderValue = "string" ) ) ), S3OriginConfig = list( OriginAccessIdentity = "string" ), CustomOriginConfig = list( HTTPPort = 123, HTTPSPort = 123, OriginProtocolPolicy = "http-only"|"match-viewer"|"https-only", OriginSslProtocols = list( Quantity = 123, Items = list( "SSLv3"|"TLSv1"|"TLSv1.1"|"TLSv1.2" ) ), OriginReadTimeout = 123, OriginKeepaliveTimeout = 123 ), ConnectionAttempts = 123, ConnectionTimeout = 123 ) ) ), OriginGroups = list( Quantity = 123, Items = list( list( Id = "string", FailoverCriteria = list( StatusCodes = list( Quantity = 123, Items = list( 123 ) ) ), Members = list( Quantity = 123, Items = list( list( OriginId = "string" ) ) ) ) ) ), DefaultCacheBehavior = list( TargetOriginId = "string", ForwardedValues = list( QueryString = TRUE|FALSE, Cookies = list( Forward = "none"|"whitelist"|"all", WhitelistedNames = list( Quantity = 123, Items = list( "string" ) ) ), Headers = list( Quantity = 123, Items = list( "string" ) ), QueryStringCacheKeys = list( Quantity = 123, Items = list( "string" ) ) ), TrustedSigners = list( Enabled = TRUE|FALSE, Quantity = 123, Items = list( "string" ) ), ViewerProtocolPolicy = "allow-all"|"https-only"|"redirect-to-https", MinTTL = 123, AllowedMethods = list( Quantity = 123, Items = list( "GET"|"HEAD"|"POST"|"PUT"|"PATCH"|"OPTIONS"|"DELETE" ), CachedMethods = list( Quantity = 123, Items = list( "GET"|"HEAD"|"POST"|"PUT"|"PATCH"|"OPTIONS"|"DELETE" ) ) ), SmoothStreaming = TRUE|FALSE, DefaultTTL = 123, MaxTTL = 123, Compress = TRUE|FALSE, LambdaFunctionAssociations = list( Quantity = 123, Items = list( list( LambdaFunctionARN = "string", EventType = "viewer-request"|"viewer-response"|"origin-request"|"origin-response", IncludeBody = TRUE|FALSE ) ) ), FieldLevelEncryptionId = "string" ), CacheBehaviors = list( Quantity = 123, Items = list( list( PathPattern = "string", TargetOriginId = "string", ForwardedValues = list( QueryString = TRUE|FALSE, Cookies = list( Forward = "none"|"whitelist"|"all", WhitelistedNames = list( Quantity = 123, Items = list( "string" ) ) ), Headers = list( Quantity = 123, Items = list( "string" ) ), QueryStringCacheKeys = list( Quantity = 123, Items = list( "string" ) ) ), TrustedSigners = list( Enabled = TRUE|FALSE, Quantity = 123, Items = list( "string" ) ), ViewerProtocolPolicy = "allow-all"|"https-only"|"redirect-to-https", MinTTL = 123, AllowedMethods = list( Quantity = 123, Items = list( "GET"|"HEAD"|"POST"|"PUT"|"PATCH"|"OPTIONS"|"DELETE" ), CachedMethods = list( Quantity = 123, Items = list( "GET"|"HEAD"|"POST"|"PUT"|"PATCH"|"OPTIONS"|"DELETE" ) ) ), SmoothStreaming = TRUE|FALSE, DefaultTTL = 123, MaxTTL = 123, Compress = TRUE|FALSE, LambdaFunctionAssociations = list( Quantity = 123, Items = list( list( LambdaFunctionARN = "string", EventType = "viewer-request"|"viewer-response"|"origin-request"|"origin-response", IncludeBody = TRUE|FALSE ) ) ), FieldLevelEncryptionId = "string" ) ) ), CustomErrorResponses = list( Quantity = 123, Items = list( list( ErrorCode = 123, ResponsePagePath = "string", ResponseCode = "string", ErrorCachingMinTTL = 123 ) ) ), Comment = "string", Logging = list( Enabled = TRUE|FALSE, IncludeCookies = TRUE|FALSE, Bucket = "string", Prefix = "string" ), PriceClass = "PriceClass_100"|"PriceClass_200"|"PriceClass_All", Enabled = TRUE|FALSE, ViewerCertificate = list( CloudFrontDefaultCertificate = TRUE|FALSE, IAMCertificateId = "string", ACMCertificateArn = "string", SSLSupportMethod = "sni-only"|"vip", MinimumProtocolVersion = "SSLv3"|"TLSv1"|"TLSv1_2016"|"TLSv1.1_2016"|"TLSv1.2_2018"|"TLSv1.2_2019", Certificate = "string", CertificateSource = "cloudfront"|"iam"|"acm" ), Restrictions = list( GeoRestriction = list( RestrictionType = "blacklist"|"whitelist"|"none", Quantity = 123, Items = list( "string" ) ) ), WebACLId = "string", HttpVersion = "http1.1"|"http2", IsIPV6Enabled = TRUE|FALSE ), Id = "string", IfMatch = "string" )
When you update a distribution, there are more required fields than when you create a distribution. When you update your distribution by using this API action, follow the steps here to get the current configuration and then make your updates, to make sure that you include all of the required fields. To view a summary, see Required Fields for Create Distribution and Update Distribution in the Amazon CloudFront Developer Guide.
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 Etag
header for
the distribution.
If you update the distribution again, you must get a new Etag
header.
Update the XML document that was returned in the response to your
GetDistributionConfig
request to include your changes.
When you edit the XML file, be aware of the following:
You must strip out the ETag parameter that is returned.
Additional fields are required when you update a distribution. There may be fields included in the XML file for features that you haven\'t configured for your distribution. This is expected and required to successfully update the distribution.
You can\'t change the value of CallerReference
. If you try to
change this value, CloudFront returns an IllegalUpdate
error.
The new configuration replaces the existing configuration; the
values that you specify in an UpdateDistribution
request are
not merged into your existing configuration. When you add,
delete, or replace values in an element that allows multiple
values (for example, CNAME
), you must specify all of the
values that you want to appear in the updated distribution. In
addition, you must update the corresponding Quantity
element.
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.
Review the response to the UpdateDistribution
request 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 Status
is Deployed
.