Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1125 from mozilla-services/bug/1124
Browse files Browse the repository at this point in the history
bug: Use environment var AWS_DEFAULT_REGION as region specifier
  • Loading branch information
pjenvey authored Feb 6, 2018
2 parents 0e03c36 + 1990c56 commit ab19033
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autopush/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def __init__(self, **kwargs):
if "endpoint_url" in conf and not conf["endpoint_url"]:
del(conf["endpoint_url"])
region = conf.get("region_name",
os.getenv("AWS_REGION_NAME", "us-east-1"))
os.getenv("AWS_DEFAULT_REGION", "us-east-1"))
if "region_name" in conf:
del(conf["region_name"])
self.conf = conf
Expand Down
14 changes: 14 additions & 0 deletions autopush/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ def test_ddb_no_endpoint(self, mresource):
if safe:
os.environ["AWS_LOCAL_DYNAMODB"] = safe

def test_ddb_env(self):
ddb_session_args = dict(
endpoint_url=os.getenv("AWS_LOCAL_DYNAMODB"),
aws_access_key_id="BogusKey",
aws_secret_access_key="BogusKey",
)
safe = os.getenv("AWS_DEFAULT_REGION")
os.environ["AWS_DEFAULT_REGION"] = "us-west-2"
boto_resource = DynamoDBResource(**ddb_session_args)
assert boto_resource._resource.meta.client.meta.region_name == \
'us-west-2'
if safe:
os.environ["AWS_DEFAULT_REGION"] = safe


class DbCheckTestCase(unittest.TestCase):
def setUp(cls):
Expand Down
2 changes: 1 addition & 1 deletion autopush/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def from_message_table(cls, uaid, item):
channel_id=uuid.UUID(key_info["channel_id"]),
data=item.get("data"),
headers=item.get("headers"),
ttl=item["ttl"],
ttl=item.get("ttl", 0),
topic=key_info.get("topic"),
message_id=key_info["message_id"],
update_id=item.get("updateid"),
Expand Down

0 comments on commit ab19033

Please sign in to comment.