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
Copy file name to clipboardExpand all lines: src/pages/guides/hosting/aws.md
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ tocHeading: 2
8
8
9
9
# AWS
10
10
11
-
Greenwood projects can be deployed to [**AWS**](https://aws.amazon.com/) for static hosting ([**S3**](https://aws.amazon.com/s3/) / [**CloudFront**](https://aws.amazon.com/cloudfront/)) and dynamic serverless hosting of SSR pages and API routes (on [**Lambda**](https://aws.amazon.com/lambda/)). Although static hosting is fairly trivial, for full-stack applications and when leveraging additional AWS services to compliment your application, we recommend leveraging [IaC (Infrastructure as Code)](https://en.wikipedia.org/wiki/Infrastructure_as_code) tools, as we will demonstrate later in this guide.
11
+
Greenwood projects can be deployed to [**AWS**](https://aws.amazon.com/) for static hosting ([**S3**](https://aws.amazon.com/s3/) / [**CloudFront**](https://aws.amazon.com/cloudfront/)) and dynamic serverless hosting of SSR pages and API routes ([**Lambda**](https://aws.amazon.com/lambda/)). Although static hosting is fairly simple, for full-stack applications and when leveraging additional AWS services to compliment your application, we recommend leveraging [IaC (Infrastructure as Code)](https://en.wikipedia.org/wiki/Infrastructure_as_code) tools, as we will demonstrate later in this guide.
12
12
13
13
> You can see a complete hybrid project example in our [demonstration repo](https://github.com/ProjectEvergreen/greenwood-demo-adapter-aws).
14
14
@@ -50,11 +50,11 @@ Below is a sample Edge function for doing the rewrites:
50
50
51
51
<!-- prettier-ignore-end -->
52
52
53
-
> At this point, you'll probably want to use Route 53 to [put your domain in front of your CloudFront distribution](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-cloudfront-distribution.html).
53
+
> At this point, you'll probably want to use Route 53 to [put a domain in front of your CloudFront distribution](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-cloudfront-distribution.html).
54
54
55
55
## Serverless
56
56
57
-
If your Greenwood project has SSR pages and / or API routes that you would like to deploy to AWS Lambda functions, our recommendation is to install [our adapter plugin](https://github.com/ProjectEvergreen/greenwood/tree/master/packages/plugin-adapter-aws) and then add it to your _greenwood.config.js_, which at build time will generate Lambda compatible function code for all your dynamic pages and routes.
57
+
If your Greenwood project has SSR pages and / or API routes that you would like to deploy as AWS Lambda functions, our recommendation is to install [our AWS adapter plugin](https://github.com/ProjectEvergreen/greenwood/tree/master/packages/plugin-adapter-aws) and then add it to your _greenwood.config.js_. At build time it will generate Lambda compatible function code for all your dynamic pages and routes.
58
58
59
59
<!-- prettier-ignore-start -->
60
60
@@ -78,10 +78,10 @@ Just like Greenwood has its own [standard build output](/docs/reference/appendix
78
78
79
79
The adapted functions will be output to a folder called _.aws-output_ with the following two folders:
80
80
81
-
-`api/` - All API routes will be in this folder, with one folder per route
82
-
-`routes/` - All SSR pages will be in this folder, with one folder per route
81
+
-_api/_ - All API routes will be in this folder, with one folder per endpoint
82
+
-_routes/_ - All SSR pages will be in this folder, with one folder per route
83
83
84
-
Here is an example from a directory listing perspective of what the structure of this folder looks like:
84
+
Here is an example directory listing of what the structure of this folder might look like:
85
85
86
86
```shell
87
87
.aws-output/
@@ -102,20 +102,22 @@ Here is an example from a directory listing perspective of what the structure of
102
102
products.route.js
103
103
```
104
104
105
-
For **_each_** of the folders in the `api` or `routes` directories, it would be as simple as just creating a zip file for each folder / route, or just pointing your IaC tooling to those output folders, as we'll get into in the next section.
105
+
For **_each_** of the folders in the _api/_ or _routes/_ directories, it would be as simple as just creating a zip file for each folder / route and uploading them, or just pointing your IaC tooling to those output folders, as we'll get into in the next section.
106
106
107
-
### SST (IaC) Example
107
+
### IaC Example (SST)
108
108
109
109
Given the nature of AWS hosting and the plethora of related services that you can use to compliment your application, the Greenwood AWS adapter is specifically designed to output purely compatible Lambda functions, one per folder, that can be plugging into any IaC tool. (or zipped up and deployed manually, if you prefer)
110
110
111
-
While there are many options for IaC tooling, [**SST**](https://sst.dev/) is a very powerful tool which let's you entirely define your AWS infrastructure with TypeScript, combining as few or as many AWS service as you may need. Below is a simple
111
+
While there are many options for IaC tooling, [**SST**](https://sst.dev/) is a very powerful option which let's you entirely define your AWS infrastructure programmatically with TypeScript, combining as few or as many AWS service as you may need.
// 1) Configure SSR pages and API routes in API Gateway
120
+
// 1) Configure an API Gateway for routing SSR pages and API routes
119
121
const api =newsst.aws.ApiGatewayV2("MyApi");
120
122
121
123
// products page
@@ -138,7 +140,7 @@ While there are many options for IaC tooling, [**SST**](https://sst.dev/) is a v
138
140
},
139
141
})
140
142
141
-
// 3) Configure CloudFront router with SSR pages, API routes, and static content
143
+
// 3) Configure a CloudFront distribution with behaviors for SSR pages, API routes, and static content
142
144
const router =newsst.aws.Router("MyRouter", {
143
145
routes: {
144
146
"/api/*": api.url,
@@ -154,7 +156,7 @@ While there are many options for IaC tooling, [**SST**](https://sst.dev/) is a v
154
156
invalidation: true,
155
157
});
156
158
157
-
// 4) Configure SST app
159
+
// 4) Configure the SST app
158
160
exportdefault$config({
159
161
app(input) {
160
162
return {
@@ -174,7 +176,7 @@ While there are many options for IaC tooling, [**SST**](https://sst.dev/) is a v
174
176
175
177
<!-- prettier-ignore-end -->
176
178
177
-
Although the above example is hardcoded, you'll want use the build output manifest from Greenwood by following the [complete example repo we have](https://github.com/ProjectEvergreen/greenwood-demo-adapter-aws) for deploying a full-stack Greenwood application.
179
+
Although the above example is hardcoded, you'll want to use the build output manifest from Greenwood by following the [complete example repo we have](https://github.com/ProjectEvergreen/greenwood-demo-adapter-aws) for deploying a full-stack Greenwood application.
178
180
179
181
> We also have an [**Architect**](https://arc.codes/) example [for reference](https://github.com/ProjectEvergreen/greenwood-demo-adapter-aws/tree/feature/arc-adapter) as well.
180
182
@@ -217,6 +219,7 @@ If you're using GitHub, you can use GitHub Actions to automate the pushing of bu
217
219
run: |
218
220
npm run build
219
221
222
+
# or run your IaC tool for adapter based builds
220
223
- name: Upload to S3 and invalidate CDN
221
224
uses: opspresso/action-s3-sync@master
222
225
env:
@@ -233,4 +236,4 @@ If you're using GitHub, you can use GitHub Actions to automate the pushing of bu
233
236
234
237
<!-- prettier-ignore-end -->
235
238
236
-
Now when you push changes to your repo, the action will run an the build files will automatically be uploaded.
239
+
Now when you push changes to your repo, the action will run and your build will automatically be deployed to your AWS account.
0 commit comments