mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
deploy: Update InvalidateCloudFront to use Go CDK helper
This commit is contained in:
parent
bcf7421ea5
commit
d979831dbd
1 changed files with 2 additions and 9 deletions
|
@ -21,21 +21,14 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
|
||||||
"github.com/aws/aws-sdk-go/service/cloudfront"
|
"github.com/aws/aws-sdk-go/service/cloudfront"
|
||||||
|
gcaws "gocloud.dev/aws"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InvalidateCloudFront invalidates the CloudFront cache for distributionID.
|
// InvalidateCloudFront invalidates the CloudFront cache for distributionID.
|
||||||
// It uses the default AWS credentials from the environment.
|
// It uses the default AWS credentials from the environment.
|
||||||
func InvalidateCloudFront(ctx context.Context, distributionID string) error {
|
func InvalidateCloudFront(ctx context.Context, distributionID string) error {
|
||||||
// SharedConfigEnable enables loading "shared config (~/.aws/config) and
|
sess, err := gcaws.NewDefaultSession()
|
||||||
// shared credentials (~/.aws/credentials) files".
|
|
||||||
// See https://docs.aws.amazon.com/sdk-for-go/api/aws/session/ for more
|
|
||||||
// details.
|
|
||||||
// This is the same codepath used by Go CDK when creating an s3 URL.
|
|
||||||
// TODO: Update this to a Go CDK helper once available
|
|
||||||
// (https://github.com/google/go-cloud/issues/2003).
|
|
||||||
sess, err := session.NewSessionWithOptions(session.Options{SharedConfigState: session.SharedConfigEnable})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue