Beispiel #1
0
        BillingMode=If("OnDemand", "PAY_PER_REQUEST", "PROVISIONED"),
        KeySchema=[
            KeySchema(AttributeName=Ref(tableIndexName), KeyType="HASH")
        ],
        ProvisionedThroughput=If(
            "OnDemand", NoValue,
            ProvisionedThroughput(ReadCapacityUnits=Ref(readunits),
                                  WriteCapacityUnits=Ref(writeunits))),
        GlobalSecondaryIndexes=[
            GlobalSecondaryIndex(
                IndexName="SecondaryIndex",
                KeySchema=[
                    KeySchema(AttributeName=Ref(secondaryIndexHashName),
                              KeyType="HASH"),
                    KeySchema(AttributeName=Ref(secondaryIndexRangeName),
                              KeyType="RANGE")
                ],
                Projection=Projection(ProjectionType="ALL"),
                ProvisionedThroughput=If(
                    "OnDemand", NoValue,
                    ProvisionedThroughput(ReadCapacityUnits=Ref(readunits),
                                          WriteCapacityUnits=Ref(writeunits))))
        ]))

template.add_output(
    Output(
        "GSITable",
        Value=Ref(GSITable),
        Description="Table with a Global Secondary Index",
    ))
Beispiel #2
0
                            Ref(secondaryIndexRangeDataType))
    ],
    KeySchema=[
        Key(Ref(tableIndexName), "HASH")
    ],
    ProvisionedThroughput=ProvisionedThroughput(
        Ref(readunits),
        Ref(writeunits)
    ),
    GlobalSecondaryIndexes=[
        GlobalSecondaryIndex(
            "SecondaryIndex",
            [
                Key(Ref(secondaryIndexHashName), "HASH"),
                Key(Ref(secondaryIndexRangeName), "RANGE")
            ],
            Projection("ALL"),
            ProvisionedThroughput(
                Ref(readunits),
                Ref(writeunits)
            )
        )
    ]
))

template.add_output(Output(
    "GSITable",
    Value=Ref(GSITable),
    Description="Table with a Global Secondary Index",
))

Beispiel #3
0
                                AttributeType="S")
        ],
        KeySchema=[
            KeySchema(AttributeName=Ref(tableIndexName), KeyType="HASH")
        ],
        ProvisionedThroughput=ProvisionedThroughput(
            ReadCapacityUnits=Ref(readunits),
            WriteCapacityUnits=Ref(writeunits)),
        GlobalSecondaryIndexes=[
            GlobalSecondaryIndex(
                IndexName="SecondaryIndex",
                KeySchema=[
                    KeySchema(AttributeName=Ref(secondaryIndexHashName),
                              KeyType="HASH"),
                    KeySchema(AttributeName=Ref(secondaryIndexRangeName),
                              KeyType="RANGE")
                ],
                Projection=Projection(ProjectionType="INCLUDE",
                                      NonKeyAttributes=["non_key_attribute_0"
                                                        ]),
                ProvisionedThroughput=ProvisionedThroughput(
                    ReadCapacityUnits=Ref(readunits),
                    WriteCapacityUnits=Ref(writeunits)))
        ]))

template.add_output(
    Output(
        "GSITable",
        Value=Ref(GSITable),
        Description="Table with a Global Secondary Index",
    ))
t.add_resource(
    Table("TestGlobalSecondaryIndexTable",
          KeySchema=[
              KeySchema(AttributeName="GameId", KeyType="HASH"),
              KeySchema(AttributeName="GameType", KeyType="RANGE")
          ],
          AttributeDefinitions=[
              AttributeDefinition(AttributeName="GameId", AttributeType="N"),
              AttributeDefinition(AttributeName="GameType", AttributeType="N"),
              AttributeDefinition(AttributeName="SeasonId", AttributeType="N"),
              AttributeDefinition(AttributeName="KeyPlayerId",
                                  AttributeType="N")
          ],
          ProvisionedThroughput=ProvisionedThroughput(ReadCapacityUnits=1,
                                                      WriteCapacityUnits=1),
          GlobalSecondaryIndexes=[
              GlobalSecondaryIndex(IndexName="GSIKeyPlayer",
                                   KeySchema=[
                                       KeySchema(AttributeName="SeasonId",
                                                 KeyType="HASH"),
                                       KeySchema(AttributeName="KeyPlayerId",
                                                 KeyType="RANGE"),
                                   ],
                                   Projection=Projection(ProjectionType="ALL"),
                                   ProvisionedThroughput=ProvisionedThroughput(
                                       ReadCapacityUnits=5,
                                       WriteCapacityUnits=1))
          ]))

