mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 05:30:54 +03:00
deploy: Fix CloudFront invalidation with AWS SDK2
This commit is contained in:
parent
d8e1e82188
commit
d8c2734178
3 changed files with 27 additions and 1 deletions
|
@ -27,6 +27,15 @@ import (
|
|||
gcaws "gocloud.dev/aws"
|
||||
)
|
||||
|
||||
// V2ConfigFromURLParams will fail for any unknown params, so we need to remove them.
|
||||
// This is a mysterious API, but inspecting the code the known params are:
|
||||
var v2ConfigValidParams = map[string]bool{
|
||||
"endpoint": true,
|
||||
"region": true,
|
||||
"profile": true,
|
||||
"awssdk": true,
|
||||
}
|
||||
|
||||
// InvalidateCloudFront invalidates the CloudFront cache for distributionID.
|
||||
// Uses AWS credentials config from the bucket URL.
|
||||
func InvalidateCloudFront(ctx context.Context, target *Target) error {
|
||||
|
@ -34,7 +43,16 @@ func InvalidateCloudFront(ctx context.Context, target *Target) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cfg, err := gcaws.V2ConfigFromURLParams(ctx, u.Query())
|
||||
vals := u.Query()
|
||||
|
||||
// Remove any unknown params.
|
||||
for k := range vals {
|
||||
if !v2ConfigValidParams[k] {
|
||||
vals.Del(k)
|
||||
}
|
||||
}
|
||||
|
||||
cfg, err := gcaws.V2ConfigFromURLParams(ctx, vals)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue