Skip to content

Commit 325e346

Browse files
committed
2 parents 1ccde9b + f3507cf commit 325e346

File tree

51 files changed

+139
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+139
-139
lines changed

_chapters/add-an-api-to-create-a-note.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ We'll first add an API to create a note. This API will take the note object as t
1414

1515
### Creating a Stack
1616

17-
{%change%} Create a new file in `lib/ApiStack.js` and add the following.
17+
{%change%} Create a new file in `stacks/ApiStack.js` and add the following.
1818

1919
``` js
2020
import * as sst from "@serverless-stack/resources";
@@ -72,7 +72,7 @@ We are doing a couple of things of note here.
7272
Let's add this new stack to the rest of our app.
7373

7474

75-
{%change%} In `lib/index.js`, import the API stack at the top.
75+
{%change%} In `stacks/index.js`, import the API stack at the top.
7676

7777
``` js
7878
import ApiStack from "./ApiStack";

_chapters/add-an-api-to-delete-a-note.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ This makes a DynamoDB `delete` call with the `userId` & `noteId` key to delete t
4040

4141
Let's add a new route for the delete note API.
4242

43-
{%change%} Add the following below the `PUT /notes{id}` route in `lib/ApiStack.js`.
43+
{%change%} Add the following below the `PUT /notes{id}` route in `stacks/ApiStack.js`.
4444

4545
``` js
4646
"DELETE /notes/{id}": "src/delete.main",

_chapters/add-an-api-to-get-a-note.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This follows exactly the same structure as our previous `create.js` function. Th
4444

4545
Let's add a new route for the get note API.
4646

47-
{%change%} Add the following below the `POST /notes` route in `lib/ApiStack.js`.
47+
{%change%} Add the following below the `POST /notes` route in `stacks/ApiStack.js`.
4848

4949
``` js
5050
"GET /notes/{id}": "src/get.main",

_chapters/add-an-api-to-handle-billing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Clearly, our serverless infrastructure might be cheap but our service isn't!
7777

7878
Let's add a new route for our billing API.
7979

80-
{%change%} Add the following below the `DELETE /notes/{id}` route in `lib/ApiStack.js`.
80+
{%change%} Add the following below the `DELETE /notes/{id}` route in `stacks/ApiStack.js`.
8181

8282
``` js
8383
"POST /billing": "src/billing.main",

_chapters/add-an-api-to-list-all-the-notes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This is pretty much the same as our `get.js` except we use a condition to only r
4545

4646
Let's add the route for this new endpoint.
4747

48-
{%change%} Add the following above the `POST /notes` route in `lib/ApiStack.js`.
48+
{%change%} Add the following above the `POST /notes` route in `stacks/ApiStack.js`.
4949

5050
``` js
5151
"GET /notes": "src/list.main",

_chapters/add-an-api-to-update-a-note.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ This should look similar to the `create.js` function. Here we make an `update` D
5252

5353
Let's add a new route for the get note API.
5454

55-
{%change%} Add the following below the `GET /notes/{id}` route in `lib/ApiStack.js`.
55+
{%change%} Add the following below the `GET /notes/{id}` route in `stacks/ApiStack.js`.
5656

5757
``` js
5858
"PUT /notes/{id}": "src/update.main",

_chapters/adding-auth-to-our-serverless-app.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Setting this all up can be pretty complicated in CDK. SST has a simple [`Auth`](
1717

1818
### Create a Stack
1919

20-
{%change%} Add the following to a new file in `lib/AuthStack.js`.
20+
{%change%} Add the following to a new file in `stacks/AuthStack.js`.
2121

2222
``` js
2323
import * as iam from "@aws-cdk/aws-iam";
@@ -115,7 +115,7 @@ One other thing to note is that, the federated identity id is a UUID that is ass
115115

116116
Let's add this stack to our app.
117117

118-
{%change%} Replace the `main` function in `lib/index.js` with this.
118+
{%change%} Replace the `main` function in `stacks/index.js` with this.
119119

