forked from kanisterio/kanister
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into docs-update
- Loading branch information
Showing
17 changed files
with
110 additions
and
67 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package aws | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/credentials" | ||
) | ||
|
||
const ( | ||
// ConfigRegion represents region key required in the map "config" | ||
ConfigRegion = "region" | ||
// ConfigRole represents the key for the ARN of the role which can be assumed. | ||
// It is optional. | ||
ConfigRole = "role" | ||
// AccessKeyID represents AWS Access key ID | ||
AccessKeyID = "AWS_ACCESS_KEY_ID" | ||
// SecretAccessKey represents AWS Secret Access Key | ||
SecretAccessKey = "AWS_SECRET_ACCESS_KEY" | ||
// SessionToken represents AWS Session Key | ||
SessionToken = "AWS_SESSION_TOKEN" | ||
) | ||
|
||
// GetConfig returns a configuration to establish AWS connection, connected region name and the role to assume if it exists. | ||
func GetConfig(config map[string]string) (awsConfig *aws.Config, region string, role string, err error) { | ||
region, ok := config[ConfigRegion] | ||
if !ok { | ||
return nil, "", "", errors.New("region required for storage type EBS") | ||
} | ||
accessKey, ok := config[AccessKeyID] | ||
if !ok { | ||
return nil, "", "", errors.New("AWS_ACCESS_KEY_ID required for storage type EBS") | ||
} | ||
secretAccessKey, ok := config[SecretAccessKey] | ||
if !ok { | ||
return nil, "", "", errors.New("AWS_SECRET_ACCESS_KEY required for storage type EBS") | ||
} | ||
sessionToken := config[SessionToken] | ||
role = config[ConfigRole] | ||
return &aws.Config{Credentials: credentials.NewStaticCredentials(accessKey, secretAccessKey, sessionToken)}, region, role, nil | ||
} |
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
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
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
Oops, something went wrong.