[{"data":1,"prerenderedAt":166},["ShallowReactive",2],{"content-svc-dynamodb-guides-knowledge-portal-howdoi_1":3},{"markdown":4,"frontMatterAttributes":5,"bodyRaw":23,"menu":24,"menuType":163,"isCollapseableMenu":27,"nextDocItem":62,"previousDocItem":30,"contributorPaths":164,"contentName":165,"slug":59,"readingTime":56},"\u003Cp>\u003Ca href=\"https:\u002F\u002Faws.amazon.com\u002Fcdk\u002F\">AWS Cloud Development Kit (CDK)\u003C\u002Fa> allows you to define cloud infrastructure in code and provision it through AWS CloudFormation. It uses familiar programming languages, including JavaScript, TypeScript, Python, C#, and Java.\u003C\u002Fp>\n\u003Cp>The following is an example of how to create an Amazon DynamoDB table with AWS CDK using Python.\nFirst, ensure that you have installed the necessary AWS CDK library for DynamoDB. You can do this with the following command:\u003C\u002Fp>\n\u003Cp>\u003Ccode>pip install aws-cdk.aws-dynamodb\u003C\u002Fcode>\u003C\u002Fp>\n\u003Cp>Then, use the following Python code to define a new DynamoDB table in your CDK stack:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-python\">from aws_cdk import core as cdk\nfrom aws_cdk import aws_dynamodb as dynamodb\n\n\nclass MyCdkStack(cdk.Stack):\n\n    def __init__(self, scope: cdk.Construct, id: str, **kwargs) -&gt; None:\n        super().__init__(scope, id, **kwargs)\n\n        # Create a new DynamoDB table\n        dynamodb.Table(self, &quot;MyTable&quot;,\n            partition_key=dynamodb.Attribute(\n                name=&quot;id&quot;,\n                type=dynamodb.AttributeType.STRING\n            ),\n            sort_key=dynamodb.Attribute(\n                name=&quot;timestamp&quot;,\n                type=dynamodb.AttributeType.STRING\n            ),\n            table_name=&quot;MyTable&quot;,\n            billing_mode=dynamodb.BillingMode.PROVISIONED,\n            read_capacity=5,\n            write_capacity=5,\n            removal_policy=cdk.RemovalPolicy.RETAIN,\n        )\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>This Python code creates a new DynamoDB table named MyTable with a string partition key id a string sort key timestamp. The table will use provisioned capacity mode with 5 RCU and 5 WCU. The removal_policy is set to RemovalPolicy.RETAIN, meaning that if the CDK stack is destroyed, the DynamoDB table will not be deleted.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Deploying CDK\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>You can deploy your CDK stack using the following command:\u003C\u002Fp>\n\u003Cp>\u003Ccode>cdk deploy\u003C\u002Fcode>\u003C\u002Fp>\n\u003Cp>This command will create a CloudFormation stack which will create your DynamoDB table.\u003C\u002Fp>\n",{"title":6,"order":7,"resources":8},"How do I create a table with CDK?",2,[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","[AWS Cloud Development Kit (CDK)](https:\u002F\u002Faws.amazon.com\u002Fcdk\u002F) allows you to define cloud infrastructure in code and provision it through AWS CloudFormation. It uses familiar programming languages, including JavaScript, TypeScript, Python, C#, and Java.\n\nThe following is an example of how to create an Amazon DynamoDB table with AWS CDK using Python.\nFirst, ensure that you have installed the necessary AWS CDK library for DynamoDB. You can do this with the following command:\n\n`pip install aws-cdk.aws-dynamodb`\n\nThen, use the following Python code to define a new DynamoDB table in your CDK stack:\n\n```python\nfrom aws_cdk import core as cdk\nfrom aws_cdk import aws_dynamodb as dynamodb\n\n\nclass MyCdkStack(cdk.Stack):\n\n    def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:\n        super().__init__(scope, id, **kwargs)\n\n        # Create a new DynamoDB table\n        dynamodb.Table(self, \"MyTable\",\n            partition_key=dynamodb.Attribute(\n                name=\"id\",\n                type=dynamodb.AttributeType.STRING\n            ),\n            sort_key=dynamodb.Attribute(\n                name=\"timestamp\",\n                type=dynamodb.AttributeType.STRING\n            ),\n            table_name=\"MyTable\",\n            billing_mode=dynamodb.BillingMode.PROVISIONED,\n            read_capacity=5,\n            write_capacity=5,\n            removal_policy=cdk.RemovalPolicy.RETAIN,\n        )\n```\n\nThis Python code creates a new DynamoDB table named MyTable with a string partition key id a string sort key timestamp. The table will use provisioned capacity mode with 5 RCU and 5 WCU. The removal_policy is set to RemovalPolicy.RETAIN, meaning that if the CDK stack is destroyed, the DynamoDB table will not be deleted.\n\n**Deploying CDK**\n\nYou can deploy your CDK stack using the following command:\n\n`cdk deploy`\n\nThis command will create a CloudFormation stack which will create your DynamoDB table.\n\n\n\n",[25,47,60,74,87,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":27,"content":49},"How do I?",[50],{"title":6,"order":7,"resources":51,"time":56,"path":57,"id":58,"link":59},[52,53,54,55],{"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":61},[62],{"title":63,"order":64,"resources":65,"time":70,"path":71,"id":72,"link":73},"How do I handle versioning of items in DynamoDB?",3,[66,67,68,69],{"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":75},[76],{"title":77,"order":78,"resources":79,"time":56,"path":84,"id":85,"link":86},"How do I implement full-text search in DynamoDB?",4,[80,81,82,83],{"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":28,"content":88},[89],{"title":90,"order":91,"resources":92,"time":56,"path":97,"id":98,"link":99},"How do I create a table with CloudFormation?",5,[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":70,"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":70,"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":56,"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":56,"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":70,"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",1792665265530]