120120
``` js
121121
export default function main(app) {
@@ -144,7 +144,7 @@ import AuthStack from "./AuthStack";
144144

145145
We also need to enable authentication in our API.
146146

147-
{%change%} Add the following above the `defaultFunctionProps: {` line in `lib/ApiStack.js`.
147+
{%change%} Add the following above the `defaultFunctionProps: {` line in `stacks/ApiStack.js`.
148148

149149
``` js
150150
defaultAuthorizationType: "AWS_IAM",

_chapters/auth-in-serverless-apps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ For reference, here is what we have so far.
2626

2727
Our users make a request to our serverless API. It starts by hitting our API Gateway endpoint. And depending on the endpoint we request, it'll forward that request to the appropriate Lambda function.
2828

29-
In terms of access control, our API Gateway endpoint is allowed to invoke the Lambda functions we listed in the routes of our `lib/ApiStack.js`. And if you'll recall, our Lambda function are allowed to connect to our DynamoDB tables.
29+
In terms of access control, our API Gateway endpoint is allowed to invoke the Lambda functions we listed in the routes of our `stacks/ApiStack.js`. And if you'll recall, our Lambda function are allowed to connect to our DynamoDB tables.
3030

3131
``` js
3232
// Allow the API to access the table

_chapters/create-a-dynamodb-table-in-sst.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ We are now going to start creating our infrastructure in [SST]({{ site.sst_githu
1313

1414
### Create a Stack
1515

16-
{%change%} Add the following to a new file in `lib/StorageStack.js`.
16+
{%change%} Add the following to a new file in `stacks/StorageStack.js`.
1717

1818
``` js
1919
import * as sst from "@serverless-stack/resources";
@@ -69,7 +69,7 @@ This'll allow us to reference this resource in our other stacks.
6969

7070
Now let's add this stack to our app.
7171

72-
{%change%} Replace the `lib/index.js` with this.
72+
{%change%} Replace the `stacks/index.js` with this.
7373

7474
``` js
7575
import StorageStack from "./StorageStack";
@@ -92,7 +92,7 @@ Stack dev-notes-storage
9292
Status: deployed
9393
```
9494

95-
The `Stack` name above of `dev-notes-storage` is a string derived from your `${stageName}-${appName}-${stackName}`. Your `appName` is defined in the `name` field of your `sst.json` file and your `stackName` is the label you choose for your stack in `lib/index.js'.
95+
The `Stack` name above of `dev-notes-storage` is a string derived from your `${stageName}-${appName}-${stackName}`. Your `appName` is defined in the `name` field of your `sst.json` file and your `stackName` is the label you choose for your stack in `stacks/index.js'.
9696

9797
### Remove Template Files
9898

@@ -101,7 +101,7 @@ There are a couple of files that came with our starter template, that we can now
101101
{%change%} Run the following in your project root.
102102

103103
``` bash
104-
$ rm lib/MyStack.js src/lambda.js
104+
$ rm stacks/MyStack.js src/lambda.js
105105
```
106106

107107
Now that our database has been created, let's create an S3 bucket to handle file uploads.

_chapters/create-a-hello-world-api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ comments_id: create-a-hello-world-api/2460
1010

1111
With our newly created [SST]({{ site.sst_github_repo }}) app, we are ready to deploy a simple _Hello World_ API.
1212

13-
In `lib/MyStack.js` you'll notice a API definition similar to this.
13+
In `stacks/MyStack.js` you'll notice a API definition similar to this.
1414

1515
``` js
1616
export default class MyStack extends sst.Stack {

_chapters/create-a-new-reactjs-app.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Now to use this package, we'll add it to our `package.json` scripts.
5959

6060
We are going to be deploying our React app to AWS. To do that we'll be using the SST [`ReactStaticSite`](https://docs.serverless-stack.com/constructs/ReactStaticSite) construct.
6161

62-
{%change%} Create a new file in `lib/FrontendStack.js` and add the following.
62+
{%change%} Create a new file in `stacks/FrontendStack.js` and add the following.
6363

6464
``` js
6565
import * as sst from "@serverless-stack/resources";
@@ -105,7 +105,7 @@ We are doing a couple of things of note here:
105105

106106
Let's add this new stack to the rest of our app.
107107

108-
{%change%} Replace the `main` function in `lib/index.js` with.
108+
{%change%} Replace the `main` function in `stacks/index.js` with.
109109

110110
``` js
111111
export default function main(app) {

_chapters/create-an-s3-bucket-in-sst.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ We'll be adding to the `StorageStack` that we created.
1515

1616
### Add to the Stack
1717

18-
{%change%} Add the following above the `sst.Table` definition in `lib/StorageStack.js`.
18+
{%change%} Add the following above the `sst.Table` definition in `stacks/StorageStack.js`.
1919

2020
``` js
2121
// Create an S3 bucket
@@ -24,7 +24,7 @@ this.bucket = new sst.Bucket(this, "Uploads");
2424

2525
This creates a new S3 bucket using the SST [`Bucket`](https://docs.serverless-stack.com/constructs/Bucket) construct.
2626

27-
Also, find the following line in `lib/StorageStack.js`.
27+
Also, find the following line in `stacks/StorageStack.js`.
2828

2929
``` js
3030
// Public reference to the table

_chapters/create-an-sst-app.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ By default our app will be deployed to an environment (or stage) called `dev` in
3333

3434
An SST app is made up of two parts.
3535

36-
1. `lib/` — App Infrastructure
36+
1. `stacks/` — App Infrastructure
3737

38-
The code that describes the infrastructure of your serverless app is placed in the `lib/` directory of your project. SST uses [AWS CDK]({% link _chapters/what-is-aws-cdk.md %}), to create the infrastructure.
38+
The code that describes the infrastructure of your serverless app is placed in the `stacks/` directory of your project. SST uses [AWS CDK]({% link _chapters/what-is-aws-cdk.md %}), to create the infrastructure.
3939

4040
2. `src/` — App Code
4141

_chapters/custom-domains-for-react-apps-on-aws.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ comments_id: custom-domains-for-react-apps-on-aws/2463
1010

1111
In the [previous chapter we configured a custom domain for our serverless API]({% link _chapters/custom-domains-in-serverless-apis.md %}). Now let's do the same for our frontend React.js app.
1212

13-
{%change%} In the `lib/FrontendStack.js` add the following below the `new sst.ReactStaticSite(` line.
13+
{%change%} In the `stacks/FrontendStack.js` add the following below the `new sst.ReactStaticSite(` line.
1414

1515
``` js
1616
customDomain:
@@ -32,7 +32,7 @@ You won't need to set the `domainAlias` for the non-prod versions because we don
3232

3333
We need to use the custom domain URL of our API in our React app.
3434

35-
{%change%} Find the following line in `lib/FrontendStack.js`.
35+
{%change%} Find the following line in `stacks/FrontendStack.js`.
3636

3737
``` js
3838
REACT_APP_API_URL: api.url,
@@ -48,7 +48,7 @@ Note that, if you are going to use a custom domain locally, you might need to re
4848

4949
We also need to update the outputs of our frontend stack.
5050

51-
{%change%} Replace the `this.addOutputs` call at the bottom of `lib/FrontendStack.js` with this.
51+
{%change%} Replace the `this.addOutputs` call at the bottom of `stacks/FrontendStack.js` with this.
5252

5353
``` js
5454
this.addOutputs({

_chapters/custom-domains-in-serverless-apis.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ comments_id: custom-domains-in-serverless-apis/2464
1010

1111
In the [previous chapter]({% link _chapters/purchase-a-domain-with-route-53.md %}) we purchased a new domain on [Route 53](https://aws.amazon.com/route53/). Now let's use it for our serverless API.
1212

13-
{%change%} In your `lib/ApiStack.js` add the following above the `defaultAuthorizationType: "AWS_IAM",` line.
13+
{%change%} In your `stacks/ApiStack.js` add the following above the `defaultAuthorizationType: "AWS_IAM",` line.
1414

1515
``` js
1616
customDomain:
@@ -23,7 +23,7 @@ We could for example, base it on the stage name, `api-${scope.stage}.my-serverle
2323

2424
We also need to update the outputs of our API stack.
2525

26-
{%change%} Replace the `this.addOutputs` call at the bottom of `lib/ApiStack.js`.
26+
{%change%} Replace the `this.addOutputs` call at the bottom of `stacks/ApiStack.js`.
2727

2828
``` js
2929
this.addOutputs({

_chapters/deploy-a-serverless-app-with-dependencies.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The short version is that:
1818

1919
In our [resources repo]({{ site.backend_ext_resources_github_repo }}) we are using SST to deploy our CDK app. CDK internally keeps track of the dependencies between stacks.
2020

21-
Our `lib/index.js` looks like this.
21+
Our `stacks/index.js` looks like this.
2222

2323
``` javascript
2424
export default function main(app) {

_chapters/dynamically-generate-social-share-images-with-serverless.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ $ cd social-cards
8282

8383
The infrastructure in our app is defined using [CDK]({% link _chapters/what-is-aws-cdk.md %}). Currently we just have a simple API that invokes a Lambda function.
8484

85-
You can see this in `lib/MyStack.js`.
85+
You can see this in `stacks/MyStack.js`.
8686

8787
``` js
8888
// Create a HTTP API
@@ -174,7 +174,7 @@ The `encoded_title` is a [Base64 encoded](https://en.wikipedia.org/wiki/Base64)
174174

175175
We are going to use [Puppeteer](https://developers.google.com/web/tools/puppeteer) to take these screenshots. We'll be using [a publicly available Lambda Layer](https://github.com/shelfio/chrome-aws-lambda-layer) for it. It allows us to skip having to compile Puppeteer specifically for AWS Lambda.
176176

177-
So the API definition in `lib/MyStack.js` now looks like this.
177+
So the API definition in `stacks/MyStack.js` now looks like this.
178178

179179
``` js
180180
const api = new sst.Api(this, "Api", {
@@ -408,7 +408,7 @@ If we visit our API multiple times, it takes a screenshot every time. This is bo
408408

409409
First, we'll create our S3 bucket.
410410

411-
In `lib/MyStack.js` above our API definition we have.
411+
In `stacks/MyStack.js` above our API definition we have.
412412

413413
``` js
414414
// Create S3 bucket to store generated images
@@ -541,7 +541,7 @@ Now if you load your API endpoint a couple of times, you'll notice it is much fa
541541

542542
To make our requests even faster we'll add a CDN in front of our API. We'll use [CloudFront](https://aws.amazon.com/cloudfront/) for this.
543543

544-
In `lib/MyStack.js` we'll define our CloudFront distribution.
544+
In `stacks/MyStack.js` we'll define our CloudFront distribution.
545545

546546
``` js
547547
// Create CloudFront Distribution
@@ -582,7 +582,7 @@ If you are looking to create a new domain, you can [follow this guide to purchas
582582

583583
Or if you have a domain hosted on another provider, [read this to migrate it to Route 53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/MigratingDNS.html).
584584

585-
We can do this in our `lib/MyStack.js` by adding this block above the CloudFront definition.
585+
We can do this in our `stacks/MyStack.js` by adding this block above the CloudFront definition.
586586

587587
``` js
588588
const rootDomain = "serverless-stack.com";
@@ -640,7 +640,7 @@ if (useCustomDomain) {
640640
}
641641
```
642642
643-
Make sure to check out the full `lib/MyStack.js` source here — [{{ page.repo | remove: "https://" }}/blob/main/lib/MyStack.js]({{ page.repo }}/blob/main/lib/MyStack.js)
643+
Make sure to check out the full `stacks/MyStack.js` source here — [{{ page.repo | remove: "https://" }}/blob/main/stacks/MyStack.js]({{ page.repo }}/blob/main/stacks/MyStack.js)
644644
645645
Now you can load our custom domain URL!
646646

_chapters/handle-cors-in-s3-for-file-uploads.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ In the notes app we are building, users will be uploading files to the bucket we
1212

1313
Let's enable CORS for our S3 bucket.
1414

15-
{%change%} Replace the following line in `lib/StorageStack.js`.
15+
{%change%} Replace the following line in `stacks/StorageStack.js`.
1616

1717
``` js
1818
this.bucket = new sst.Bucket(this, "Uploads");

_chapters/handling-secrets-in-sst.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Also, since we won't be committing this file to Git, we'll need to add this to o
3535

3636
Next, let's add these to our functions.
3737

38-
{%change%} Add the following below the `TABLE_NAME: table.tableName,` line in `lib/ApiStack.js`:
38+
{%change%} Add the following below the `TABLE_NAME: table.tableName,` line in `stacks/ApiStack.js`:
3939

4040
``` js
4141
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY,

_chapters/parameterize-serverless-resources-names.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ resources:
5151
5252
For CDK on the other hand we use [SST](https://github.com/serverless-stack/serverless-stack) to automatically parameterize our stack names. And use a helper method to parameterize specific resource names.
5353
54-
So for example in the `lib/index.js` file in our [resources repo]({{ site.backend_ext_resources_github_repo }}).
54+
So for example in the `stacks/index.js` file in our [resources repo]({{ site.backend_ext_resources_github_repo }}).
5555

5656
``` javascript
5757
export default function main(app) {
@@ -73,7 +73,7 @@ dev-notes-ext-infra-cognito
7373

7474
Where `dev` is the stage we are deploying to and `notes-ext-infra` is the name of our SST app, as specified in our `sst.json`.
7575

76-
For specific resources, such as CloudFormation exports, we use the `app.logicalPrefixedName` helper method. Here's an example from `lib/DynamoDBStack.js`.
76+
For specific resources, such as CloudFormation exports, we use the `app.logicalPrefixedName` helper method. Here's an example from `stacks/DynamoDBStack.js`.
7777

7878
``` javascript
7979
new CfnOutput(this, "TableName", {

_chapters/unexpected-errors-in-lambda-functions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const main = handler(async (event) => {
112112

113113
Now we'll set our Lambda function to use the lowest memory allowed.
114114

115-
{%change%} Add the following below the `defaultFunctionProps: {` line in your `lib/ApiStack.js`.
115+
{%change%} Add the following below the `defaultFunctionProps: {` line in your `stacks/ApiStack.js`.
116116

117117
``` js
118118
memorySize: 128,

_chapters/unit-tests-in-serverless.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Let's start by writing a test for the CDK infrastructure in our app. We are goin
2525
``` js
2626
import { expect, haveResource } from "@aws-cdk/assert";
2727
import * as sst from "@serverless-stack/resources";
28-
import StorageStack from "../lib/StorageStack";
28+
import StorageStack from "../stacks/StorageStack";
2929

3030
test("Test StorageStack", () => {
3131
const app = new sst.App();

_chapters/using-cognito-to-add-authentication-to-a-serverless-app.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ To understand this better we'll be referencing an example SST application on Git
2020

2121
This example SST app has a couple of key parts:
2222

23-
- **The `lib/` directory**: This contains the code that describes the infrastructure of your serverless app. It works by leveraging [AWS CDK](https://serverless-stack.com/chapters/what-is-aws-cdk.html) to create the infrastructure. This includes our API, our Cognito services, and our frontend static site.
23+
- **The `stacks/` directory**: This contains the code that describes the infrastructure of your serverless app. It works by leveraging [AWS CDK](https://serverless-stack.com/chapters/what-is-aws-cdk.html) to create the infrastructure. This includes our API, our Cognito services, and our frontend static site.
2424
- **The `src/` directory**: This is where the application code resides. The code that will run when your API is called.
2525
- **The `frontend/` directory**: This is where our frontend React.js application is. It'll be connecting to our APIs.
2626

@@ -43,7 +43,7 @@ Let’s start with looking at how to add Cognito User Pool to our app.
4343

4444
In the [previous chapter]({% link _chapters/how-to-add-authentication-to-a-serverless-app.md %}) we talked about the various parts of Cognito ([User Pools and Identity Pools]({% link _chapters/cognito-user-pool-vs-identity-pool.md %})).
4545

46-
SST makes it easy to add these to your application. In [`lib/MyStack.js`]({{ repo_url }}/lib/MyStack.js) you'll notice.
46+
SST makes it easy to add these to your application. In [`stacks/MyStack.js`]({{ repo_url }}/stacks/MyStack.js) you'll notice.
4747

4848
``` js
4949
// Create a Cognito User Pool to manage auth
@@ -112,7 +112,7 @@ new Auth(this, "Auth", {
112112

113113
### Adding an API
114114

115-
Now let's look at how we can use Cognito to secure our API. In [`lib/MyStack.js`]({{ repo_url }}/lib/MyStack.js) of our example, you'll notice our SST [`Api`](https://docs.serverless-stack.com/constructs/Api) definition.
115+
Now let's look at how we can use Cognito to secure our API. In [`stacks/MyStack.js`]({{ repo_url }}/stacks/MyStack.js) of our example, you'll notice our SST [`Api`](https://docs.serverless-stack.com/constructs/Api) definition.
116116

117117
``` js
118118
// Create an HTTP API
@@ -161,7 +161,7 @@ export async function handler() {
161161

162162
### Adding a React Static Site
163163

164-
We can now turn our attention to the frontend part of our application. In [`lib/MyStack.js`]({{ repo_url }}/lib/MyStack.js) take a look at the SST [`ReactStaticSite`](https://docs.serverless-stack.com/constructs/ReactStaticSite) definition.
164+
We can now turn our attention to the frontend part of our application. In [`stacks/MyStack.js`]({{ repo_url }}/stacks/MyStack.js) take a look at the SST [`ReactStaticSite`](https://docs.serverless-stack.com/constructs/ReactStaticSite) definition.
165165

166166
``` js
167167
// Deploy our React app
@@ -187,7 +187,7 @@ The key here is that we are [setting the outputs from our backend as environment
187187
4. Id of our Cognito Identity Pool
188188
5. And the Id of the Cognito User Pool client
189189

190-
You can check out the rest of [`lib/MyStack.js`]({{ repo_url }}/lib/MyStack.js) for reference.
190+
You can check out the rest of [`stacks/MyStack.js`]({{ repo_url }}/stacks/MyStack.js) for reference.
191191

192192
Now we are ready to create our React app.
193193

0 commit comments

Comments
 (0)