Skip to content

Commit 90846cc

Browse files
final draft and tweaks
1 parent 0386776 commit 90846cc

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

  • src/pages/guides/hosting

src/pages/guides/hosting/aws.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tocHeading: 2
88

99
# AWS
1010

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.
1212

1313
> You can see a complete hybrid project example in our [demonstration repo](https://github.com/ProjectEvergreen/greenwood-demo-adapter-aws).
1414
@@ -50,11 +50,11 @@ Below is a sample Edge function for doing the rewrites:
5050

5151
<!-- prettier-ignore-end -->
5252

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).
5454
5555
## Serverless
5656

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.
5858

5959
<!-- prettier-ignore-start -->
6060

@@ -78,10 +78,10 @@ Just like Greenwood has its own [standard build output](/docs/reference/appendix
7878

7979
The adapted functions will be output to a folder called _.aws-output_ with the following two folders:
8080

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
8383

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:
8585

8686
```shell
8787
.aws-output/
@@ -102,20 +102,22 @@ Here is an example from a directory listing perspective of what the structure of
102102
products.route.js
103103
```
104104

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.
106106

107-
### SST (IaC) Example
107+
### IaC Example (SST)
108108

109109
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)
110110

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.
112+
113+
Let's look at the below example:
112114

113115
<!-- prettier-ignore-start -->
114116

115117
<app-ctc-block variant="snippet" heading="sst.config.ts">
116118

117119
```ts
118-
// 1) Configure SSR pages and API routes in API Gateway
120+
// 1) Configure an API Gateway for routing SSR pages and API routes
119121
const api = new sst.aws.ApiGatewayV2("MyApi");
120122

121123
// products page
@@ -138,7 +140,7 @@ While there are many options for IaC tooling, [**SST**](https://sst.dev/) is a v
138140
},
139141
})
140142

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
142144
const router = new sst.aws.Router("MyRouter", {
143145
routes: {
144146
"/api/*": api.url,
@@ -154,7 +156,7 @@ While there are many options for IaC tooling, [**SST**](https://sst.dev/) is a v
154156
invalidation: true,
155157
});
156158

157-
// 4) Configure SST app
159+
// 4) Configure the SST app
158160
export default $config({
159161
app(input) {
160162
return {
@@ -174,7 +176,7 @@ While there are many options for IaC tooling, [**SST**](https://sst.dev/) is a v
174176

175177
<!-- prettier-ignore-end -->
176178

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.
178180

179181
> 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.
180182
@@ -217,6 +219,7 @@ If you're using GitHub, you can use GitHub Actions to automate the pushing of bu
217219
run: |
218220
npm run build
219221
222+
# or run your IaC tool for adapter based builds
220223
- name: Upload to S3 and invalidate CDN
221224
uses: opspresso/action-s3-sync@master
222225
env:
@@ -233,4 +236,4 @@ If you're using GitHub, you can use GitHub Actions to automate the pushing of bu
233236
234237
<!-- prettier-ignore-end -->
235238
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

Comments
 (0)