Just like the previous chapter, we are going to be using AWS CDK in our SST app to create an S3 bucket.

We’ll be adding to the StorageStack that we created.

Add to the Stack

Add the following above the sst.Table definition in lib/StorageStack.js.

// Create an S3 bucket
this.bucket = new sst.Bucket(this, "Uploads");

This creates a new S3 bucket using the SST Bucket construct.

Also, find the following line in lib/StorageStack.js.

// Public reference to the table
table;

And add the following above it.

// Public reference to the bucket
bucket;

As the comment says, we want to have a public reference to the S3 bucket.

Deploy the App

If you switch over to your terminal, you’ll notice that you are being prompted to redeploy your changes. Go ahead and hit ENTER.

Note that, you’ll need to have sst start running for this to happen. If you had previously stopped it, then running npx sst start will deploy your changes again.

You should see that the storage stack has been updated.

Stack dev-notes-storage
  Status: deployed

Commit the Changes

Let’s commit and push our changes to GitHub.

$ git add .
$ git commit -m "Adding a storage stack"
$ git push

Next, let’s create the API for our notes app.