Last active
December 15, 2017 09:09
-
-
Save 2matzzz/5f31bd53d8e5ad306e3664628c9fa4f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/url" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/credentials/stscreds" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/s3" | |
) | |
func main() { | |
sess := session.Must(session.NewSession()) | |
creds := stscreds.NewCredentials(sess, "arn:aws:iam::ACCOUNT_ID:role/YOUR_ROLE_NAME") | |
svc := s3.New(sess, &aws.Config{Credentials: creds}) | |
source := url.QueryEscape("SRC_BUCKET_NAME/SRC_OBJECT_KEY") | |
params := &s3.CopyObjectInput{} | |
params.SetBucket("DEST_BUCKET_NAME") | |
params.SetKey("DEST_OBJECT_KEY") | |
params.SetCopySource(source) | |
req, resp := svc.CopyObjectRequest(params) | |
err := req.Send() | |
if err == nil { | |
fmt.Println(resp) | |
} else { | |
fmt.Println(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment