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

Boto3 cannot find region #254

Open
atmosx opened this issue Sep 13, 2019 · 0 comments
Open

Boto3 cannot find region #254

atmosx opened this issue Sep 13, 2019 · 0 comments

Comments

@atmosx
Copy link

atmosx commented Sep 13, 2019

Hello, the following code:

#!/usr/bin/env python

from credstash import putSecretAutoversion as update_secret
import docker


class CredStashAPI:

    def __init__(self, log):
        self.log = log
        self.allowed_secrets = ['sec1']

    def run(self, key, value):
        if key in self.allowed_secrets:
            update_secret("{}".format(key),
                          "{}".format(value),
                          region="us-east-1",
                          context={"environment": "production"})
            self.log.info("Credstash key '{}' updated!".format(key))
        else:
            self.log.info("Key '{}' is not part of 'allowed_secrets' list!")

Produces an error related to boto3 region. The region is set specifically for credstash. This snippet runs inside a container. I tried setting AWS_DEFAULT_REGION as an env variable to the container, but still getting the error:

deployer.1.f9ntap553i0v@ip-10-0-12-167    |   File "/usr/local/lib/python3.7/site-packages/botocore-1.12.227-py3.7.egg/botocore/session.py", line 839, in create_client
deployer.1.s212szy96baw@ip-10-0-12-167    | botocore.exceptions.NoRegionError: You must specify a region.
deployer.1.f9ntap553i0v@ip-10-0-12-167    |     client_config=config, api_version=api_version)
deployer.1.f9ntap553i0v@ip-10-0-12-167    |   File "/usr/local/lib/python3.7/site-packages/botocore-1.12.227-py3.7.egg/botocore/client.py", line 86, in create_client
deployer.1.f9ntap553i0v@ip-10-0-12-167    |     verify, credentials, scoped_config, client_config, endpoint_bridge)
deployer.1.f9ntap553i0v@ip-10-0-12-167    |   File "/usr/local/lib/python3.7/site-packages/botocore-1.12.227-py3.7.egg/botocore/client.py", line 328, in _get_client_args
deployer.1.f9ntap553i0v@ip-10-0-12-167    |     verify, credentials, scoped_config, client_config, endpoint_bridge)
deployer.1.s212szy96baw@ip-10-0-12-167    | [2019-09-12 05:50:29 +0000] [1] [INFO] Handling signal: term
deployer.1.f9ntap553i0v@ip-10-0-12-167    |   File "/usr/local/lib/python3.7/site-packages/botocore-1.12.227-py3.7.egg/botocore/args.py", line 47, in get_client_args
deployer.1.f9ntap553i0v@ip-10-0-12-167    |     endpoint_url, is_secure, scoped_config)
deployer.1.s212szy96baw@ip-10-0-12-167    | [2019-09-12 05:50:29 +0000] [1] [INFO] Shutting down: Master
deployer.1.f9ntap553i0v@ip-10-0-12-167    |   File "/usr/local/lib/python3.7/site-packages/botocore-1.12.227-py3.7.egg/botocore/args.py", line 117, in compute_client_args
deployer.1.f9ntap553i0v@ip-10-0-12-167    |     service_name, region_name, endpoint_url, is_secure)
deployer.1.f9ntap553i0v@ip-10-0-12-167    |   File "/usr/local/lib/python3.7/site-packages/botocore-1.12.227-py3.7.egg/botocore/client.py", line 402, in resolve
deployer.1.f9ntap553i0v@ip-10-0-12-167    |     service_name, region_name)
deployer.1.f9ntap553i0v@ip-10-0-12-167    |   File "/usr/local/lib/python3.7/site-packages/botocore-1.12.227-py3.7.egg/botocore/regions.py", line 122, in construct_endpoint
deployer.1.f9ntap553i0v@ip-10-0-12-167    |     partition, service_name, region_name)
deployer.1.f9ntap553i0v@ip-10-0-12-167    |   File "/usr/local/lib/python3.7/site-packages/botocore-1.12.227-py3.7.egg/botocore/regions.py", line 135, in _endpoint_for_partition
deployer.1.f9ntap553i0v@ip-10-0-12-167    |     raise NoRegionError()
deployer.1.f9ntap553i0v@ip-10-0-12-167    | botocore.exceptions.NoRegionError: You must specify a region.

This might be related to #93 however in my case boto3 doesn't default to us-east-1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant