Skip to content

Commit 34afcb6

Browse files
committed
Update README
1 parent 10d9469 commit 34afcb6

File tree

4 files changed

+151
-3
lines changed

4 files changed

+151
-3
lines changed

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,71 @@
11
# SvelteKit AWS Adapter for Pulumi
2+
3+
This project contains a SvelteKit adapter to deploy SvelteKit to AWS using Pulumi.
4+
5+
## How to use?
6+
7+
1. Create a SvelteKit project "my-app" - `npm create svelte@latest my-app`
8+
2. `cd my-app`
9+
3. `npm install`
10+
4. `npm install -D sveltekit-adapter-aws-pulumi`
11+
5. edit **svelte.config.js**
12+
13+
## Basic setup example
14+
15+
**svelte.config.js**
16+
17+
```javascript
18+
import { adapter } from 'sveltekit-adapter-aws-pulumi';
19+
import preprocess from 'svelte-preprocess';
20+
21+
export default {
22+
preprocess: preprocess(),
23+
kit: {
24+
adapter: adapter({
25+
autoDeploy: true,
26+
}),
27+
},
28+
};
29+
```
30+
31+
## Architecture
32+
33+
The following diagram shows the architecture deployed by this package. The key features are as follows:
34+
35+
1. A CloudFront CDN
36+
1. An S3 bucket to serve prerendered and static content (via the CloudFront
37+
CDN)
38+
1. An APIGateWay HTTP API with two routes:
39+
1. The default route is integrated with a lambda that serves the SSR code
40+
2. A second route for OPTIONS requests that integrates with a lambda used
41+
to manage CORS
42+
43+
![Architecture](architecture.png)
44+
45+
## Configuration
46+
47+
```typescript
48+
export interface AWSAdapterProps {
49+
artifactPath?: string; // Build output directory (default: build)
50+
autoDeploy?: boolean; // Should automatically deploy in SvelteKit build step (default: false)
51+
pulumiPath?: string; // Path to Pulumi project for custom deployments (e.g. ${process.cwd()}/pulumi)
52+
stackName?: string; // Pulumi stack name (default: sveltekit-adapter-aws)
53+
serverHeaders?: string[]; // Whitelist of headers for the SSR server. Defaults to ['Accept','Accept-Charset','Access-Control-Request-Method','Access-Control-Request-Headers','Accept-Datetime','Accept-Language','Origin','Referer']
54+
staticHeaders?: string[]; // Whitelist of headers for the static files. Defaults to ['User-Agent', 'Referer']
55+
esbuildOptions?: any; // Override or extend default esbuild options. Supports `external` (default `['node:*']`), `format` (default `cjs`), `target` (default `node16`), `banner` (default `{}`).
56+
FQDN?: string; // Full qualified domain name of CloudFront deployment (e.g. demo.example.com)
57+
MEMORY_SIZE?: number; // Memory size of SSR lambda in MB (default 128 MB)
58+
zoneName?: string; // The name of the hosted zone in Route 53 (defaults to the TLD from the FQDN)
59+
}
60+
```
61+
62+
## Dependencies
63+
64+
This package utilises the [SvelteKit AWS Adapter Base
65+
Package](https://github.com/Data-Only-Greater/sveltekit-adapter-aws-base) to
66+
prepare the files to be deployed.
67+
68+
## Credits
69+
70+
This package is derived from [Mike
71+
Bild's](https://github.com/MikeBild/sveltekit-adapter-aws) AWS adapter for CDK.

adapter.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export interface AWSAdapterProps {
1313
staticHeaders?: string[]
1414
esbuildOptions?: any
1515
FQDN?: string
16-
LOG_RETENTION_DAYS?: number
1716
MEMORY_SIZE?: number
1817
zoneName?: string
1918
env?: { [key: string]: string }
@@ -23,7 +22,7 @@ export function adapter({
2322
artifactPath = 'build',
2423
autoDeploy = false,
2524
pulumiPath = `${__dirname}/pulumi`,
26-
stackName = 'sveltekit-adapter-aws-webapp',
25+
stackName = 'sveltekit-adapter-aws',
2726
serverHeaders = [
2827
'Accept',
2928
'Accept-Charset',
@@ -37,7 +36,6 @@ export function adapter({
3736
staticHeaders = ['User-Agent', 'Referer'],
3837
esbuildOptions = {},
3938
FQDN,
40-
LOG_RETENTION_DAYS,
4139
MEMORY_SIZE,
4240
zoneName = '',
4341
env = {},

architecture.drawio

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<mxfile host="65bd71144e">
2+
<diagram id="Ht1M8jgEwFfnCIfOTk4-" name="Page-1">
3+
<mxGraphModel dx="1077" dy="792" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" background="#ffffff" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0"/>
6+
<mxCell id="1" parent="0"/>
7+
<mxCell id="ulep6MaeRu_wHvCxp79e-1" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
8+
<mxGeometry x="200" y="290" width="120" height="120" as="geometry"/>
9+
</mxCell>
10+
<mxCell id="ulep6MaeRu_wHvCxp79e-19" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" parent="1" source="ulep6MaeRu_wHvCxp79e-2" target="ulep6MaeRu_wHvCxp79e-5" edge="1">
11+
<mxGeometry relative="1" as="geometry"/>
12+
</mxCell>
13+
<mxCell id="ulep6MaeRu_wHvCxp79e-2" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
14+
<mxGeometry x="290" y="320" width="120" height="60" as="geometry"/>
15+
</mxCell>
16+
<mxCell id="ulep6MaeRu_wHvCxp79e-3" value="Adapter AWS" style="text;html=1;resizable=0;autosize=1;align=center;verticalAlign=middle;points=[];fillColor=none;strokeColor=none;rounded=0;fontStyle=1" parent="1" vertex="1">
17+
<mxGeometry x="304" y="340" width="90" height="20" as="geometry"/>
18+
</mxCell>
19+
<mxCell id="ulep6MaeRu_wHvCxp79e-4" value="SvelteKit&lt;br&gt;Project" style="text;html=1;resizable=0;autosize=1;align=center;verticalAlign=middle;points=[];fillColor=none;strokeColor=none;rounded=0;fontStyle=1" parent="1" vertex="1">
20+
<mxGeometry x="220" y="335" width="70" height="30" as="geometry"/>
21+
</mxCell>
22+
<mxCell id="ulep6MaeRu_wHvCxp79e-5" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
23+
<mxGeometry x="540" y="110" width="360" height="480" as="geometry"/>
24+
</mxCell>
25+
<mxCell id="ulep6MaeRu_wHvCxp79e-6" value="SvelteKit Adapter Stack" style="text;html=1;resizable=0;autosize=1;align=center;verticalAlign=middle;points=[];fillColor=none;strokeColor=none;rounded=0;fontStyle=1" parent="1" vertex="1">
26+
<mxGeometry x="547" y="120" width="150" height="20" as="geometry"/>
27+
</mxCell>
28+
<mxCell id="ulep6MaeRu_wHvCxp79e-9" value="CDN&lt;br&gt;&amp;nbsp;Cloudfront" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#ffffff;fillColor=#232F3E;dashed=0;verticalLabelPosition=middle;verticalAlign=bottom;align=center;html=1;whiteSpace=wrap;fontSize=10;fontStyle=1;spacing=3;shape=mxgraph.aws4.productIcon;prIcon=mxgraph.aws4.cloudfront;" parent="1" vertex="1">
29+
<mxGeometry x="681" y="168" width="80" height="110" as="geometry"/>
30+
</mxCell>
31+
<mxCell id="ulep6MaeRu_wHvCxp79e-11" value="Prerendered &amp;amp; Static Content&lt;br&gt;S3" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#ffffff;fillColor=#232F3E;dashed=0;verticalLabelPosition=middle;verticalAlign=bottom;align=center;html=1;whiteSpace=wrap;fontSize=10;fontStyle=1;spacing=3;shape=mxgraph.aws4.productIcon;prIcon=mxgraph.aws4.s3;" parent="1" vertex="1">
32+
<mxGeometry x="560" y="304" width="80" height="120" as="geometry"/>
33+
</mxCell>
34+
<mxCell id="ulep6MaeRu_wHvCxp79e-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" parent="1" source="ulep6MaeRu_wHvCxp79e-9" target="ulep6MaeRu_wHvCxp79e-13" edge="1">
35+
<mxGeometry relative="1" as="geometry">
36+
<mxPoint x="760" y="225" as="sourcePoint"/>
37+
</mxGeometry>
38+
</mxCell>
39+
<mxCell id="ulep6MaeRu_wHvCxp79e-17" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" parent="1" source="ulep6MaeRu_wHvCxp79e-9" target="ulep6MaeRu_wHvCxp79e-11" edge="1">
40+
<mxGeometry relative="1" as="geometry">
41+
<mxPoint x="680" y="225" as="sourcePoint"/>
42+
</mxGeometry>
43+
</mxCell>
44+
<mxCell id="ulep6MaeRu_wHvCxp79e-15" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" parent="1" source="ulep6MaeRu_wHvCxp79e-13" target="ulep6MaeRu_wHvCxp79e-14" edge="1">
45+
<mxGeometry relative="1" as="geometry"/>
46+
</mxCell>
47+
<mxCell id="ulep6MaeRu_wHvCxp79e-13" value="HTTP Proxy API Gateway" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#ffffff;fillColor=#232F3E;dashed=0;verticalLabelPosition=middle;verticalAlign=bottom;align=center;html=1;whiteSpace=wrap;fontSize=10;fontStyle=1;spacing=3;shape=mxgraph.aws4.productIcon;prIcon=mxgraph.aws4.api_gateway;" parent="1" vertex="1">
48+
<mxGeometry x="790" y="304" width="80" height="110" as="geometry"/>
49+
</mxCell>
50+
<mxCell id="ulep6MaeRu_wHvCxp79e-14" value="SSR Lambda" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#ffffff;fillColor=#232F3E;dashed=0;verticalLabelPosition=middle;verticalAlign=bottom;align=center;html=1;whiteSpace=wrap;fontSize=10;fontStyle=1;spacing=3;shape=mxgraph.aws4.productIcon;prIcon=mxgraph.aws4.lambda;" parent="1" vertex="1">
51+
<mxGeometry x="790" y="460" width="80" height="110" as="geometry"/>
52+
</mxCell>
53+
<mxCell id="VaYHp8SwEo52CTvzwjfN-1" value="Default (*)" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
54+
<mxGeometry x="770" y="170" width="120" height="20" as="geometry"/>
55+
</mxCell>
56+
<mxCell id="VaYHp8SwEo52CTvzwjfN-3" value="_app/*" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
57+
<mxGeometry x="550" y="170" width="120" height="20" as="geometry"/>
58+
</mxCell>
59+
<mxCell id="VaYHp8SwEo52CTvzwjfN-5" value="other static content" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
60+
<mxGeometry x="550" y="190" width="120" height="20" as="geometry"/>
61+
</mxCell>
62+
<mxCell id="VaYHp8SwEo52CTvzwjfN-6" value="build + deploy" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
63+
<mxGeometry x="421" y="320" width="110" height="30" as="geometry"/>
64+
</mxCell>
65+
<mxCell id="2" value="OPTIONS&lt;br&gt;Lambda" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#ffffff;fillColor=#232F3E;dashed=0;verticalLabelPosition=middle;verticalAlign=bottom;align=center;html=1;whiteSpace=wrap;fontSize=10;fontStyle=1;spacing=3;shape=mxgraph.aws4.productIcon;prIcon=mxgraph.aws4.lambda;" parent="1" vertex="1">
66+
<mxGeometry x="690" y="460" width="80" height="110" as="geometry"/>
67+
</mxCell>
68+
<mxCell id="3" value="" style="endArrow=none;html=1;" parent="1" source="2" target="ulep6MaeRu_wHvCxp79e-13" edge="1">
69+
<mxGeometry width="50" height="50" relative="1" as="geometry">
70+
<mxPoint x="520" y="430" as="sourcePoint"/>
71+
<mxPoint x="570" y="380" as="targetPoint"/>
72+
<Array as="points">
73+
<mxPoint x="730" y="360"/>
74+
</Array>
75+
</mxGeometry>
76+
</mxCell>
77+
</root>
78+
</mxGraphModel>
79+
</diagram>
80+
</mxfile>

architecture.png

40.7 KB
Loading

0 commit comments

Comments
 (0)