Python 部署到Elastic Beanstalk时Django出现了望台区域错误
在部署到AWS Elastic Beanstalk时,我正在尝试将watchtower与Django API结合使用,我的Google页面快用完了。当我使用AWS EB CLI部署时,会出现一个错误,指出:Python 部署到Elastic Beanstalk时Django出现了望台区域错误,python,django,amazon-web-services,amazon-elastic-beanstalk,Python,Django,Amazon Web Services,Amazon Elastic Beanstalk,在部署到AWS Elastic Beanstalk时,我正在尝试将watchtower与Django API结合使用,我的Google页面快用完了。当我使用AWS EB CLI部署时,会出现一个错误,指出: ValueError: Unable to configure handler 'watchtower': You must specify a region. 为了解决这个问题,我尝试了多种方式添加我的凭据。我把它们放在settings.py文件中,凭证文件放在.aws目录中(csv和无
ValueError: Unable to configure handler 'watchtower': You must specify a region.
为了解决这个问题,我尝试了多种方式添加我的凭据。我把它们放在settings.py文件中,凭证文件放在.aws目录中(csv和无扩展名)
Settings.py:
导入操作系统
从日期时间导入时间增量
从boto3.session导入会话
从boto3导入客户端
#在项目内部构建如下路径:os.path.join(BASE_DIR,…)
BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(u文件_u)))
AWS\u访问\u密钥\u ID='我的密钥'
AWS_SECRET_ACCESS_KEY='Shhh SECRET KEY'
AWS_地区_名称='us-east-2'
boto3\u会话=会话(aws\u访问\u密钥\u id=aws\u访问\u密钥\u id,
aws_secret_access_key=aws_secret_access_key,
地区名称=AWS地区名称)
如前所述,我的根目录中还有一个名为“.aws”的目录,其凭据如下:
[default]
region = us-east-2
aws_access_key_id = key
aws_secret_access_key = key
我的配置文件:
option_settings:
- namespace: aws:elasticbeanstalk:container:python
option_name: WSGIPath
value: Wesbite/wsgi.py
- option_name: DJANGO_SETTINGS_MODULE
value: Wesbite.settings
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: StreamLogs
value: true
以下是错误的完整输出:
ValueError: Unable to configure handler 'watchtower': You must specify a region.
container_command 01_migrate in .ebextensions/db-migrate.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2019-09-08 01:17:39 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
谢谢你的见解
编辑:
在cloudwatch中,错误还表示:
botocore.exceptions.NoRegionError: You must specify a region.
我在容器中添加了AWS_DEFAULT_REGION作为环境变量,解决了这个问题。在设置日志处理程序时,我找不到任何明显的方法来指定区域。(在我的例子中,我将此env文件添加到我的无服务器yaml的AWS::Batch::JobDefinition.ContainerProperties.Environment部分。)
botocore.exceptions.NoRegionError: You must specify a region.