Exemplo n.º 1
0
    def get_deploy_templates(cls):
        def _pre_create(resource_id, resources, resource_type, func, stack_name):
            resource = resources[resource_id]
            props = resource["Properties"]

            def _generate_res_name():  # TODO: generalize
                return "%s-%s-%s" % (stack_name, resource_id, short_uid())

            props["TableName"] = props.get("TableName") or _generate_res_name()

        return {
            "create": [
                {"function": _pre_create},
                {
                    "function": "create_table",
                    "parameters": {
                        "TableName": "TableName",
                        "AttributeDefinitions": "AttributeDefinitions",
                        "KeySchema": "KeySchema",
                        "BillingMode": "BillingMode",
                        "ProvisionedThroughput": get_ddb_provisioned_throughput,
                        "LocalSecondaryIndexes": "LocalSecondaryIndexes",
                        "GlobalSecondaryIndexes": get_ddb_global_sec_indexes,
                        "StreamSpecification": lambda params, **kwargs: (
                            common.merge_dicts(
                                params.get("StreamSpecification"),
                                {"StreamEnabled": True},
                                default=None,
                            )
                        ),
                    },
                    "defaults": {
                        "ProvisionedThroughput": {
                            "ReadCapacityUnits": 5,
                            "WriteCapacityUnits": 5,
                        }
                    },
                },
                {
                    "function": "enable_kinesis_streaming_destination",
                    "parameters": get_ddb_kinesis_stream_specification,
                },
            ],
            "delete": {
                "function": "delete_table",
                "parameters": {"TableName": "TableName"},
            },
        }
Exemplo n.º 2
0
 def get_deploy_templates():
     return {
         "create": [
             {
                 "function": "create_table",
                 "parameters": {
                     "TableName":
                     "TableName",
                     "AttributeDefinitions":
                     "AttributeDefinitions",
                     "KeySchema":
                     "KeySchema",
                     "ProvisionedThroughput":
                     get_ddb_provisioned_throughput,
                     "LocalSecondaryIndexes":
                     "LocalSecondaryIndexes",
                     "GlobalSecondaryIndexes":
                     get_ddb_global_sec_indexes,
                     "StreamSpecification":
                     lambda params, **kwargs: (common.merge_dicts(
                         params.get("StreamSpecification"),
                         {"StreamEnabled": True},
                         default=None,
                     )),
                 },
                 "defaults": {
                     "ProvisionedThroughput": {
                         "ReadCapacityUnits": 5,
                         "WriteCapacityUnits": 5,
                     }
                 },
             },
             {
                 "function": "enable_kinesis_streaming_destination",
                 "parameters": get_ddb_kinesis_stream_specification,
             },
         ],
         "delete": {
             "function": "delete_table",
             "parameters": {
                 "TableName": "TableName"
             },
         },
     }
Exemplo n.º 3
0
         'parameters': {
             'TableName':
             'TableName',
             'AttributeDefinitions':
             'AttributeDefinitions',
             'KeySchema':
             'KeySchema',
             'ProvisionedThroughput':
             'ProvisionedThroughput',
             'LocalSecondaryIndexes':
             'LocalSecondaryIndexes',
             'GlobalSecondaryIndexes':
             'GlobalSecondaryIndexes',
             'StreamSpecification':
             lambda params, **kwargs: (common.merge_dicts(
                 params.get('StreamSpecification'), {'StreamEnabled': True},
                 default=None))
         },
         'defaults': {
             'ProvisionedThroughput': {
                 'ReadCapacityUnits': 5,
                 'WriteCapacityUnits': 5
             }
         }
     }
 },
 'IAM::Role': {
     # TODO implement
 },
 'ApiGateway::RestApi': {
     'create': {
Exemplo n.º 4
0
def merge_parameters(func1, func2):
    return lambda params, **kwargs: common.merge_dicts(func1(params, **kwargs), func2(params, **kwargs))