[{"data":1,"prerenderedAt":166},["ShallowReactive",2],{"content-svc-dynamodb-guides-knowledge-portal-howdoi_4":3},{"markdown":4,"frontMatterAttributes":5,"bodyRaw":23,"menu":24,"menuType":163,"isCollapseableMenu":27,"nextDocItem":103,"previousDocItem":78,"contributorPaths":164,"contentName":165,"slug":99,"readingTime":58},"\u003Cp>\u003Cstrong>Creating a template\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>Creating a DynamoDB table with CloudFormation involves defining a template YAML or JSON file that specifies the properties for your AWS resources. The YAML example below creates a table with an attribute (&quot;id&quot;) as its partition key and attribute (“date”) as its sort key:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>Resources:\n  MyDynamoDBTable:\n    Type: &#39;AWS::DynamoDB::Table&#39;\n    Properties:\n    TableName: &#39;MyTable&#39;\n    AttributeDefinitions:\n\n    AttributeName: &#39;id&#39;\n    AttributeType: &#39;S&#39;\n\n    AttributeName: &#39;date&#39;\n    AttributeType: &#39;S&#39;\n    KeySchema:\n\n    AttributeName: &#39;id&#39;\n    KeyType: &#39;HASH&#39;\n\n    AttributeName: &#39;date&#39;\n    KeyType: &#39;RANGE&#39;\n    ProvisionedThroughput:\n    ReadCapacityUnits: &#39;5&#39;\n    WriteCapacityUnits: &#39;5&#39;\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Here is what the properties represent:\u003C\u002Fp>\n\u003Col>\n\u003Cli>\u003Ccode>Resources\u003C\u002Fcode>: This is where you declare AWS resources.\u003C\u002Fli>\n\u003Cli>\u003Ccode>MyDynamoDBTable\u003C\u002Fcode>: This is a logical name for your DynamoDB table inside this template.\u003C\u002Fli>\n\u003Cli>\u003Ccode>Type\u003C\u002Fcode>: This is the type of resource you&#39;re creating. For a DynamoDB table, use \u003Ccode>AWS::DynamoDB::Table\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>\u003Ccode>Properties\u003C\u002Fcode>: These are the properties of the resource.\u003C\u002Fli>\n\u003Cli>\u003Ccode>TableName\u003C\u002Fcode>: This is the name of the table. Replace &#39;MyTable&#39; with the name you want to give to your table.\u003C\u002Fli>\n\u003Cli>\u003Ccode>AttributeDefinitions\u003C\u002Fcode>: This is where you define all attributes for the table.\u003C\u002Fli>\n\u003Cli>\u003Ccode>AttributeName\u003C\u002Fcode> and \u003Ccode>AttributeType\u003C\u002Fcode>: These are the name and the type of the attribute. In this example, the attributes named &#39;id&#39; and ‘date’ are both type &#39;S&#39; (string).\u003C\u002Fli>\n\u003Cli>\u003Ccode>KeySchema\u003C\u002Fcode>: This is where you define the primary key of the table. You specify an attribute to act as the primary key of the table. In this example, &#39;id&#39; is the primary key (or ‘hash’ key) and ‘date’ is the sort key (or ‘range’ key).\u003C\u002Fli>\n\u003Cli>\u003Ccode>ProvisionedThroughput\u003C\u002Fcode>: This is where you set the \u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002Famazondynamodb\u002Flatest\u002Fdeveloperguide\u002FHowItWorks.ReadWriteCapacityMode.html\">read and write capacity\u003C\u002Fa> units for the table. This example creates a basic DynamoDB table with provisioned throughput. Depending on your use case, you might want to specify additional properties such as \u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002Famazondynamodb\u002Flatest\u002Fdeveloperguide\u002FSecondaryIndexes.html\">secondary indexes\u003C\u002Fa>, stream specifications, \u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002Famazondynamodb\u002Flatest\u002Fdeveloperguide\u002FTTL.html\">Time to Live (TTL)\u003C\u002Fa> attributes, etc.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>\u003Cstrong>Deploying the template\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>You can use AWS Management Console, the AWS CLI, or AWS SDKs to deploy a CloudFormation template. The following command could be used to deploy the above example, after it had been saved locally as \u003Ccode>dynamodb-table.yml\u003C\u002Fcode>, using the AWS CLI.\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-bash\">aws cloudformation create-stack --stack-name my-stack-name --template-body file:\u002F\u002Fdynamodb-table.yml\n\u003C\u002Fcode>\u003C\u002Fpre>\n",{"title":6,"order":7,"resources":8},"How do I create a table with CloudFormation?",5,[9,13,16,19],{"link":10,"text":11,"type":12},"https:\u002F\u002Fdocs.aws.amazon.com\u002Famazondynamodb\u002Flatest\u002Fdeveloperguide\u002FIntroduction.html","DynamoDB developer guides","document",{"link":14,"type":12,"text":15},"https:\u002F\u002Fdocs.aws.amazon.com\u002Famazondynamodb\u002Flatest\u002FAPIReference\u002FAPI_Operations_Amazon_DynamoDB.html","DynamoDB API reference",{"link":17,"type":12,"text":18},"https:\u002F\u002Faws.amazon.com\u002Fprescriptive-guidance\u002F?apg-all-cards.sort-by=item.additionalFields.contentTitle&apg-all-cards.sort-order=asc&awsf.apg-new-filter=*all&awsf.apg-content-type-filter=*all&awsf.apg-code-filter=*all&awsf.apg-category-filter=categories%23serverless&awsf.apg-rtype-filter=*all&awsf.apg-isv-filter=*all&awsf.apg-product-filter=*all&awsf.apg-env-filter=*all&apg-all-cards.q=DynamoDB&apg-all-cards.q_operator=AND","DynamoDB prescriptive guides",{"link":20,"type":21,"text":22},"https:\u002F\u002Fexplore.skillbuilder.aws\u002Flearn\u002Fexternal-ecommerce;view=signin;redirectURL=?ctldoc-catalog-0=se-DynamoDb","Training","DynamoDB training","**Creating a template**\n\nCreating a DynamoDB table with CloudFormation involves defining a template YAML or JSON file that specifies the properties for your AWS resources. The YAML example below creates a table with an attribute (\"id\") as its partition key and attribute (“date”) as its sort key:\n\n```\nResources:\n  MyDynamoDBTable:\n    Type: 'AWS::DynamoDB::Table'\n    Properties:\n    TableName: 'MyTable'\n    AttributeDefinitions:\n\n    AttributeName: 'id'\n    AttributeType: 'S'\n\n    AttributeName: 'date'\n    AttributeType: 'S'\n    KeySchema:\n\n    AttributeName: 'id'\n    KeyType: 'HASH'\n\n    AttributeName: 'date'\n    KeyType: 'RANGE'\n    ProvisionedThroughput:\n    ReadCapacityUnits: '5'\n    WriteCapacityUnits: '5'\n```\n\nHere is what the properties represent:\n\n1. `Resources`: This is where you declare AWS resources.\n2. `MyDynamoDBTable`: This is a logical name for your DynamoDB table inside this template.\n3. `Type`: This is the type of resource you're creating. For a DynamoDB table, use `AWS::DynamoDB::Table`.\n4. `Properties`: These are the properties of the resource.\n5. `TableName`: This is the name of the table. Replace 'MyTable' with the name you want to give to your table.\n6. `AttributeDefinitions`: This is where you define all attributes for the table.\n7. `AttributeName` and `AttributeType`: These are the name and the type of the attribute. In this example, the attributes named 'id' and ‘date’ are both type 'S' (string).\n8. `KeySchema`: This is where you define the primary key of the table. You specify an attribute to act as the primary key of the table. In this example, 'id' is the primary key (or ‘hash’ key) and ‘date’ is the sort key (or ‘range’ key).\n9. `ProvisionedThroughput`: This is where you set the [read and write capacity](https:\u002F\u002Fdocs.aws.amazon.com\u002Famazondynamodb\u002Flatest\u002Fdeveloperguide\u002FHowItWorks.ReadWriteCapacityMode.html) units for the table. This example creates a basic DynamoDB table with provisioned throughput. Depending on your use case, you might want to specify additional properties such as [secondary indexes](https:\u002F\u002Fdocs.aws.amazon.com\u002Famazondynamodb\u002Flatest\u002Fdeveloperguide\u002FSecondaryIndexes.html), stream specifications, [Time to Live (TTL)](https:\u002F\u002Fdocs.aws.amazon.com\u002Famazondynamodb\u002Flatest\u002Fdeveloperguide\u002FTTL.html) attributes, etc.\n\n**Deploying the template**\n\nYou can use AWS Management Console, the AWS CLI, or AWS SDKs to deploy a CloudFormation template. The following command could be used to deploy the above example, after it had been saved locally as `dynamodb-table.yml`, using the AWS CLI.\n\n```bash\naws cloudformation create-stack --stack-name my-stack-name --template-body file:\u002F\u002Fdynamodb-table.yml\n```\n\n\n\n",[25,47,62,76,89,100,114,127,139,151],{"title":26,"collapsible":27,"isCollapsed":28,"content":29},"Learn",false,true,[30],{"title":31,"order":32,"callout":33,"resources":38,"time":43,"path":44,"id":45,"link":46},"Getting started with Amazon DynamoDB",1,{"title":34,"description":35,"image":36,"link":37},"DynamoDB Developer resources","Watch short bite size videos created by Amazon DynamoDB experts on specific topics like backup and restore, indexes, pre-scaling your on-demand tables and many more.. ","\u002Fassets\u002Fexternal\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fassets\u002Fnugets.png","https:\u002F\u002Fwww.youtube.com\u002Fplaylist?list=PLhr1KZpdzukemNOO71Hca0GpjG0QmXwEd",[39,40,41,42],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"1 min","getting-started","getting-started.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fgetting-started",{"title":48,"collapsible":27,"isCollapsed":28,"content":49},"How do I?",[50],{"title":51,"order":52,"resources":53,"time":58,"path":59,"id":60,"link":61},"How do I create a table with CDK?",2,[54,55,56,57],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"2 min","howdoi_1","howdoi_1.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fhowdoi_1",{"title":-1,"collapsible":27,"isCollapsed":28,"content":63},[64],{"title":65,"order":66,"resources":67,"time":72,"path":73,"id":74,"link":75},"How do I handle versioning of items in DynamoDB?",3,[68,69,70,71],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"3 min","howdoi_2","howdoi_2.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fhowdoi_2",{"title":-1,"collapsible":27,"isCollapsed":28,"content":77},[78],{"title":79,"order":80,"resources":81,"time":58,"path":86,"id":87,"link":88},"How do I implement full-text search in DynamoDB?",4,[82,83,84,85],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"howdoi_3","howdoi_3.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fhowdoi_3",{"title":-1,"collapsible":27,"isCollapsed":27,"content":90},[91],{"title":6,"order":7,"resources":92,"time":58,"path":97,"id":98,"link":99},[93,94,95,96],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"howdoi_4","howdoi_4.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fhowdoi_4",{"title":101,"collapsible":27,"isCollapsed":28,"content":102},"Migrate to Amazon DynamoDB",[103],{"title":104,"order":105,"resources":106,"time":72,"path":111,"id":112,"link":113},"Why migrate to DynamoDB",6,[107,108,109,110],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"migrations_1","migrations_1.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fmigrations_1",{"title":-1,"collapsible":27,"isCollapsed":28,"content":115},[116],{"title":117,"order":118,"resources":119,"time":72,"path":124,"id":125,"link":126},"Migration planning",7,[120,121,122,123],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"migrations_2","migrations_2.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fmigrations_2",{"title":-1,"collapsible":27,"isCollapsed":28,"content":128},[129],{"title":130,"order":32,"resources":131,"time":58,"path":136,"id":137,"link":138},"DynamoDB key concepts",[132,133,134,135],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"migrations_3","migrations_3.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fmigrations_3",{"title":-1,"collapsible":27,"isCollapsed":28,"content":140},[141],{"title":142,"order":32,"resources":143,"time":58,"path":148,"id":149,"link":150},"Difference between relational and NoSQL data model",[144,145,146,147],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"migrations_4","migrations_4.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fmigrations_4",{"title":-1,"collapsible":27,"isCollapsed":28,"content":152},[153],{"title":154,"order":32,"resources":155,"time":72,"path":160,"id":161,"link":162},"Migration strategies",[156,157,158,159],{"link":10,"text":11,"type":12},{"link":14,"type":12,"text":15},{"link":17,"type":12,"text":18},{"link":20,"type":21,"text":22},"migrations_5","migrations_5.md","\u002Fcontent\u002Fservice\u002Fdynamodb\u002Fguides\u002Fknowledge-portal\u002Fmigrations_5","LIST",[],"DynamoDB knowledge portal",1792578866742]