From d8c2734178f2a726e8e3c8ffc612433df272ddb3 Mon Sep 17 00:00:00 2001 From: Bjørn Erik Pedersen Date: Wed, 31 Jan 2024 21:41:04 +0100 Subject: deploy: Fix CloudFront invalidation with AWS SDK2 --- deploy/cloudfront.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'deploy') 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 } -- cgit v1.2.3