summaryrefslogtreecommitdiffstats
path: root/deploy/cloudfront.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-01-31 21:41:04 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-01-31 22:12:48 +0100
commitd8c2734178f2a726e8e3c8ffc612433df272ddb3 (patch)
tree2942026582d6c388512d3eef380e30cc3dc9e4cc /deploy/cloudfront.go
parentd8e1e821881c665f2874b2cef46f0df3c565560a (diff)
deploy: Fix CloudFront invalidation with AWS SDK2
Diffstat (limited to 'deploy/cloudfront.go')
-rw-r--r--deploy/cloudfront.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/deploy/cloudfront.go b/deploy/cloudfront.go
index a91126c5d..91453dfb9 100644
--- a/deploy/cloudfront.go
+++ b/deploy/cloudfront.go
@@ -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
}