support to create dynamodb resource by cloudformation (#2219)
* support to create dynamodb resource by cloudformation
This commit is contained in:
parent
cb72d1d00e
commit
a61124f774
3 changed files with 153 additions and 2 deletions
|
|
@ -12,7 +12,7 @@ from moto.batch import models as batch_models
|
|||
from moto.cloudwatch import models as cloudwatch_models
|
||||
from moto.cognitoidentity import models as cognitoidentity_models
|
||||
from moto.datapipeline import models as datapipeline_models
|
||||
from moto.dynamodb import models as dynamodb_models
|
||||
from moto.dynamodb2 import models as dynamodb2_models
|
||||
from moto.ec2 import models as ec2_models
|
||||
from moto.ecs import models as ecs_models
|
||||
from moto.elb import models as elb_models
|
||||
|
|
@ -37,7 +37,7 @@ MODEL_MAP = {
|
|||
"AWS::Batch::JobDefinition": batch_models.JobDefinition,
|
||||
"AWS::Batch::JobQueue": batch_models.JobQueue,
|
||||
"AWS::Batch::ComputeEnvironment": batch_models.ComputeEnvironment,
|
||||
"AWS::DynamoDB::Table": dynamodb_models.Table,
|
||||
"AWS::DynamoDB::Table": dynamodb2_models.Table,
|
||||
"AWS::Kinesis::Stream": kinesis_models.Stream,
|
||||
"AWS::Lambda::EventSourceMapping": lambda_models.EventSourceMapping,
|
||||
"AWS::Lambda::Function": lambda_models.LambdaFunction,
|
||||
|
|
|
|||
|
|
@ -417,6 +417,25 @@ class Table(BaseModel):
|
|||
}
|
||||
self.set_stream_specification(streams)
|
||||
|
||||
@classmethod
|
||||
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
||||
properties = cloudformation_json['Properties']
|
||||
params = {}
|
||||
|
||||
if 'KeySchema' in properties:
|
||||
params['schema'] = properties['KeySchema']
|
||||
if 'AttributeDefinitions' in properties:
|
||||
params['attr'] = properties['AttributeDefinitions']
|
||||
if 'GlobalSecondaryIndexes' in properties:
|
||||
params['global_indexes'] = properties['GlobalSecondaryIndexes']
|
||||
if 'ProvisionedThroughput' in properties:
|
||||
params['throughput'] = properties['ProvisionedThroughput']
|
||||
if 'LocalSecondaryIndexes' in properties:
|
||||
params['indexes'] = properties['LocalSecondaryIndexes']
|
||||
|
||||
table = dynamodb_backends[region_name].create_table(name=properties['TableName'], **params)
|
||||
return table
|
||||
|
||||
def _generate_arn(self, name):
|
||||
return 'arn:aws:dynamodb:us-east-1:123456789011:table/' + name
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue