File tree Expand file tree Collapse file tree 5 files changed +28
-11
lines changed Expand file tree Collapse file tree 5 files changed +28
-11
lines changed Original file line number Diff line number Diff line change @@ -77,19 +77,21 @@ with custom values to setup a completely independent project:
77
77
--name "/app/aws-lambda-edge/certificateId" \
78
78
--value "<certificate-identifier>"
79
79
```
80
- 3 . Create the parameter for the test asset domain with
80
+ 3 . Create the parameters for the test stage with
81
81
```
82
82
aws ssm put-parameter --type "String" \
83
83
--name "/app/aws-lambda-edge/test/assetDomain" \
84
84
--value "test-assets.aws-lambda-edge.immutableweb.app"
85
- ```
86
- 4 . Create the parameter for the test app version with
87
- ```
85
+
88
86
aws ssm put-parameter --type "String" \
89
87
--name "/app/aws-lambda-edge/test/appVersion" \
90
88
--value "0.0.0"
89
+
90
+ aws ssm put-parameter --type "String" \
91
+ --name "/app/aws-lambda-edge/test/appConfig" \
92
+ --value '{"title":"Lambda@Edge Immutable Web App"}'
91
93
```
92
- 5 . Build and deploy the initial version with
94
+ 4 . Build and deploy the initial version with
93
95
```
94
96
nvm install
95
97
npm install
Original file line number Diff line number Diff line change 3
3
const { SSM } = require ( 'aws-sdk' )
4
4
5
5
const parameterNames = [
6
+ 'appConfig' ,
6
7
'appVersion' ,
7
8
'assetDomain'
8
9
]
@@ -18,8 +19,9 @@ const getObjectOfParameters = params => {
18
19
}
19
20
20
21
const getOptionsFromParameters = params => {
21
- const { appVersion, assetDomain } = getObjectOfParameters ( params )
22
+ const { appConfig , appVersion, assetDomain } = getObjectOfParameters ( params )
22
23
return {
24
+ config : appConfig ,
23
25
version : appVersion ,
24
26
origin : `https://${ assetDomain } `
25
27
}
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const createIndex = ( { root } ) => `
3
+ const createIndex = ( { root, config } ) => `
4
4
<!doctype html>
5
5
<html class="no-js" lang="">
6
6
<head>
@@ -13,16 +13,22 @@ const createIndex = ({ root }) => `
13
13
</head>
14
14
<body>
15
15
<div id="root"></div>
16
+ <script>window.config = JSON.parse(decodeURIComponent('${ config } '))</script>
16
17
<script src="${ root } /index.js"></script>
17
18
</body>
18
19
`
19
20
20
21
const createContent = ( {
22
+ config,
21
23
origin,
22
24
version
23
25
} ) => {
24
26
const root = [ origin , version ] . filter ( x => x ) . join ( '/' )
25
- return createIndex ( { root } )
27
+ const encodedConfig = encodeURIComponent ( config )
28
+ return createIndex ( {
29
+ root,
30
+ config : encodedConfig
31
+ } )
26
32
}
27
33
28
34
module . exports = createContent
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const port = 8080
11
11
const assetPort = 8081
12
12
const host = 'localhost'
13
13
const options = {
14
+ config : '{"title":"Lambda@Edge Immutable Web App"}' ,
14
15
origin : `http://${ host } :${ assetPort } ` ,
15
16
version : ''
16
17
}
Original file line number Diff line number Diff line change @@ -3,13 +3,19 @@ import { render } from 'react-dom'
3
3
4
4
import './main.css'
5
5
6
- const App = ( ) => (
6
+ const defaultAppConfig = {
7
+ title : 'Lambda@Edge Immutable Web App'
8
+ }
9
+
10
+ const { title } = window . config || defaultAppConfig
11
+
12
+ const App = ( { title } ) => (
7
13
< main >
8
- < h1 > Hello, world! </ h1 >
14
+ < h1 > { title } </ h1 >
9
15
< div className = 'logo' />
10
16
</ main >
11
17
)
12
- const renderApp = ( ) => render ( < App /> , document . getElementById ( 'root' ) )
18
+ const renderApp = ( ) => render ( < App title = { title } /> , document . getElementById ( 'root' ) )
13
19
14
20
if ( 'addEventListener' in document ) {
15
21
document . addEventListener ( 'DOMContentLoaded' , renderApp )
You can’t perform that action at this time.
0 commit comments