add CloudFormation model for Kinesis streams

This commit is contained in:
Waldemar Hummer 2017-07-20 14:25:46 +10:00
parent 074ff68bf1
commit 115b9cee3e
3 changed files with 37 additions and 1 deletions

View File

@ -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,

View File

@ -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):

View File

@ -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