在 AWS SAM CLI 构建、打包和部署过程中忽略 Python 依赖的问题,可以通过以下解决方法:
requirements.txt
文件,其中列出了项目所需的所有 Python 依赖。例如:requests==2.25.1
flask==1.1.2
samconfig.toml
文件,其中包含以下内容:version = 0.1
[build]
manifest_path = "sam_build_manifest.json"
[package]
artifact_dir = "dist"
sam build --use-container
sam package --output-template-file packaged.yaml --s3-bucket
sam deploy --template-file packaged.yaml --stack-name --capabilities CAPABILITY_IAM
这样,AWS SAM CLI 将会正确处理并包含所有在 requirements.txt
文件中列出的 Python 依赖。