zl程序教程

您现在的位置是:首页 >  后端

当前栏目

[AWS] Lambda Python Get Current Account Id

PythonAWS ID get lambda Current account
2023-09-11 14:21:36 时间

Unlike AWS_REGION or AWS_LAMBDA_FUNCTION_NAME, we cannot get current account id from the environment variables. In order to to get the account id, we can use boto3 library with the following code:


import boto3

client = boto3.client("sts")
account_id =  client.get_caller_identity()["Account"]