github.com/openshift/installer@v1.4.17/pkg/asset/installconfig/aws/presign.go (about) 1 package aws 2 3 import ( 4 "time" 5 6 "github.com/aws/aws-sdk-go/aws" 7 "github.com/aws/aws-sdk-go/aws/session" 8 "github.com/aws/aws-sdk-go/service/s3" 9 ) 10 11 // PresignedS3URL returns a presigned S3 URL for a bucket/object pair 12 func PresignedS3URL(session *session.Session, region string, bucket string, object string) (string, error) { 13 client := s3.New(session, aws.NewConfig().WithRegion(region)) 14 req, _ := client.GetObjectRequest(&s3.GetObjectInput{ 15 Bucket: aws.String(bucket), 16 Key: aws.String(object), 17 }) 18 presignedURL, err := req.Presign(60 * time.Minute) 19 if err != nil { 20 return "", err 21 } 22 23 return presignedURL, nil 24 }