Skip to content

Commit

Permalink
Resolve #156 Incompatible with Localstack (#180)
Browse files Browse the repository at this point in the history
* Making it so alternative hosts are used when the host parameter is used instead of only when the region is set to local. This will improve compatibility with other methods of mocking AWS services while maintaining compatbility with existing scripts since the host parameter was only used for this mode anyway.

* Update dynamodump.py

Updating help text per requested change.
  • Loading branch information
mnuzzo-moxe committed Dec 13, 2022
1 parent 9cedd33 commit be53b4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ dynamodump -a tar -b some_s3_bucket -m restore -r us-east-1 -p profile -d destin
## Local example

The following assumes your local DynamoDB is running on localhost:8000 and is accessible via 'a' as access/secret keys.
You must specify the host to get local behavior.

```
dynamodump -m backup -r local -s testTable --host localhost --port 8000 --accessKey a --secretKey a
Expand Down
10 changes: 4 additions & 6 deletions dynamodump/dynamodump.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
DEFAULT_PREFIX_SEPARATOR = "-"
CURRENT_WORKING_DIR = os.getcwd()
JSON_INDENT = 2
LOCAL_REGION = "local"
LOCAL_SLEEP_INTERVAL = 1 # seconds
LOG_LEVEL = "INFO"
MAX_BATCH_WRITE = 25 # DynamoDB limit
Expand Down Expand Up @@ -1121,12 +1120,11 @@ def main():
"-r",
"--region",
help="AWS region to use, e.g. 'us-west-1'. "
"Can use AWS_DEFAULT_REGION for local testing. Use '"
+ LOCAL_REGION
+ "' for local DynamoDB testing",
"Can use any region for local testing",
)
parser.add_argument(
"--host", help="Host of local DynamoDB [required only for local]"
"--host",
help="Host of local DynamoDB. This parameter initialises dynamodump for local DynamoDB testing [required only for local]",
)
parser.add_argument(
"--port", help="Port of local DynamoDB [required only for local]"
Expand Down Expand Up @@ -1250,7 +1248,7 @@ def main():
sys.exit(1)

# instantiate connection
if args.region == LOCAL_REGION:
if args.host:
conn = _get_aws_client(
service="dynamodb",
access_key=args.accessKey,
Expand Down

0 comments on commit be53b4a

Please sign in to comment.