mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 05:30:54 +03:00
Upgrade to deploy to use AWS SDK V2
This commit is contained in:
parent
6c3b6ba3e6
commit
a1c64989df
3 changed files with 26 additions and 17 deletions
|
@ -21,8 +21,9 @@ import (
|
|||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/cloudfront"
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/cloudfront"
|
||||
"github.com/aws/aws-sdk-go-v2/service/cloudfront/types"
|
||||
gcaws "gocloud.dev/aws"
|
||||
)
|
||||
|
||||
|
@ -33,20 +34,21 @@ func InvalidateCloudFront(ctx context.Context, target *Target) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sess, _, err := gcaws.NewSessionFromURLParams(u.Query())
|
||||
cfg, err := gcaws.V2ConfigFromURLParams(ctx, u.Query())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cf := cloudfront.NewFromConfig(cfg)
|
||||
req := &cloudfront.CreateInvalidationInput{
|
||||
DistributionId: aws.String(target.CloudFrontDistributionID),
|
||||
InvalidationBatch: &cloudfront.InvalidationBatch{
|
||||
InvalidationBatch: &types.InvalidationBatch{
|
||||
CallerReference: aws.String(time.Now().Format("20060102150405")),
|
||||
Paths: &cloudfront.Paths{
|
||||
Items: []*string{aws.String("/*")},
|
||||
Quantity: aws.Int64(1),
|
||||
Paths: &types.Paths{
|
||||
Items: []string{"/*"},
|
||||
Quantity: aws.Int32(1),
|
||||
},
|
||||
},
|
||||
}
|
||||
_, err = cloudfront.New(sess).CreateInvalidationWithContext(ctx, req)
|
||||
_, err = cf.CreateInvalidation(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue