> For the complete documentation index, see [llms.txt](https://tricks.bodik.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tricks.bodik.tech/infrastructure/aws/sam/schema-to-create-a-resource-of-dynamodb-table-using-sam.md). Agents can also search and read this documentation through its [MCP server](https://tricks.bodik.tech/~gitbook/mcp).

# Schema to create a resource of DynamoDB table using SAM

An example of how to declare DynamoDB table in template.yaml of your SAM configuration

```yaml
  YourDynamoDBTable:
    Type: AWS::DynamoDB::Table
    Properties: 
      TableName: 'your-table-name'
      AttributeDefinitions: 
        - AttributeName: yourAttribute1
          AttributeType: S
        - AttributeName: yourAttribute2
          AttributeType: S
      KeySchema: 
        - AttributeName: yourAttribute1
          KeyType: HASH
        - AttributeName: yourAttribute2
          KeyType: RANGE
      ProvisionedThroughput: 
        ReadCapacityUnits: 1
        WriteCapacityUnits: 1
```

More info on the available properties is in the next resource. I use CDK documentation, as I have not found related to SAM resources.

{% embed url="<https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-dynamodb.Table.html>" %}
