部署到Elastic-Beanstalk时具有with望塔区域错误的Django

时间:2019-09-08 01:34:46

标签: python django amazon-web-services amazon-elastic-beanstalk

当我部署到AWS Elastic Beanstalk时,我尝试在Django API中使用use望塔,而Google页面即将用完。当我使用AWS EB CLI进行部署时,出现错误消息:

ValueError: Unable to configure handler 'watchtower': You must specify a region.

我尝试以多种方式添加我的凭据来尝试解决此问题。我已经将它们放在settings.py文件中,即.aws目录中的凭据文件中(包括csv和无扩展名)。

Settings.py:

import os
from datetime import timedelta
from boto3.session import Session
from boto3 import client

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

AWS_ACCESS_KEY_ID = 'MY-KEy'
AWS_SECRET_ACCESS_KEY = 'Shhh Secret Key'
AWS_REGION_NAME = 'us-east-2'

boto3_session = Session(aws_access_key_id=AWS_ACCESS_KEY_ID,
                        aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                        region_name=AWS_REGION_NAME)

正如我所说,我的根目录中还有一个名为“ .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
container_commands:
  01_migrate:
    command: "django-admin.py migrate"
    leader_only: true
  02_collectstatic:
    command: "python manage.py collectstatic --noinput"
  03_wsgipass:
    command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'
option_settings:
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: Wesbite.settings
    PYTHONPATH: "$PYTHONPATH"
  "aws:elasticbeanstalk:container:python":
    WSGIPath: "my_eb_site/wsgi.py"
    StaticFiles: "/static/=www/static/"

以下是错误的完整输出:

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.

0 个答案:

没有答案