mirror of
https://github.com/nyanotech/object-holder.git
synced 2026-02-08 05:47:26 -08:00
accept aws credentials from environment variables
This commit is contained in:
16
main.go
16
main.go
@@ -30,9 +30,10 @@ var threadCount = flag.Int("threads", 1024, "how many objects to operate on at a
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
cfg, err := config.LoadDefaultConfig(context.TODO(),
|
options := []func(*config.LoadOptions) error{}
|
||||||
// just a placeholder because it needs to be defined
|
|
||||||
// should be using the one from the endpoint regardless
|
options = append(options,
|
||||||
|
// TODO: figure out what to do with this
|
||||||
config.WithRegion("us-east-1"),
|
config.WithRegion("us-east-1"),
|
||||||
config.WithEndpointResolverWithOptions(aws.EndpointResolverWithOptionsFunc(
|
config.WithEndpointResolverWithOptions(aws.EndpointResolverWithOptionsFunc(
|
||||||
func(service, region string, options ...interface{}) (aws.Endpoint, error) {
|
func(service, region string, options ...interface{}) (aws.Endpoint, error) {
|
||||||
@@ -41,7 +42,14 @@ func main() {
|
|||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(*accessKeyId, *secretAccessKey, "")),
|
)
|
||||||
|
|
||||||
|
if *accessKeyId != "" && *secretAccessKey != "" {
|
||||||
|
options = append(options, config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(*accessKeyId, *secretAccessKey, "")))
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg, err := config.LoadDefaultConfig(context.TODO(),
|
||||||
|
options...,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Failed to create AWS config", err)
|
log.Fatalln("Failed to create AWS config", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user