Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local invoke command causes botocore.exceptions.NoRegionError: #885

Closed
MariusVolkhart opened this issue Dec 24, 2018 · 12 comments
Closed

local invoke command causes botocore.exceptions.NoRegionError: #885

MariusVolkhart opened this issue Dec 24, 2018 · 12 comments
Labels
stage/waiting-for-release Fix has been merged to develop and is waiting for a release

Comments

@MariusVolkhart
Copy link

MariusVolkhart commented Dec 24, 2018

Description

The sam local invoke command produces a botocore.exceptions.NoRegionError exception, which prevents its use.

#583 Fixed this for the sample code it seems

Steps to reproduce

On Mac OS:

  1. Follow direction to install via Homebrew
  2. Run echo '{"message": "Hey, are you there?" }' | sam local invoke "Signup". The function name doesn't matter; it can be anything.

Observed result

 echo '{"message": "Hey, are you there?" }' | sam local invoke "Signup" --debug
2018-12-24 18:26:53 Using SAM Template at /Users/marius_v/Documents/personal/identityvault-serverless/template.yaml
2018-12-24 18:26:53 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2018-12-24 18:26:53 Changing event name from before-call.apigateway to before-call.api-gateway
2018-12-24 18:26:53 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2018-12-24 18:26:53 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2018-12-24 18:26:53 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2018-12-24 18:26:53 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2018-12-24 18:26:53 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2018-12-24 18:26:53 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2018-12-24 18:26:53 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2018-12-24 18:26:53 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2018-12-24 18:26:53 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2018-12-24 18:26:53 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2018-12-24 18:26:53 Changing event name from before-call.apigateway to before-call.api-gateway
2018-12-24 18:26:53 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2018-12-24 18:26:53 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2018-12-24 18:26:53 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2018-12-24 18:26:53 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2018-12-24 18:26:53 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2018-12-24 18:26:53 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2018-12-24 18:26:53 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2018-12-24 18:26:53 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2018-12-24 18:26:53 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2018-12-24 18:26:53 local invoke command is called
2018-12-24 18:26:53 Reading invoke payload from stdin (you can also pass it from file with --event)
2018-12-24 18:26:53 Looking for credentials via: env
2018-12-24 18:26:53 Looking for credentials via: assume-role
2018-12-24 18:26:53 Looking for credentials via: shared-credentials-file
2018-12-24 18:26:53 Looking for credentials via: custom-process
2018-12-24 18:26:53 Looking for credentials via: config-file
2018-12-24 18:26:53 Looking for credentials via: ec2-credentials-file
2018-12-24 18:26:53 Looking for credentials via: boto-config
2018-12-24 18:26:53 Looking for credentials via: container-role
2018-12-24 18:26:53 Looking for credentials via: iam-role
2018-12-24 18:26:53 Converted retries value: False -> Retry(total=False, connect=None, read=None, redirect=0, status=None)
2018-12-24 18:26:53 Starting new HTTP connection (1): 169.254.169.254:80
2018-12-24 18:26:54 Caught retryable HTTP exception while making metadata service request to http://169.254.169.254/latest/meta-data/iam/security-credentials/: Connect timeout on endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/httpsession.py", line 258, in send
    decode_content=False,
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/util/retry.py", line 343, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/packages/six.py", line 686, in reraise
    raise value
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/awsrequest.py", line 125, in _send_request
    method, url, body, headers, *args, **kwargs)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/awsrequest.py", line 152, in _send_output
    self.send(msg)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/awsrequest.py", line 236, in send
    return super(AWSConnection, self).send(str)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
    self.connect()
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connection.py", line 181, in connect
    conn = self._new_conn()
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connection.py", line 164, in _new_conn
    (self.host, self.timeout))
urllib3.exceptions.ConnectTimeoutError: (<botocore.awsrequest.AWSHTTPConnection object at 0x1059a6d68>, 'Connection to 169.254.169.254 timed out. (connect timeout=1)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/utils.py", line 303, in _get_request
    response = self._session.send(request.prepare())
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/httpsession.py", line 282, in send
    raise ConnectTimeoutError(endpoint_url=request.url, error=e)
botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
2018-12-24 18:26:54 Max number of attempts exceeded (1) when attempting to retrieve data from metadata service.
2018-12-24 18:26:54 Loading JSON file: /usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/data/endpoints.json
2018-12-24 18:26:54 Event choose-service-name: calling handler <function handle_service_name_alias at 0x104be2840>
2018-12-24 18:26:54 Loading JSON file: /usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/data/serverlessrepo/2017-09-08/service-2.json
2018-12-24 18:26:54 Event creating-client-class.serverlessapplicationrepository: calling handler <function add_generate_presigned_url at 0x104ba96a8>
Traceback (most recent call last):
  File "/usr/local/bin/sam", line 11, in <module>
    load_entry_point('aws-sam-cli==0.10.0', 'console_scripts', 'sam')()
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/commands/local/invoke/cli.py", line 56, in cli
    parameter_overrides)  # pragma: no cover
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/commands/local/invoke/cli.py", line 93, in do_cli
    aws_region=ctx.region) as context:
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 130, in __enter__
    self._function_provider = SamFunctionProvider(self._template_dict, self.parameter_overrides)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/commands/local/lib/sam_function_provider.py", line 45, in __init__
    self.template_dict = SamBaseProvider.get_template(template_dict, parameter_overrides)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/commands/local/lib/sam_base_provider.py", line 60, in get_template
    template_dict = SamTranslatorWrapper(template_dict).run_plugins()
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/lib/samlib/wrapper.py", line 64, in run_plugins
    all_plugins = prepare_plugins(additional_plugins)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samtranslator/translator/translator.py", line 226, in prepare_plugins
    required_plugins.insert(0, ServerlessAppPlugin())
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samtranslator/plugins/application/serverless_app_plugin.py", line 54, in __init__
    self._sar_client = boto3.client('serverlessrepo')
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/boto3/__init__.py", line 91, in client
    return _get_default_session().client(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/session.py", line 838, in create_client
    client_config=config, api_version=api_version)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/client.py", line 86, in create_client
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/client.py", line 328, in _get_client_args
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/args.py", line 47, in get_client_args
    endpoint_url, is_secure, scoped_config)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/args.py", line 117, in compute_client_args
    service_name, region_name, endpoint_url, is_secure)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/client.py", line 402, in resolve
    service_name, region_name)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/regions.py", line 122, in construct_endpoint
    partition, service_name, region_name)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/botocore/regions.py", line 135, in _endpoint_for_partition
    raise NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.

Expected result

I expected to see my function run locally

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac
  2. sam --version: SAM CLI, version 0.10.0
@MariusVolkhart MariusVolkhart changed the title local invoke causes botocore.exceptions.NoRegionError: local invoke command causes botocore.exceptions.NoRegionError: Dec 24, 2018
@jfuss
Copy link
Contributor

jfuss commented Dec 27, 2018

This is causes by a boto3 client being instantiated in SAM when it isn't needed too. It was fixed here: aws/serverless-application-model#697.

We are waiting for SAM (aws-sam-translator) to cut a new release with the fix. Until then, you can set the default region through aws configure in the AWS CLI.

@jfuss jfuss added the stage/waiting-for-release Fix has been merged to develop and is waiting for a release label Dec 27, 2018
@jfuss
Copy link
Contributor

jfuss commented Feb 14, 2019

SAM release a patched (1.9.1) that included the fix for this. We bumped the version in #990 so this will be released with the next SAM CLI version. Moving into Release 0.12.0 Milestone.

@jfuss jfuss added this to the Release: v0.12.0 milestone Feb 14, 2019
@jfuss
Copy link
Contributor

jfuss commented Mar 8, 2019

This was released with v0.12.0

Closing

@jfuss jfuss closed this as completed Mar 8, 2019
@anuraguniyal
Copy link

upgrade sam-cli but still see the issue

$ sam --version
SAM CLI, version 0.12.0

$ sam local invoke HelloWorldFunction --event event.json
Traceback (most recent call last):
  File "/home/itsme/src/sample/sample.venv/bin/sam", line 11, in <module>
    sys.exit(cli())
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/samcli/commands/local/invoke/cli.py", line 56, in cli 
    parameter_overrides)  # pragma: no cover
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/samcli/commands/local/invoke/cli.py", line 96, in do_cli
    context.local_lambda_runner.invoke(context.function_name,
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 191, in local_lambda_runner
    layer_downloader = LayerDownloader(self._layer_cache_basedir, self.get_cwd())
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/samcli/local/layers/layer_downloader.py", line 39, in __init__
    self.lambda_client = lambda_client or boto3.client('lambda')
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/boto3/__init__.py", line 91, in client
    return _get_default_session().client(*args, **kwargs)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/botocore/session.py", line 838, in create_client
    client_config=config, api_version=api_version)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/botocore/client.py", line 86, in create_client
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/botocore/client.py", line 328, in _get_client_args
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/botocore/args.py", line 47, in get_client_args
    endpoint_url, is_secure, scoped_config)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/botocore/args.py", line 117, in compute_client_args
    service_name, region_name, endpoint_url, is_secure)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/botocore/client.py", line 402, in resolve
    service_name, region_name)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/botocore/regions.py", line 122, in construct_endpoint
    partition, service_name, region_name)
  File "/home/itsme/src/sample/sample.venv/lib/python3.6/site-packages/botocore/regions.py", line 135, in _endpoint_for_partition
    raise NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.

I am using python 3.6. with venv

@cjiang-ias
Copy link

I get this issue as well, with sam local start-api:

christinejiang at Christine-MBP in ~/Integral/sam-app on master*
$ sam --version
SAM CLI, version 0.13.0
christinejiang at Christine-MBP in ~/Integral/sam-app on master*
$ sam local start-api
2019-03-12 18:51:43 Found credentials in shared credentials file: ~/.aws/credentials
Traceback (most recent call last):
  File "/usr/local/bin/sam", line 11, in <module>
    load_entry_point('aws-sam-cli==0.13.0', 'console_scripts', 'sam')()
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/samcli/commands/local/start_api/cli.py", line 57, in cli
    parameter_overrides)  # pragma: no cover
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/samcli/commands/local/start_api/cli.py", line 91, in do_cli
    static_dir=static_dir)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/samcli/commands/local/lib/local_api_service.py", line 44, in __init__
    self.lambda_runner = lambda_invoke_context.local_lambda_runner
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 191, in local_lambda_runner
    layer_downloader = LayerDownloader(self._layer_cache_basedir, self.get_cwd())
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/samcli/local/layers/layer_downloader.py", line 39, in __init__
    self.lambda_client = lambda_client or boto3.client('lambda')
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/boto3/__init__.py", line 91, in client
    return _get_default_session().client(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/botocore/session.py", line 838, in create_client
    client_config=config, api_version=api_version)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/botocore/client.py", line 86, in create_client
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/botocore/client.py", line 328, in _get_client_args
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/botocore/args.py", line 47, in get_client_args
    endpoint_url, is_secure, scoped_config)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/botocore/args.py", line 117, in compute_client_args
    service_name, region_name, endpoint_url, is_secure)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/botocore/client.py", line 402, in resolve
    service_name, region_name)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/botocore/regions.py", line 122, in construct_endpoint
    partition, service_name, region_name)
  File "/usr/local/Cellar/aws-sam-cli/0.13.0/libexec/lib/python3.7/site-packages/botocore/regions.py", line 135, in _endpoint_for_partition
    raise NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.

@ghouston
Copy link

i have aws-sam-cli v 0.13.0 and this error is happening. i found i could work around it by providing the region on the command line.

sam local start-api --region us-east-1

@jfuss
Copy link
Contributor

jfuss commented Mar 13, 2019

@ghouston Looks like there was another path that this happened on. Just submitted a PR to address it

@haipcl
Copy link

haipcl commented Apr 26, 2019

I am using version 0.15.0 of AWS SAM CLI and this error is still appearing.

@k4fer74
Copy link

k4fer74 commented Apr 27, 2019

I am using version 0.15.0 of AWS SAM CLI and this error is still appearing.

I had the same problem. Type this into your terminal: export AWS_DEFAULT_REGION=us-west-2

@jfmmm
Copy link

jfmmm commented May 15, 2019

Still happening in 0.16.0 when running sam local start-api

@jfuss
Copy link
Contributor

jfuss commented May 15, 2019

The PR is still open: #1059 which is why it is 'still happening'. There are some failure happening in Travis that I can't reproduce locally at the moment. That is the current hold up.

@jfuss
Copy link
Contributor

jfuss commented May 23, 2019

#1059 was just merged and will go out with our next release. This should fix the NoRegionError once and for all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/waiting-for-release Fix has been merged to develop and is waiting for a release
Projects
None yet
Development

No branches or pull requests

8 participants