99x / 99x/serverless-dynamodb-local
Issue with default region on Localstack 1.1
- Dominant language
- JavaScript
- Stars
- 621
- Forks
- 232
- PR merge metrics
- No merged PRs in 30d
Description
**Actual Behaviour**
Using the plugin has become impossible as of late due to a hardcoded value 'localhost' as the region when initializing the plugin :
https://github.com/99x/serverless-dynamodb-local/blob/v1/index.js#L192
When starting the stack ( Localstack + serverless) I get an error :
'localhost' is not a valid AWS region name for dynamodb
This is thrown by boto3 when trying to resolve the DynamoDB enpoint and region locally.
**Steps to reproduce it**
Use Localstack 1.1.0, Serverless v3, and this plugin for migration and seeding.
**Logs for the issue**
The error message appears in every call, here's one of them :
`localstack_1 | 2022-09-05T12:41:30.713 ERROR --- [ asgi_gw_0] l.aws.handlers.logging : exception during call chain
localstack_1 | Traceback (most recent call last):
localstack_1 | File "/opt/code/localstack/localstack/aws/chain.py", line 57, in handle
localstack_1 | handler(self, self.context, response)
localstack_1 | File "/opt/code/localstack/localstack/aws/handlers/service.py", line 122, in __call__
localstack_1 | handler(chain, context, response)
localstack_1 | File "/opt/code/localstack/localstack/aws/handlers/service.py", line 92, in __call__
localstack_1 | skeleton_response = self.skeleton.invoke(context)
localstack_1 | File "/opt/code/localstack/localstack/aws/skeleton.py", line 153, in invoke
localstack_1 | return self.dispatch_request(context, instance)
localstack_1 | File "/opt/code/localstack/localstack/aws/skeleton.py", line 165, in dispatch_request
localstack_1 | result = handler(context, instance) or {}
localstack_1 | File "/opt/code/localstack/localstack/aws/forwarder.py", line 56, in _call
localstack_1 | return handler(context, req)
localstack_1 | File "/opt/code/localstack/localstack/aws/skeleton.py", line 117, in __call__
localstack_1 | return self.fn(*args, **kwargs)
localstack_1 | File "/opt/code/localstack/localstack/services/dynamodb/provider.py", line 471, in describe_table
localstack_1 | global_table_region: str | None = find_global_table_region(
localstack_1 | File "/opt/code/localstack/localstack/services/dynamodb/provider.py", line 285, in find_global_table_region
localstack_1 | replicas = get_store().REPLICA_UPDATES.get(table_name)
localstack_1 | File "/opt/code/localstack/localstack/services/dynamodb/provider.py", line 275, in get_store
localstack_1 | return dynamodb_stores[_account_id][_region]
localstack_1 | File "/opt/code/localstack/localstack/services/stores.py", line 166, in __getitem__
localstack_1 | raise ValueError(
localstack_1 | ValueError: 'localhost' is not a valid AWS region name for dynamodb`
**Would you like to work on the issue?**
I have only done a minor fix for my use case in a fork, but it may need a bit more work to make it configurable.
Contributor guide
Research direction
Start at index.js around line 192, where the plugin initializes with the hardcoded 'localhost' region, and reproduce the failure with Localstack 1.1.0, Serverless v3, and the migration or seeding workflow. Done means the region is configurable and DynamoDB calls no longer fail with an invalid AWS region error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100