Skip to content

Commit a2bbd3a

Browse files
committed
docs: update getting started
1 parent eee51a7 commit a2bbd3a

File tree

1 file changed

+81
-49
lines changed

1 file changed

+81
-49
lines changed

README.md

Lines changed: 81 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Highlights of this project include:
4444

4545
# Getting Started
4646

47-
## 1. Install dependencies & deploy
47+
## 1. Install dependencies
4848

4949
**Install Serverless Framework**
5050

@@ -54,31 +54,81 @@ npm i -g serverless
5454

5555
**Install NPM dependencies**
5656

57-
This runs `npm install` in each service directory.
57+
This project is structured as a monorepo with multiple services. Each service
58+
has its own `package.json` file, so you must install the dependencies for each
59+
service. Running `npm install` in the root directory will install the
60+
dependencies for all services.
5861

5962
```
6063
npm install
6164
```
6265

66+
**Setup AWS Credentials**
67+
68+
If you haven't already, setup your AWS Credentials. You can follow the [AWS Credentials doc](https://www.serverless.com/framework/docs/providers/aws/guide/credentials)
69+
for step-by-step instructions.
70+
71+
## 2. Enable AWS Bedrock Models
72+
73+
This example requires the `meta.llama3-70b-instruct-v1:0` AWS Bedrock
74+
Model to be enabled. By default, AWS does not enable these models, you must go
75+
to the [AWS Console](https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/models)
76+
and individually request access to the AI Models.
77+
78+
There is no cost to enable the models, but you must request access to use them.
79+
80+
Upon request, it may take a few minutes for AWS to enable the model. Once they
81+
are enabled, you will receive an email from AWS confirming the model is enabled.
82+
83+
## 3. Deploy & start developing
84+
85+
Now you are ready to deploy the services. This will deploy all the services
86+
to your AWS account. You can deploy the services to the `default` stage, which
87+
is the default stage for development.
88+
6389
**Deploy the services**
6490

6591
```
6692
serverless deploy
6793
```
6894

69-
**NOTE**: This example requires the `meta.llama3-70b-instruct-v1:0` AWS Bedrock
70-
Model to be enabled. By default, AWS does not enable these models, you must go
71-
to the [AWS Console](https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/models)
72-
and individually request access to the AI Models.
95+
At this point the service is live. When running the `serverless deploy` command,
96+
you will see the output of the services that were deployed. One of those
97+
services is the `web` service, which is the website service. To view the app,
98+
go to the URL in the `endpoint: ANY - ` section for the `web` service.
99+
100+
```
101+
Deploying "web" to stage "dev" (us-east-1)
102+
103+
endpoint: ANY - https://ps5s7dd634.execute-api.us-east-1.amazonaws.com
104+
functions:
105+
app: web-dev-app (991 kB)
106+
107+
```
108+
109+
Once you start developing it is easier to run the service locally for faster
110+
iteration. We recommend using [Serverless Dev Mode](https://www.serverless.com/framework/docs/providers/aws/cli-reference/dev).
111+
You can run Dev Mode for individual services. This emulates Lambda locally and
112+
proxies requests to the real service.
113+
114+
```
115+
serverless auth dev
116+
```
117+
118+
Once done, you can redeploy individual services using the `serverless` command
119+
with the service name.
120+
121+
```
122+
serverless auth deploy
123+
```
73124

74-
At this point you will have a functional dev service deploy. This `dev` stage
75-
does not use a custom domain name, and uses a placeholder shared secret for JWT
76-
token authentication.
125+
## 4. Prepare for production
77126

78-
The subsequent steps will help you setup the custom domain name, shared secret,
79-
and development workflow you can use in production.
127+
Now that the app is up and running in a development environment, lets get it
128+
ready for production by setting up a custom domain name, and setting a new
129+
shared secret for JWT token authentication.
80130

81-
## 2. Setup Custom Domain Name (optional)
131+
### Setup Custom Domain Name (optional)
82132

83133
This project is configured to use custom domain names. For non `prod`
84134
deployments this is disabled. Deployments to `prod` are designed to use a custom
@@ -103,22 +153,22 @@ https://us-east-1.console.aws.amazon.com/acm/home?region=us-east-1#/certificates
103153
This example uses a Certificate with the following full qualified domain names:
104154

105155
```
106-
serverless-fullstack.com
107-
*.serverless-fullstack.com
156+
awsaistack.com
157+
*.awsaistack.com
108158
```
109159

110-
The base domain name, `serverless-fullstack.com` is used for the website service
160+
The base domain name, `awsaistack.com` is used for the website service
111161
to host the static website. The wildcard domain name,
112-
`*.serverless-fullstack.com` is used for the API services,
113-
`api.serverless-fullstack.com`, and `chat.serverless-fullstack.com`.
162+
`*.awsaistack.com` is used for the API services,
163+
`api.awsaistack.com`, and `chat.awsaistack.com`.
114164

115165
**Update serverless-compose.yml**
116166

117167
- Update the `stages.default.customDomainName` to your custom domain name.
118168
- Update the `stages.default.customDomainCertificateARN` to the ARN of the
119169
certificate you created in ACM.
120170

121-
## 3. Create the secret for JWT Token authentication
171+
### Create the secret for JWT Token authentication
122172

123173
Authentication is implemented using JWT tokens. A shared secret is used to sign
124174
the JWT tokens when a user logs in. The secret is also used to verify the JWT
@@ -133,11 +183,11 @@ The `prod` stage uses the `${ssm}` parameter to retrieve the secret from AWS
133183
Systems Manager Parameter Store.
134184

135185
Generate a random secret and store it in the AWS Systems Manager Parameter Store
136-
with a key like `/serverless-fullstack/shared-token`, and set it in the
186+
with a key like `/awsaistack/shared-token`, and set it in the
137187
`sharedTokenSecret` parameter in the `serverless-compose.yml` file:
138188

139189
```
140-
sharedTokenSecret: ${ssm:/serverless-fullstack/shared-token}
190+
sharedTokenSecret: ${ssm:/awsaistack/shared-token}
141191
```
142192

143193
## 4. Deploy to prod
@@ -150,27 +200,9 @@ serverless deploy --stage prod
150200
```
151201

152202
Now you can use the service by visiting your domain name, or
153-
https://servelress-fullstack.com. This uses the Auth service to login and
203+
https://awsaistack.com. This uses the Auth service to login and
154204
register users, the AI Chat service to interact with the AI Chat bot.
155205

156-
## 5. Start Developing
157-
158-
Once you start developing it is easier to run the service locally for faster
159-
iteration. We recommend using Serverless Dev Mode. You can run Dev Mode for
160-
individual services. This emulates Lambda locally and proxies requests to the
161-
real service.
162-
163-
```
164-
serverless auth dev
165-
```
166-
167-
Once done, you can redeploy individual services using the `serverless` command
168-
with the service name.
169-
170-
```
171-
serverless auth deploy
172-
```
173-
174206
# Architectural Overview
175207

176208
## Serverless & Costs
@@ -213,7 +245,7 @@ services to validate the JWT token. This library is defined as an NPM package
213245
and is used by the `ai-chat-api` and `business-api` services and included using
214246
relative paths in the `package.json` file.
215247

216-
## Authentication (api.serverless-fullstack.com/auth)
248+
## Authentication (api.awsaistack.com/auth)
217249

218250
The `auth` service is an Express.js-based API service that provides login and
219251
registration endpoints. It uses a DynamoDB table to store user information and
@@ -232,7 +264,7 @@ authorizer.
232264
The `auth` service also publishes the CloudFormation Output `AuthApiUrl`, which
233265
is used by the website service to make requests to the `auth` service.
234266

235-
## AI Chat (chat.serverless-fullstack.com)
267+
## AI Chat (chat.awsaistack.com)
236268

237269
In most cases APIs on AWS Lambda use the API Gateway to expose the API. However,
238270
the `ai-chat-api` service uses Lambda Function URLs instead of API Gateway, in
@@ -274,7 +306,7 @@ stages:
274306
throttleMonthlyLimitGlobal: 100
275307
```
276308
277-
## Website (serverless-fullstack.com)
309+
## Website (awsaistack.com)
278310
279311
The website service is a simple Lambda function which uses Express to serve
280312
static assets. The service uses the `serverless-plugin-scripts` plugin to
@@ -287,7 +319,7 @@ The frontend website is built using React. It uses the `auth` service to
287319
login and register uses, and uses the `ai-chat-api` to interact with the
288320
AI Chat bot API.
289321
290-
## Business API (api.serverless-fullstack.com/business)
322+
## Business API (api.awsaistack.com/business)
291323
292324
This is an Express.js-based API service that provides a placeholder for your
293325
business logic. It is configured to use the same custom domain name as the
@@ -329,15 +361,15 @@ Below are a few simple API requests using the `curl` command.
329361
## User Registration API
330362
331363
```
332-
curl -X POST https://api.serverless-fullstack.com/auth/register \
364+
curl -X POST https://api.awsaistack.com/auth/register \
333365
-H 'Content-Type: application/json' \
334366
-d '{"email": "[email protected]", "password": "password"}'
335367
```
336368
337369
## User Login API
338370
339371
```
340-
curl -X POST https://api.serverless-fullstack.com/auth/login \
372+
curl -X POST https://api.awsaistack.com/auth/login \
341373
-H 'Content-Type: application/json' \
342374
-d '{"email": "[email protected]", "password": "password"}'
343375
```
@@ -347,7 +379,7 @@ the token as an environment variable so you can use the token in subsequent
347379
requests.
348380
349381
```
350-
export SERVERLESS_EXAMPLE_TOKEN=$(curl -X POST https://api.serverless-fullstack.com/auth/login \
382+
export SERVERLESS_EXAMPLE_TOKEN=$(curl -X POST https://api.awsaistack.com/auth/login \
351383
-H 'Content-Type: application/json' \
352384
-d '{"email": "[email protected]", "password": "password"}' \
353385
| jq -r '.token')
@@ -362,7 +394,7 @@ may also contain multiple JSON objects.
362394
This endpoint is authenticated and requires the JWT token from the login API.
363395
364396
```
365-
curl -N -X POST https://chat.serverless-fullstack.com/ \
397+
curl -N -X POST https://chat.awsaistack.com/ \
366398
-H 'Content-Type: application/json' \
367399
-H "Authorization: Bearer $SERVERLESS_EXAMPLE_TOKEN" \
368400
-d '[{"role":"user","content":[{"text":"What makes the serverless framework so great?"}]}]'
@@ -374,7 +406,7 @@ This endpoint is also authenticated and requires the JWT token from the login
374406
API. The response is a simple message.
375407
376408
```
377-
curl -X GET https://api.serverless-fullstack.com/business/ \
409+
curl -X GET https://api.awsaistack.com/business/ \
378410
-H 'Content-Type: application/json' \
379411
-H "Authorization: Bearer $SERVERLESS_EXAMPLE_TOKEN"
380412
```
@@ -398,7 +430,7 @@ to use the same domain name as the other services.
398430
## Using API Gateway to share a custom domain name
399431
400432
In this configuration, the Auth and Business APIs use the paths `/auth` and
401-
`/business` respectively on `api.serverless-fullstack.com`. The Custom Domain
433+
`/business` respectively on `api.awsaistack.com`. The Custom Domain
402434
Name Path Mapping was used in the Custom Domain Name support in API Gateway
403435
to use the same domain name but shared across multiple API Gateway instances.
404436

0 commit comments

Comments
 (0)