Creating the first table
In the previous chapter, we created an API authorizer that does not have any underlying data layer. Now we will create two DynamoDB tables, which are User
and Token
tables. As per their names, these tables will store our user list and access tokens, respectively.
Now let's add this block to our CloudFormation template's Resources
section in order to create our UserTable
table:
"UserTable": { "Type": "AWS::DynamoDB::Table", "Properties": { "AttributeDefinitions": [ { "AttributeName": "UserId", "AttributeType": "S" } ], "KeySchema": [ { "AttributeName": "UserId", "KeyType": "HASH" } ], "ProvisionedThroughput": { "ReadCapacityUnits": 1, "WriteCapacityUnits": 1 } } }
If we analyze the definition, we can see that we define the UserId
attribute as S
, which means string. This might seem surprising and you might ask why we do not use numeric values. Our UserId...