You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Note-Taking application built using AWS SDK for JavaScript (v3) demonstrates how to build a serverless web application using DynamoDB, Lambda, Cognito, API Gateway, and S3. This sample application deploys five Lambda functions to create, list, update, delete, and get all the notes. A React-based frontend allows the user to interact with the Lambda functions exposed via an API Gateway URL. Users can deploy this application sample on LocalStack & AWS using AWS Cloud Development Kit with no changes. To test this application sample, we will demonstrate how you use LocalStack to deploy the infrastructure on your developer machine and your CI environment. Furthermore, we will showcase how you can interact with the web user interface to verify the application's functionality.
14
+
The Note-Taking application built using AWS SDK for JavaScript (v3) demonstrates how to build a serverless web application using DynamoDB, Lambda, Cognito, API Gateway, S3 and Cloudfront. This sample application deploys five Lambda functions to create, list, update, delete, and get all the notes. A React-based frontend served via a Cloudfront distribution and an S3 bucket allows the user to interact with the Lambda functions exposed via an API Gateway URL. Users can deploy this application sample on LocalStack & AWS using AWS Cloud Development Kit with no changes. To test this application sample, we will demonstrate how you use LocalStack to deploy the infrastructure on your developer machine and your CI environment. Furthermore, we will showcase how you can interact with the web user interface to verify the application's functionality.
15
15
16
16
## Architecture diagram
17
17
@@ -27,6 +27,8 @@ We are using the following AWS services and their features to build our infrastr
27
27
-[IAM](https://docs.localstack.cloud/user-guide/aws/iam/) to create policies to specify roles and permissions for various AWS services.
28
28
-[API Gateway](https://docs.localstack.cloud/user-guide/aws/apigatewayv2/) to expose the Lambda functions to the user through HTTP APIs.
29
29
-[Cognito User Pools](https://docs.localstack.cloud/user-guide/aws/cognito/) for creating an identity pool to generate signed url for S3.
30
+
-[Cloudfront](https://docs.localstack.cloud/user-guide/aws/cloudfront/) to serve frontend content.
31
+
-[S3] (https://docs.localstack.cloud/user-guide/aws/s3/) to store files for the frontend build.
30
32
31
33
## Prerequisites
32
34
@@ -35,10 +37,10 @@ We are using the following AWS services and their features to build our infrastr
35
37
-[CDK](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/) with the [`cdklocal`](https://www.npmjs.com/package/aws-cdk-local) wrapper.
36
38
-[Node.js](https://nodejs.org/en/download/) with `yarn` package manager.
37
39
38
-
Start LocalStack Pro with the `LOCALSTACK_API_KEY` pre-configured:
40
+
Start LocalStack Pro with the `LOCALSTACK_AUTH_TOKEN` or `LOCALSTACK_API_KEY` pre-configured:
39
41
40
42
```shell
41
-
exportLOCALSTACK_API_KEY=<your-api-key>
43
+
exportLOCALSTACK_AUTH_TOKEN=<your-auth-token>
42
44
EXTRA_CORS_ALLOWED_ORIGINS=* localstack start
43
45
```
44
46
@@ -61,7 +63,7 @@ yarn install
61
63
To build the Lambda functions, run the following command:
62
64
63
65
```shell
64
-
yarn build:backend
66
+
make build
65
67
```
66
68
67
69
You are expected to see the following output:
@@ -81,15 +83,15 @@ You are expected to see the following output:
81
83
To bootstrap the CDK, run the following command:
82
84
83
85
```shell
84
-
yarn cdklocal bootstrap
86
+
make bootstrap
85
87
```
86
88
87
89
### Deploying the infrastructure
88
90
89
91
To deploy the infrastructure, run the following command:
90
92
91
93
```shell
92
-
yarn cdklocal deploy
94
+
make deploy
93
95
```
94
96
95
97
> If you see a `CREATE_FAILED (Deployment failed)` error, wait a few seconds and re-run the command.
@@ -121,7 +123,7 @@ To configure the frontend to use the deployed infrastructure, run the following
121
123
make prepare-frontend-local
122
124
```
123
125
124
-
It will update the `packages/frontend/src/config.json` file with the deployed infrastructure's output values.
126
+
It will update the `packages/frontend/.env` file with the deployed infrastructure's output values.
125
127
126
128
### Deploying the frontend
127
129
@@ -131,19 +133,23 @@ make bootstrap-frontend
131
133
make deploy-frontend
132
134
```
133
135
134
-
Alternatively you can start the frontend locally with below steps:
136
+
### View the frontend
135
137
136
-
### Starting the frontend
138
+
Access the cloudfront distribution by fetching its id with the following command:
137
139
138
-
To start the frontend, run the following command:
140
+
```shell
141
+
awslocal cloudfront list-distributions
142
+
```
139
143
144
+
with the Id of the distribution, simply open the following URL:
To test the web application, open the URL you see in the output of the `yarn start:frontend` command in your browser. You will see the following page:
152
+
To test the web application, open the URL above. You will see the following page:
147
153
148
154

149
155
@@ -157,12 +163,26 @@ You can click on **Create** and see the note added to the list of notes:
157
163
158
164
You can further edit, delete, and view the notes.
159
165
166
+
### Starting the frontend locally
167
+
168
+
To start the frontend locally, run the following command:
169
+
170
+
```shell
171
+
yarn start:frontend
172
+
```
173
+
174
+
You'll see the URL to access the frontend in the output of the `yarn start:frontend` command
175
+
160
176
### GitHub Action
161
177
162
178
This application sample hosts an example GitHub Action workflow that starts up LocalStack, builds the Lambda functions, and deploys the infrastructure on the runner. You can find the workflow in the `.github/workflows/main.yml` file. To run the workflow, you can fork this repository and push a commit to the `main` branch.
163
179
164
180
Users can adapt this example workflow to run in their own CI environment. LocalStack supports various CI environments, including GitHub Actions, CircleCI, Jenkins, Travis CI, and more. You can find more information about the CI integration in the [LocalStack documentation](https://docs.localstack.cloud/user-guide/ci/).
165
181
182
+
### Preview environment
183
+
184
+
This sample further shows off our preview environments feature. Preview environments allow you to deploy your application to a separate environment whenever you want with the right configuration. You can find the workflow in the `.github/workflows/preview.yml` file. You can find more information about preview environments in the [LocalStack documentation](https://docs.localstack.cloud/user-guide/cloud-sandbox/application-previews/).
185
+
166
186
## Learn more
167
187
168
188
The sample application is based on a public [AWS sample app](https://github.com/aws-samples/ecs-apigateway-sample) and a [SST tutorial](https://github.com/serverless-stack/demo-notes-app).
0 commit comments