Skip to content

Commit

Permalink
Adds comments on boto cache dir usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lorengordon committed Oct 16, 2019
1 parent d2a95c8 commit 34a2a1a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions new-account-trust-policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import boto3
import botocore

# Allow user to override the boto cache dir using the env `BOTOCORE_CACHE_DIR`
# References:
# * <https://github.com/mixja/boto3-session-cache>
# * <https://github.com/boto/botocore/blob/a196a50ad7bbf2410b8ac800807acd0fb06ca331/botocore/credentials.py#L241-L252>
BOTOCORE_CACHE_DIR = os.environ.get('BOTOCORE_CACHE_DIR')

DEFAULT_LOG_LEVEL = logging.INFO
Expand Down Expand Up @@ -190,6 +194,9 @@ def lambda_handler(event, context):
update_role_name = os.environ['UPDATE_ROLE_NAME']
role_arn = f'arn:{partition}:iam::{account_id}:role/{assume_role_name}'
trust_policy = os.environ['TRUST_POLICY']

# In lambda, override the default boto cache dir because only `/tmp/`
# is writeable
botocore_cache_dir = BOTOCORE_CACHE_DIR or '/tmp/.aws/boto/cache'

# Assume the role and update the role trust policy
Expand Down

0 comments on commit 34a2a1a

Please sign in to comment.