Browse code

option to load AWS keys from env vars

Signed-off-by: Vasileios Mitrousis <vamitrou@gmail.com>

Vasileios Mitrousis authored on 2014/05/14 21:17:31
Showing 2 changed files
... ...
@@ -135,6 +135,11 @@ class Config(object):
135 135
 
136 136
             if len(self.access_key)==0:
137 137
                 self.role_config()
138
+            else:
139
+                if self.access_key[0] == '$':
140
+                    self.access_key = os.environ.get(self.access_key[1:])
141
+                if self.secret_key[0] == '$':
142
+                    self.secret_key = os.environ.get(self.secret_key[1:])
138 143
 
139 144
     def role_config(self):
140 145
         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. You can enter $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY 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"),