Miserlou / Zappa

Serverless Python
https://blog.zappa.io/
MIT License
11.89k stars 1.2k forks source link

zappa deploy: region missing from zappa_settings.json created by zappa init #1554

Open virtualritz opened 6 years ago

virtualritz commented 6 years ago

Context

After using zappa init with all defaults, zappa deploy fails.

Expected Behavior

zappa deploy should succeed, initially, after a zappa init accepting all defaults.

Actual Behavior

$ zappa deploy dev
Calling deploy for stage dev..
Warning! AWS Lambda may not be available in this AWS Region!
Warning! AWS API Gateway may not be available in this AWS Region!
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/zappa/cli.py", line 2693, in handle
    sys.exit(cli.handle())
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/zappa/cli.py", line 504, in handle
    self.dispatch_command(self.command, stage)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/zappa/cli.py", line 530, in dispatch_command
    self.load_settings(self.vargs.get('settings_file'))
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/zappa/cli.py", line 2060, in load_settings
    xray_tracing=self.xray_tracing
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/zappa/core.py", line 293, in __init__
    self.lambda_client = self.boto_client('lambda', config=long_config)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/zappa/core.py", line 323, in boto_client
    return self.boto_session.client(service, *args, **self.configure_boto_session_method_kwargs(service, kwargs))
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/botocore/session.py", line 861, in create_client
    client_config=config, api_version=api_version)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/botocore/client.py", line 76, in create_client
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/botocore/client.py", line 285, in _get_client_args
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/botocore/args.py", line 45, in get_client_args
    endpoint_url, is_secure, scoped_config)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/botocore/args.py", line 111, in compute_client_args
    service_name, region_name, endpoint_url, is_secure)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/botocore/client.py", line 358, in resolve
    service_name, region_name)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/botocore/regions.py", line 122, in construct_endpoint
    partition, service_name, region_name)
  File "/Users/moeller/.pyenv/versions/3.6.5/lib/python3.6/site-packages/botocore/regions.py", line 135, in _endpoint_for_partition
    raise NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.

==============

Steps to Reproduce

zappa init (accept all defaults) zappa deploy dev

Your Environment

Qoyyuum commented 5 years ago

I have the same issue with slightly different specs:

PS C:\app\ > pip freeze
argcomplete==1.9.3
Babel==2.6.0
base58==1.0.0
boto3==1.9.4
botocore==1.12.4
certifi==2018.8.24
cfn-flip==1.0.3
chardet==3.0.4
click==6.7
Django==2.1.1
django-appconf==1.0.2
django-compressor==2.2
django-extra-views==0.11.0
django-haystack==2.8.1
django-oscar==1.6.4
django-phonenumber-field==2.0.1
django-tables2==1.21.2
django-treebeard==4.3
django-widget-tweaks==1.4.3
docutils==0.14
durationpy==0.5
factory-boy==2.11.1
Faker==0.9.0
future==0.16.0
hjson==3.0.1
idna==2.7
jmespath==0.9.3
kappa==0.6.0
lambda-packages==0.20.0
mock==2.0.0
pbr==4.2.0
phonenumbers==8.9.13
Pillow==5.2.0
placebo==0.8.2
purl==1.4
pycountry==18.5.26
python-dateutil==2.7.3
python-slugify==1.2.4
pytz==2018.5
PyYAML==3.12
rcssmin==1.0.6
requests==2.19.1
rjsmin==1.0.12
s3transfer==0.1.13
six==1.11.0
sorl-thumbnail==12.4.1
text-unidecode==1.2
toml==0.9.6
tqdm==4.19.1
troposphere==2.3.3
Unidecode==1.0.22
urllib3==1.23
Werkzeug==0.14.1
whitenoise==4.0
wsgi-request-logger==0.4.6
zappa==0.46.2

Error shows similar:

(pip 18.0 (c:\users\ms1\.virtualenvs\app\lib\site-packages), Requirement.parse('pip<=10.1.0,>=9.0.1'), {'zappa'})
Calling deploy for stage dev..
Warning! AWS Lambda may not be available in this AWS Region!
Warning! AWS API Gateway may not be available in this AWS Region!
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\zappa\cli.py", line 2693, in handle
    sys.exit(cli.handle())
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\zappa\cli.py", line 504, in handle
    self.dispatch_command(self.command, stage)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\zappa\cli.py", line 530, in dispatch_command
    self.load_settings(self.vargs.get('settings_file'))
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\zappa\cli.py", line 2060, in load_settings
    xray_tracing=self.xray_tracing
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\zappa\core.py", line 293, in __init__
    self.lambda_client = self.boto_client('lambda', config=long_config)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\zappa\core.py", line 323, in boto_client
    return self.boto_session.client(service, *args, **self.configure_boto_session_method_kwargs(service, kwargs))
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\boto3\session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\botocore\session.py", line 889, in create_client
    client_config=config, api_version=api_version)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\botocore\client.py", line 76, in create_client
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\botocore\client.py", line 291, in _get_client_args
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\botocore\args.py", line 45, in get_client_args
    endpoint_url, is_secure, scoped_config)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\botocore\args.py", line 112, in compute_client_args
    service_name, region_name, endpoint_url, is_secure)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\botocore\client.py", line 364, in resolve
    service_name, region_name)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\botocore\regions.py", line 122, in construct_endpoint
    partition, service_name, region_name)
  File "c:\users\ms1\.virtualenvs\app\lib\site-packages\botocore\regions.py", line 135, in _endpoint_for_partition
    raise NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.

==============
jvicentenapolitano commented 5 years ago

Try to specify inside the zappa_settings.json file a new field called "aws_region" for the region that you are trying to deploy.

{ "dev": { "app_function": "app.init.app", "profile_name": "default", "project_name": "flask-lambda-la", "runtime": "python3.6", "s3_bucket": "zappa-3geposihd", "aws_region": "<INTRODUCE HERE YOUR REGION, ex: eu-west-1>" }

jneves commented 5 years ago

Do you have any region field in the AWS config or credentials files and/or any value (or empty string) on an environment variable called AWS_REGION?

jvicentenapolitano commented 5 years ago

@jneves there is no variable created in the preset file when it is used the command zappa init, but in the link https://github.com/Miserlou/Zappa/blob/master/example/zappa_settings.json there is specified some of those fields

minu93 commented 3 years ago

I've the same issue, my zappa_settings.json:

{ "dev": { "app_function": "app.__init__.app", "profile_name": null, "project_name": "contact", "runtime": "python3.8", "s3_bucket": "zappa-s2ze4ee9c", "aws_region": "eu-central-1" } }

@jneves Is there any fix or workaround?

purplezi commented 3 years ago

I've the same issue, my zappa_settings.json:

{ "dev": { "app_function": "app.__init__.app", "profile_name": null, "project_name": "contact", "runtime": "python3.8", "s3_bucket": "zappa-s2ze4ee9c", "aws_region": "eu-central-1" } }

@jneves Is there any fix or workaround?

May I ask “How can we get this region field?“ ”It can be get from AWS or anywhere else?"

OK, I finally find it at https://docs.aws.amazon.com/zh_cn/general/latest/gr/rande.html

Thanks anyway