credential keys now actually work when set via env

all credential keys are converted to uppercase, dashes replaced with underscores and prefixed with 'AWS_'
This commit is contained in:
Anders Ingemann 2013-11-04 17:31:32 +01:00
parent 71adb3d04e
commit c62dcccd8d

View file

@ -20,9 +20,12 @@ class GetCredentials(Task):
for key in keys: for key in keys:
creds[key] = manifest.credentials[key] creds[key] = manifest.credentials[key]
return creds return creds
if all(getenv(key) is not None for key in keys):
def env_key(key):
return ('aws-'+key).upper().replace('-', '_')
if all(getenv(env_key(key)) is not None for key in keys):
for key in keys: for key in keys:
creds[key] = getenv(key) creds[key] = getenv(env_key(key))
return creds return creds
raise RuntimeError(('No ec2 credentials found, they must all be specified ' raise RuntimeError(('No ec2 credentials found, they must all be specified '
'exclusively via environment variables or through the manifest.')) 'exclusively via environment variables or through the manifest.'))