From a6606cbf42319320f9e67296fd9e65466027d016 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sat, 28 Aug 2021 07:25:06 +0100 Subject: [PATCH] DynamoDB - Describe Endpoints (#3716) --- moto/dynamodb2/models/__init__.py | 8 ++++++++ moto/dynamodb2/responses.py | 4 ++++ tests/test_dynamodb2/test_dynamodb.py | 15 +++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/moto/dynamodb2/models/__init__.py b/moto/dynamodb2/models/__init__.py index e9968e5c1..86f2f932d 100644 --- a/moto/dynamodb2/models/__init__.py +++ b/moto/dynamodb2/models/__init__.py @@ -1085,6 +1085,14 @@ class DynamoDBBackend(BaseBackend): def delete_table(self, name): return self.tables.pop(name, None) + def describe_endpoints(self): + return [ + { + "Address": "dynamodb.{}.amazonaws.com".format(self.region_name), + "CachePeriodInMinutes": 1440, + } + ] + def tag_resource(self, table_arn, tags): for table in self.tables: if self.tables[table].table_arn == table_arn: diff --git a/moto/dynamodb2/responses.py b/moto/dynamodb2/responses.py index 07c51da3c..66fba999c 100644 --- a/moto/dynamodb2/responses.py +++ b/moto/dynamodb2/responses.py @@ -190,6 +190,10 @@ class DynamoHandler(BaseResponse): er = "com.amazonaws.dynamodb.v20111205#ResourceNotFoundException" return self.error(er, "Requested resource not found") + def describe_endpoints(self): + response = {"Endpoints": self.dynamodb_backend.describe_endpoints()} + return dynamo_json_dump(response) + def tag_resource(self): table_arn = self.body["ResourceArn"] tags = self.body["Tags"] diff --git a/tests/test_dynamodb2/test_dynamodb.py b/tests/test_dynamodb2/test_dynamodb.py index 2efcf6e26..97331e98b 100644 --- a/tests/test_dynamodb2/test_dynamodb.py +++ b/tests/test_dynamodb2/test_dynamodb.py @@ -6202,3 +6202,18 @@ def test_source_and_restored_table_items_are_not_linked(): set(restored_table_guids).should.equal( set(guids_original) | set(guids_added_after_restore) ) + + +@mock_dynamodb2 +@pytest.mark.parametrize("region", ["eu-central-1", "ap-south-1"]) +def test_describe_endpoints(region): + client = boto3.client("dynamodb", region) + res = client.describe_endpoints()["Endpoints"] + res.should.equal( + [ + { + "Address": "dynamodb.{}.amazonaws.com".format(region), + "CachePeriodInMinutes": 1440, + }, + ] + )