Created
November 5, 2018 22:57
-
-
Save brydavis/a9a9676aad49cf1e56d9d0f160a7b743 to your computer and use it in GitHub Desktop.
Create an AWS SDK session from string credentials (say, you retrieve your creds from a database)
This file contains hidden or 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 ( | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/credentials" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/s3" | |
) | |
func main() { | |
AWS_ACCESS_KEY_ID := "" | |
AWS_SECRET_ACCESS_KEY := "" | |
AWS_SECRET_ACCESS_TOKEN := "" | |
creds := credentials.NewStaticCredentials( | |
AWS_ACCESS_KEY_ID, | |
AWS_SECRET_ACCESS_KEY, | |
AWS_SECRET_ACCESS_TOKEN, | |
) | |
// Create Session | |
sess := session.Must(session.NewSession(&aws.Config{ | |
Region: aws.String(""), | |
Credentials: creds, | |
})) | |
// Create a S3 client instance from a session | |
sess := session.Must(session.NewSession()) | |
svc := s3.New(sess) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment