Get AWS account id inside Lambda function programmatically - python
def lambda_handler(event, context): | |
# Get Account Id from lambda function arn | |
print "lambda arn: " + context.invoked_function_arn | |
# Get Account ID from lambda function arn in the context | |
ACCOUNT_ID = context.invoked_function_arn.split(":")[4] | |
print "Account ID=" + ACCOUNT_ID | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Once you rely on context... you need to make sure you fake it up from the command line and test invocations
or catch errors and substitute something else