deploy/classic/dynamodb.md
:::info Legacy Documentation
You are viewing legacy documentation for Deno Deploy Classic. We recommend migrating to the new <a href="/deploy/">Deno Deploy</a> platform.
:::
Amazon DynamoDB is a fully managed NoSQL database. To persist data to DynamoDB, follow the steps below:
The tutorial assumes that you have an AWS and Deno Deploy Classic account.
The first step in the process is to generate AWS credentials to programmatically access DynamoDB.
Generate Credentials:
denamo), and select Programmatic access type.AmazonDynamoDBFullAccess and select it.Next, let's create a project in Deno Deploy Classic and set it up with the requisite environment variables:
AWS_ACCESS_KEY_ID - Use the value that's available under Access key ID
column in the downloaded CSV.AWS_SECRET_ACCESS_KEY - Use the value that's available under Secret access
key column in the downloaded CSV.AWS has an official SDK that works with browsers. As most Deno Deploy's APIs are similar to browsers', the same SDK works with Deno Deploy. To use the SDK in Deno, import from a cdn like below and create a client:
import {
DynamoDBClient,
GetItemCommand,
PutItemCommand,
} from "https://esm.sh/@aws-sdk/client-dynamodb?dts";
// Create a client instance by providing your region information.
// The credentials are automatically obtained from environment variables which
// we set during our project creation step on Deno Deploy, so we don't have to
// pass them manually here.
const client = new ApiFactory().makeNew(DynamoDB);
serve({
"/songs": handleRequest,
});
async function handleRequest(request) {
// async/await.
try {
const data = await client.send(command);
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}
}
Once you have finished writing your application, you can deploy it on Deno Deploy Classic.
To do this, go back to your project page at
https://dash.deno.com/projects/<project-name>.
You should see a couple of options to deploy:
deployctl
deployctl deploy --project=<project-name> <application-file-name>
Unless you want to add a build step, we recommend that you select the Github integration.
For more details on the different ways to deploy on Deno Deploy Classic and the different configuration options, read here.