aws-sdk-go-v2 icon indicating copy to clipboard operation
aws-sdk-go-v2 copied to clipboard

fix LoadDefaultConfig optFns

Open kentokento opened this issue 1 year ago • 0 comments

I want to use config.LoadOptionsFunc as below

	// var opts []func(*config.LoadOptions) error
	var opts []config.LoadOptionsFunc // now this will result in an error
	if c.AccessKey != "" && c.SecretKey != "" {
		opts = append(opts, config.WithCredentialsProvider(
			&credentials.StaticCredentialsProvider{
				Value: aws.Credentials{
					AccessKeyID:     c.AccessKey,
					SecretAccessKey: c.SecretKey,
				},
			},
		))
	}

	if c.Profile != "" {
		opts = append(opts, config.WithSharedConfigProfile(c.Profile))
	}
	if c.Filename != "" {
		opts = append(opts, config.WithSharedConfigFiles([]string{c.Filename}))
	}
	return config.LoadDefaultConfig(context.TODO(), opts...)

kentokento avatar Jul 03 '24 00:07 kentokento