From 115b9cee3e823208fa8ff389f6fd955b849ae673 Mon Sep 17 00:00:00 2001 From: Waldemar Hummer Date: Thu, 20 Jul 2017 14:25:46 +1000 Subject: [PATCH] add CloudFormation model for Kinesis streams --- moto/cloudformation/parsing.py | 2 ++ moto/kinesis/models.py | 7 +++++ .../test_cloudformation_stack_crud.py | 29 ++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/moto/cloudformation/parsing.py b/moto/cloudformation/parsing.py index 928cd68e0..923ada058 100644 --- a/moto/cloudformation/parsing.py +++ b/moto/cloudformation/parsing.py @@ -15,6 +15,7 @@ from moto.ec2 import models as ec2_models from moto.ecs import models as ecs_models from moto.elb import models as elb_models from moto.iam import models as iam_models +from moto.kinesis import models as kinesis_models from moto.kms import models as kms_models from moto.rds import models as rds_models from moto.rds2 import models as rds2_models @@ -31,6 +32,7 @@ MODEL_MAP = { "AWS::AutoScaling::AutoScalingGroup": autoscaling_models.FakeAutoScalingGroup, "AWS::AutoScaling::LaunchConfiguration": autoscaling_models.FakeLaunchConfiguration, "AWS::DynamoDB::Table": dynamodb_models.Table, + "AWS::Kinesis::Stream": kinesis_models.Stream, "AWS::Lambda::EventSourceMapping": lambda_models.EventSourceMapping, "AWS::Lambda::Function": lambda_models.LambdaFunction, "AWS::Lambda::Version": lambda_models.LambdaVersion, diff --git a/moto/kinesis/models.py b/moto/kinesis/models.py index 13900e6a6..aae94bbbd 100644 --- a/moto/kinesis/models.py +++ b/moto/kinesis/models.py @@ -172,6 +172,13 @@ class Stream(BaseModel): } } + @classmethod + def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name): + properties = cloudformation_json['Properties'] + region = properties.get('Region', 'us-east-1') + shard_count = properties.get('ShardCount', 1) + return Stream(properties['Name'], shard_count, region) + class FirehoseRecord(BaseModel): diff --git a/tests/test_cloudformation/test_cloudformation_stack_crud.py b/tests/test_cloudformation/test_cloudformation_stack_crud.py index 0e3634756..801faf8a1 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_crud.py +++ b/tests/test_cloudformation/test_cloudformation_stack_crud.py @@ -569,7 +569,6 @@ def test_describe_stack_events_shows_create_update_and_delete(): @mock_cloudformation_deprecated -@mock_route53_deprecated def test_create_stack_lambda_and_dynamodb(): conn = boto.connect_cloudformation() dummy_template = { @@ -643,3 +642,31 @@ def test_create_stack_lambda_and_dynamodb(): stack = conn.describe_stacks()[0] resources = stack.list_resources() assert len(resources) == 4 + + +@mock_cloudformation_deprecated +def test_create_stack_kinesis(): + conn = boto.connect_cloudformation() + dummy_template = { + "AWSTemplateFormatVersion": "2010-09-09", + "Description": "Stack Kinesis Test 1", + "Parameters": {}, + "Resources": { + "stream1": { + "Type" : "AWS::Kinesis::Stream", + "Properties" : { + "Name": "stream1", + "ShardCount": 2 + } + } + } + } + conn.create_stack( + "test_stack_kinesis_1", + template_body=json.dumps(dummy_template), + parameters={}.items() + ) + + stack = conn.describe_stacks()[0] + resources = stack.list_resources() + assert len(resources) == 1