Skip to content

Instantly share code, notes, and snippets.

@shawn-hurley
Created October 13, 2021 18:37
Show Gist options
  • Save shawn-hurley/81a441f6386e979a8d8ccaf09c6365ab to your computer and use it in GitHub Desktop.
Save shawn-hurley/81a441f6386e979a8d8ccaf09c6365ab to your computer and use it in GitHub Desktop.
func (b *VolumeSnapshotter) Init(config map[string]string) error {
- if err := veleroplugin.ValidateVolumeSnapshotterConfigKeys(config, regionKey, credentialProfileKey); err != nil {
+ if err := veleroplugin.ValidateVolumeSnapshotterConfigKeys(config, regionKey, credentialProfileKey, credentialsFileKey); err != nil {
return err
}
region := config[regionKey]
credentialProfile := config[credentialProfileKey]
+ credentialsFile := config[credentialsFileKey]
if region == "" {
return errors.Errorf("missing %s in aws configuration", regionKey)
}
@@ -79,6 +81,18 @@ func (b *VolumeSnapshotter) Init(config map[string]string) error {
awsConfig := aws.NewConfig().WithRegion(region)
sessionOptions := session.Options{Config: *awsConfig, Profile: credentialProfile}
+ // Handle bug for credentials file
+ if credentialsFile != "" {
+ b.log.Infof("Hello World: %v", credentialsFile)
+ if _, err := os.Stat(credentialsFile); err != nil {
+ if os.IsNotExist(err) {
+ return errors.Wrapf(err, "provided credentialsFile does not exist")
+ }
+ return errors.Wrapf(err, "could not get credentialsFile info")
+ }
+ sessionOptions.SharedConfigFiles = []string{credentialsFile}
+ }
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment