Skip to content

Commit b8c7e3b

Browse files
committed
s3: load env creds
1 parent f763a82 commit b8c7e3b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

appstore/s3.py

+23
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@
99
session = None
1010
s3_endpoint = None
1111

12+
# Try loading creds from the environment.
13+
try:
14+
if session is None and config['AWS_ACCESS_KEY'] is not None and config['AWS_SECRET_KEY'] is not None:
15+
session = boto3.Session(
16+
aws_access_key_id=config['AWS_ACCESS_KEY'],
17+
aws_secret_access_key=config['AWS_SECRET_KEY'],
18+
)
19+
# XXX: for GCP later:
20+
# s3_endpoint = creds.get('S3Endpoint')
21+
except:
22+
pass
23+
24+
25+
# "Well, the creds were towed outside the environment." "Into another
26+
# environment?" "No, no, they've been towed beyond the environment. They're
27+
# not in the environment." "No, but from one environment to another
28+
# environment." "No, it's beyond the environment. It's not in an
29+
# environment. It's been towed beyond the environment." "Well, what's out
30+
# there?" "Nothing's out there!" "Well there must be something out there"
31+
# "There's nothing out there! All there is sea, and birds, and fish."
32+
# "And?" "And 20,000 tons of AWS creds." "And what else?" "And a fire."
33+
#
34+
# Try loading creds from an on-disk .json.
1235
try:
1336
if session is None:
1437
with open('session-token.json', 'r') as f:

appstore/settings.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@
2121
'HONEYCOMB_KEY': os.environ.get('HONEYCOMB_KEY', None),
2222
'DISCORD_HOOK_URL': os.environ.get('DISCORD_HOOK_URL', None),
2323
'DISCORD_ADMIN_HOOK_URL': os.environ.get('DISCORD_ADMIN_HOOK_URL', None),
24-
'ALGOLIA_DISABLE': os.environ.get('ALGOLIA_DISABLE', False)
24+
'ALGOLIA_DISABLE': os.environ.get('ALGOLIA_DISABLE', False),
25+
'AWS_ACCESS_KEY': os.environ.get('AWS_ACCESS_KEY', None),
26+
'AWS_SECRET_KEY': os.environ.get('AWS_SECRET_KEY', None),
2527
}

0 commit comments

Comments
 (0)