From a66b0e5b1a5087b206b9e6bb384e2de993c96f2e Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Thu, 4 Jun 2020 07:45:00 +0100 Subject: [PATCH] CloudFormation - Support DynamoDB Streams --- moto/dynamodb2/models/__init__.py | 2 ++ .../test_cloudformation_stack_integration.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/moto/dynamodb2/models/__init__.py b/moto/dynamodb2/models/__init__.py index a5277800f..ff4ad3594 100644 --- a/moto/dynamodb2/models/__init__.py +++ b/moto/dynamodb2/models/__init__.py @@ -342,6 +342,8 @@ class Table(BaseModel): params["throughput"] = properties["ProvisionedThroughput"] if "LocalSecondaryIndexes" in properties: params["indexes"] = properties["LocalSecondaryIndexes"] + if "StreamSpecification" in properties: + params["streams"] = properties["StreamSpecification"] table = dynamodb_backends[region_name].create_table( name=properties["TableName"], **params diff --git a/tests/test_cloudformation/test_cloudformation_stack_integration.py b/tests/test_cloudformation/test_cloudformation_stack_integration.py index 27bac5e57..ad2436696 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_integration.py +++ b/tests/test_cloudformation/test_cloudformation_stack_integration.py @@ -2307,6 +2307,7 @@ def test_stack_dynamodb_resources_integration(): }, } ], + "StreamSpecification": {"StreamViewType": "KEYS_ONLY"}, }, } }, @@ -2319,6 +2320,12 @@ def test_stack_dynamodb_resources_integration(): StackName="dynamodb_stack", TemplateBody=dynamodb_template_json ) + dynamodb_client = boto3.client("dynamodb", region_name="us-east-1") + table_desc = dynamodb_client.describe_table(TableName="myTableName")["Table"] + table_desc["StreamSpecification"].should.equal( + {"StreamEnabled": True, "StreamViewType": "KEYS_ONLY",} + ) + dynamodb_conn = boto3.resource("dynamodb", region_name="us-east-1") table = dynamodb_conn.Table("myTableName") table.name.should.equal("myTableName")