print(t.to_json())
Beispiel #5
0
        AttributeDefinition("non_key_attribute_1", "S")
    ],
    KeySchema=[
        Key(Ref(tableIndexName), "HASH")
    ],
    ProvisionedThroughput=ProvisionedThroughput(
        Ref(readunits),
        Ref(writeunits)
    ),
    GlobalSecondaryIndexes=[
        GlobalSecondaryIndex(
            "SecondaryIndex",
            [
                Key(Ref(secondaryIndexHashName), "HASH"),
                Key(Ref(secondaryIndexRangeName), "RANGE")
            ],
            Projection("INCLUDE", ["non_key_attribute_0"]),
            ProvisionedThroughput(
                Ref(readunits),
                Ref(writeunits)
            )
        )
    ]
))

template.add_output(Output(
    "GSITable",
    Value=Ref(GSITable),
    Description="Table with a Global Secondary Index",
))

Beispiel #6
0
def create_template():
    t = Template()

    t.add_description("The DynamoDB tables stack for CBuildCI.")

    p_config_table_name = t.add_parameter(Parameter(
        "ConfigTableName",
        Type = "String",
    ))

    p_locks_table_name = t.add_parameter(Parameter(
        "LocksTableName",
        Type = "String",
    ))

    p_sessions_table_name = t.add_parameter(Parameter(
        "SessionsTableName",
        Type = "String",
    ))

    p_executions_table_name = t.add_parameter(Parameter(
        "ExecutionsTableName",
        Type = "String",
    ))

    p_config_table_rcu = t.add_parameter(Parameter(
        "ConfigTableRCU",
        Type = "Number",
        Default = "5",
    ))

    p_config_table_wcu = t.add_parameter(Parameter(
        "ConfigTableWCU",
        Type = "Number",
        Default = "1",
    ))

    p_locks_table_rcu = t.add_parameter(Parameter(
        "LocksTableRCU",
        Type = "Number",
        Default = "5",
    ))

    p_locks_table_wcu = t.add_parameter(Parameter(
        "LocksTableWCU",
        Type = "Number",
        Default = "2",
    ))

    p_sessions_table_rcu = t.add_parameter(Parameter(
        "SessionsTableRCU",
        Type = "Number",
        Default = "5",
    ))

    p_sessions_table_wcu = t.add_parameter(Parameter(
        "SessionsTableWCU",
        Type = "Number",
        Default = "2",
    ))

    p_executions_table_rcu = t.add_parameter(Parameter(
        "ExecutionsTableRCU",
        Type = "Number",
        Default = "15",
    ))

    p_executions_table_wcu = t.add_parameter(Parameter(
        "ExecutionsTableWCU",
        Type = "Number",
        Default = "5",
    ))

    p_executions_search_indexes_rcu = t.add_parameter(Parameter(
        "ExecutionsSearchIndexesRCU",
        Type = "Number",
        Default = "5",
    ))

    p_executions_search_indexes_wcu = t.add_parameter(Parameter(
        "ExecutionsSearchIndexesWCU",
        Type = "Number",
        Default = "1",
    ))

    # Replace with custom tags if desired.
    tags = build_tags_list(t)

    t.add_resource(Table(
        "ConfigDBTable",
        DeletionPolicy = "Retain",
        TableName = Ref(p_config_table_name),
        KeySchema = [
            KeySchema(
                KeyType = "HASH",
                AttributeName = "id",
            ),
        ],
        AttributeDefinitions = [
            AttributeDefinition(
                AttributeName = "id",
                AttributeType = "S",
            ),
        ],
        ProvisionedThroughput = ProvisionedThroughput(
            ReadCapacityUnits = Ref(p_config_table_rcu),
            WriteCapacityUnits = Ref(p_config_table_wcu)
        ),
        Tags = tags,
    ))

    t.add_resource(Table(
        "LocksTable",
        DeletionPolicy = "Retain",
        TableName = Ref(p_locks_table_name),
        KeySchema = [
            KeySchema(
                KeyType = "HASH",
                AttributeName = "id",
            ),
        ],
        AttributeDefinitions = [
            AttributeDefinition(
                AttributeName = "id",
                AttributeType = "S",
            ),
        ],
        ProvisionedThroughput = ProvisionedThroughput(
            ReadCapacityUnits = Ref(p_locks_table_rcu),
            WriteCapacityUnits = Ref(p_locks_table_wcu)
        ),
        Tags = tags,
    ))

    t.add_resource(Table(
        "SessionsTable",
        DeletionPolicy = "Retain",
        TableName = Ref(p_sessions_table_name),
        KeySchema = [
            KeySchema(
                KeyType = "HASH",
                AttributeName = "id",
            ),
        ],
        AttributeDefinitions = [
            AttributeDefinition(
                AttributeName = "id",
                AttributeType = "S",
            ),
        ],
        ProvisionedThroughput = ProvisionedThroughput(
            ReadCapacityUnits = Ref(p_sessions_table_rcu),
            WriteCapacityUnits = Ref(p_sessions_table_wcu)
        ),
        TimeToLiveSpecification = TimeToLiveSpecification(
            Enabled = True,
            AttributeName = "ttlTime",
        ),
        Tags = tags,
    ))

    t.add_resource(Table(
        "ExecutionsTable",
        DeletionPolicy = "Retain",
        TableName = Ref(p_executions_table_name),
        KeySchema = [
            KeySchema(
                KeyType = "HASH",
                AttributeName = "repoId",
            ),
            KeySchema(
                KeyType = "RANGE",
                AttributeName = "executionId",
            ),
        ],
        AttributeDefinitions = [
            AttributeDefinition(
                AttributeName = "repoId",
                AttributeType = "S",
            ),
            AttributeDefinition(
                AttributeName = "executionId",
                AttributeType = "S",
            ),
            AttributeDefinition(
                AttributeName = "createTime",
                AttributeType = "S",
            ),
        ],
        ProvisionedThroughput = ProvisionedThroughput(
            ReadCapacityUnits = Ref(p_executions_table_rcu),
            WriteCapacityUnits = Ref(p_executions_table_wcu)
        ),
        Tags = tags,
        GlobalSecondaryIndexes = [
            GlobalSecondaryIndex(
                IndexName = "search-repoId-createTime-index",
                KeySchema = [
                    KeySchema(
                        KeyType = "HASH",
                        AttributeName = "repoId",
                    ),
                    KeySchema(
                        KeyType = "RANGE",
                        AttributeName = "createTime",
                    ),
                ],
                Projection = Projection(
                    NonKeyAttributes = [
                        "repoId",
                        "executionId",
                        "createTime",
                        "updateTime",
                        "status",
                        "conclusion",
                        "conclusionTime",
                        "meta",
                    ],
                    ProjectionType = "INCLUDE",
                ),
                ProvisionedThroughput = ProvisionedThroughput(
                    ReadCapacityUnits = Ref(p_executions_search_indexes_rcu),
                    WriteCapacityUnits = Ref(p_executions_search_indexes_wcu),
                ),
            ),
            GlobalSecondaryIndex(
                IndexName = "search-repoId-executionId-index",
                KeySchema = [
                    KeySchema(
                        KeyType = "HASH",
                        AttributeName = "repoId",
                    ),
                    KeySchema(
                        KeyType = "RANGE",
                        AttributeName = "executionId",
                    ),
                ],
                Projection = Projection(
                    NonKeyAttributes = [
                        "repoId",
                        "executionId",
                        "createTime",
                        "updateTime",
                        "status",
                        "conclusion",
                        "conclusionTime",
                        "meta",
                    ],
                    ProjectionType = "INCLUDE",
                ),
                ProvisionedThroughput = ProvisionedThroughput(
                    ReadCapacityUnits = Ref(p_executions_search_indexes_rcu),
                    WriteCapacityUnits = Ref(p_executions_search_indexes_wcu),
                ),
            ),
        ],
    ))

    return t
Beispiel #7
0
     AttributeType='S',
 ), AttributeDefinition(
     AttributeName='upvotes',
     AttributeType='N',
 )],
 KeySchema=[KeySchema(
     AttributeName='videoId',
     KeyType='HASH',
 )],
 GlobalSecondaryIndexes=[GlobalSecondaryIndex(
     IndexName='lastModifiedInState',
     KeySchema=[KeySchema(
         AttributeName='videoState',
         KeyType='HASH',
     ), KeySchema(
         AttributeName='lastModified',
         KeyType='RANGE',
     )],
     Projection=Projection(
         ProjectionType='ALL',
     ),
 ), GlobalSecondaryIndex(
     IndexName='upvotedInState',
     KeySchema=[KeySchema(
         AttributeName='videoState',
         KeyType='HASH',
     ), KeySchema(
         AttributeName='upvotes',
         KeyType='RANGE',
     )],
     Projection=Projection(
Beispiel #8
0
          ],
          KeySchema=[
              KeySchema(AttributeName=Ref(segmentSetAnswersTableHashkeyName),
                        KeyType="HASH")
          ],
          ProvisionedThroughput=ProvisionedThroughput(
              ReadCapacityUnits=Ref(readunits),
              WriteCapacityUnits=Ref(writeunits)),
          PointInTimeRecoverySpecification=PointInTimeRecoverySpecification(
              PointInTimeRecoveryEnabled=True),
          GlobalSecondaryIndexes=[
              GlobalSecondaryIndex(IndexName="sourceLanguage",
                                   KeySchema=[
                                       KeySchema(
                                           AttributeName="sourceLanguage",
                                           KeyType="HASH")
                                   ],
                                   ProvisionedThroughput=ProvisionedThroughput(
                                       ReadCapacityUnits=Ref(readunits),
                                       WriteCapacityUnits=Ref(writeunits)),
                                   Projection=Projection(ProjectionType="ALL"))
          ],
          Tags=Tags(app="gap-fill-evaluation", stage=Ref(stage)),
          TableName=Join("-", ["SegmentSetAnswersDynamoDBTable",
                               Ref(stage)])))

t.add_output(
    Output(
        "SegmentTableName",
        Value=Ref(segmentDynamoDBTable),
        Description="Table name of the newly created DynamoDB table",
    ))