【发布时间】:2016-03-06 06:39:55
【问题描述】:
我编写了一些使用 Java API 创建和删除 CloudFront 分配的 Scala 代码。
有问题的代码是removeDistribution method。输出是:
Disabling distribution of scalacoursesdemo.s3.amazonaws.com with id E3656VVNINIXI3 and ETag E3W3IUM6RJKTDY
distributionConfig={
"enabled" : false,
"restrictions" : {
"geoRestriction" : {
"restrictionType" : "none",
"items" : [ ],
"quantity" : 0
}
},
"priceClass" : "PriceClass_All",
"defaultRootObject" : "index.html",
"logging" : {
"enabled" : false,
"bucket" : "",
"prefix" : "",
"includeCookies" : false
},
"customErrorResponses" : {
"items" : [ ],
"quantity" : 0
},
"aliases" : {
"items" : [ ],
"quantity" : 0
},
"cacheBehaviors" : {
"items" : [ ],
"quantity" : 0
},
"origins" : {
"items" : [ {
"id" : "S3-scalacoursesdemo",
"customOriginConfig" : null,
"s3OriginConfig" : {
"originAccessIdentity" : ""
},
"domainName" : "scalacoursesdemo.s3.amazonaws.com"
} ],
"quantity" : 1
},
"comment" : "",
"callerReference" : "284851146697",
"defaultCacheBehavior" : {
"targetOriginId" : "S3-scalacoursesdemo",
"minTTL" : 3600,
"viewerProtocolPolicy" : "allow-all",
"trustedSigners" : {
"enabled" : false,
"items" : [ ],
"quantity" : 0
},
"allowedMethods" : {
"items" : [ "GET", "HEAD" ],
"quantity" : 2
},
"smoothStreaming" : false,
"forwardedValues" : {
"queryString" : false,
"cookies" : {
"forward" : "all",
"whitelistedNames" : null
}
}
},
"viewerCertificate" : {
"SSLSupportMethod" : null,
"cloudFrontDefaultCertificate" : true,
"IAMCertificateId" : null
}
}
Update result ETag = E14HGEUEBH4TKO
Deleting distribution of scalacoursesdemo.s3.amazonaws.com with id E3656VVNINIXI3 and ETag E14HGEUEBH4TKO.
deleteDistributionRequest={
"id" : "E3656VVNINIXI3",
"requestClientOptions" : {
"clientMarker" : null
},
"ifMatch" : "E14HGEUEBH4TKO",
"requestMetricCollector" : null,
"requestCredentials" : null
}
Distribution of scalacoursesdemo.s3.amazonaws.com with id 'E3656VVNINIXI3' and ETag 'E3W3IUM6RJKTDY':
The distribution you are trying to delete has not been disabled.
(Service: AmazonCloudFront; Status Code: 409; Error Code: DistributionNotDisabled; Request ID: ab6e9920-d3aa-11e3-a498-7f333cd2eda0)
问题是 AWS Web 客户端确实将分发显示为已禁用。如果我然后尝试使用 CloudBerry,它也无法删除分发。大约一个小时后,问题消失了,CloudBerry 能够删除分发。
如果我在另一个由 CloudBerry 创建的发行版上重新运行我的程序,它会禁用该发行版,然后生成以下错误:
The precondition given in one or more of the request-header fields evaluated to false.
该错误消息最没有帮助。我可以看到它列出了here。我认为这意味着ifMatch ETag 不正确。不知道还能从哪里获得该值。
顺便说一句,我想我在CloudFront docs 中发现了一个错误。我认为更正确的说法是应该从最近的GET 或PUT 操作的eTag 中设置If-Match 值,而不是The value of the ETag header you received when you disabled the distribution。
我尝试在创建分发后等待 3 秒,并在禁用它之间等待 3 秒再删除它,但这没有帮助。
显然我的程序有问题,但我没有看到。有什么建议吗?
【问题讨论】:
标签: amazon-web-services amazon-cloudfront