option to load AWS keys from env vars
Matt Domsch authored on 2014/06/24 10:55:09... | ... |
@@ -134,7 +134,13 @@ class Config(object): |
134 | 134 |
self.secret_key = secret_key |
135 | 135 |
|
136 | 136 |
if len(self.access_key)==0: |
137 |
- self.role_config() |
|
137 |
+ env_access_key = os.environ.get("AWS_ACCESS_KEY", None) or os.environ.get("AWS_ACCESS_KEY_ID", None) |
|
138 |
+ env_secret_key = os.environ.get("AWS_SECRET_KEY", None) or os.environ.get("AWS_SECRET_ACCESS_KEY", None) |
|
139 |
+ if env_access_key: |
|
140 |
+ self.access_key = env_access_key |
|
141 |
+ self.secret_key = env_secret_key |
|
142 |
+ else: |
|
143 |
+ self.role_config() |
|
138 | 144 |
|
139 | 145 |
def role_config(self): |
140 | 146 |
if sys.version_info[0] * 10 + sys.version_info[1] < 26: |
... | ... |
@@ -1751,7 +1751,7 @@ def gpg_decrypt(filename, gpgenc_header = "", in_place = True): |
1751 | 1751 |
def run_configure(config_file, args): |
1752 | 1752 |
cfg = Config() |
1753 | 1753 |
options = [ |
1754 |
- ("access_key", "Access Key", "Access key and Secret key are your identifiers for Amazon S3"), |
|
1754 |
+ ("access_key", "Access Key", "Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables."), |
|
1755 | 1755 |
("secret_key", "Secret Key"), |
1756 | 1756 |
("gpg_passphrase", "Encryption password", "Encryption password is used to protect your files from reading\nby unauthorized persons while in transfer to S3"), |
1757 | 1757 |
("gpg_command", "Path to GPG program"), |