问题描述
限时送ChatGPT账号..我有一个连接到数据库的 Python 应用程序,我希望数据库凭据在本地环境(用于测试)或 lambda 函数(用于生产)中运行时不同.
I've got a Python application that connects to a database and I would like the db credentials to be different when it's running in local env (for testing) or within a lambda function (for production).
有什么方法可以从 Python 应用程序中检测它是否在 lambda 函数内运行?
Is there any way, from the Python app, to detect that it is running inside the lambda function?
推荐答案
查看其他答案,这是一个更好的解决方案:
See the other answer, this is a better solution:
os.environ.get("AWS_EXECUTION_ENV") is not None
原答案:
Original answer:
如何检查处理函数中是否存在 context
对象?http://docs.aws.amazon/lambda/latest/dg/python-programming-model-handler-types.html
How about checking for the existence of the context
object in the handler function? http://docs.aws.amazon/lambda/latest/dg/python-programming-model-handler-types.html
这篇关于如何检查 Python 应用程序是否在 AWS lambda 函数中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论