Skip to content

Commit c2c11b5

Browse files
authored
Update Lambda Runtime and React to latest (#56)
* GitHub Action to copy static workshop resources to S3 bucket for CloudFormation deployments * Cloud9 now requires the ImageId property * Update Lambda runtime to Java 21 * Updating React web app to work with Node 16+ * Updating the Lambda Authorizer to use the Auth0 JWT library to be compatible with Java 21
1 parent fa32554 commit c2c11b5

File tree

27 files changed

+19404
-556
lines changed

27 files changed

+19404
-556
lines changed

lab2/client/package-lock.json

Lines changed: 18864 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lab2/client/package.json

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
"description": "Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. \nPermission is hereby granted, free of charge, to any person obtaining a copy of this \nsoftware and associated documentation files (the 'Software'), to deal in the Software \nwithout restriction, including without limitation the rights to use, copy, modify,\nmerge, publish, distribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so.\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\nINCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\nPARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
55
"private": true,
66
"dependencies": {
7-
"@fortawesome/fontawesome-svg-core": "^1.2.36",
8-
"@fortawesome/free-solid-svg-icons": "^5.15.4",
9-
"@fortawesome/react-fontawesome": "^0.1.16",
10-
"axios": "^0.24.0",
11-
"bootstrap": "^4.6.1",
12-
"jsonwebtoken": "^8.5.1",
13-
"moment": "^2.29.1",
7+
"@fortawesome/fontawesome-svg-core": "^6.5.1",
8+
"@fortawesome/free-solid-svg-icons": "^6.5.1",
9+
"@fortawesome/react-fontawesome": "^0.2.0",
10+
"axios": "^1.6.7",
11+
"bootstrap": "^5.3.3",
12+
"crypto-browserify": "^3.12.0",
13+
"jwt-decode": "^4.0.0",
14+
"moment": "^2.30.1",
1415
"npm-force-resolutions": "^0.0.10",
15-
"prop-types": "^15.7.2",
16-
"react": "^16.14.0",
17-
"react-bootstrap": "^1.6.4",
18-
"react-dom": "^16.14.0",
19-
"react-redux": "^7.2.6",
20-
"react-router-dom": "^5.3.0",
21-
"react-scripts": "^4.0.1",
22-
"redux": "^4.1.2",
23-
"redux-thunk": "^2.4.1",
16+
"prop-types": "^15.8.1",
17+
"react": "^18.2.0",
18+
"react-bootstrap": "^2.10.1",
19+
"react-dom": "^18.2.0",
20+
"react-redux": "^9.1.0",
21+
"react-router-dom": "^6.22.2",
22+
"react-scripts": "^5.0.1",
23+
"redux": "^5.0.1",
24+
"redux-thunk": "^3.1.0",
2425
"request": "^2.88.2"
2526
},
2627
"resolutions": {
@@ -32,7 +33,6 @@
3233
"ansi-html": "https://registry.npmjs.org/ansi-html-community/-/ansi-html-community-0.0.8.tgz"
3334
},
3435
"scripts": {
35-
"preinstall": "([ ! -f package-lock.json ] && npm install --package-lock-only --ignore-scripts --no-audit); npx npm-force-resolutions",
3636
"start": "react-scripts start",
3737
"build": "react-scripts build",
3838
"test": "react-scripts test",
@@ -52,5 +52,8 @@
5252
"last 1 firefox version",
5353
"last 1 safari version"
5454
]
55+
},
56+
"devDependencies": {
57+
"@babel/plugin-proposal-private-property-in-object": "^7.21.11"
5558
}
5659
}

lab2/client/src/App.css

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1515
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1616
*/
17-
.App {
17+
.App {
1818
text-align: center;
1919
}
2020

@@ -47,3 +47,34 @@
4747
transform: rotate(360deg);
4848
}
4949
}
50+
51+
.container-fluid .jumbotron, .container .jumbotron {
52+
border-radius: 6px;
53+
padding-left: 15px;
54+
padding-right: 15px;
55+
}
56+
57+
@media screen and (min-width: 768px)
58+
{
59+
.container-fluid .jumbotron, .container .jumbotron {
60+
padding-left: 60px;
61+
padding-right: 60px;
62+
}
63+
}
64+
65+
@media screen and (min-width: 768px)
66+
{
67+
.jumbotron {
68+
padding-bottom: 48px;
69+
padding-top: 48px;
70+
}
71+
}
72+
73+
.jumbotron {
74+
background-color: #eee;
75+
padding-left: 60px;
76+
padding-right: 60px;
77+
margin-bottom: 30px;
78+
padding-bottom: 30px;
79+
padding-top: 30px;
80+
}

lab2/client/src/App.js

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1616
*/
1717
import React from 'react';
18-
import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom';
18+
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
1919
import { Provider, connect } from 'react-redux';
2020
import Container from 'react-bootstrap/Container';
21-
import Jumbotron from 'react-bootstrap/Jumbotron';
2221

2322
import {
2423
Navigation,
@@ -42,14 +41,41 @@ const App = ({ store, currentUser }) => {
4241
<Navigation />
4342
</Container>
4443
<Container>
45-
<Jumbotron>
46-
<Route exact={true} path='/'>
47-
{isAuthenticated ? <Redirect to="/dashboard" /> : <Home /> }
48-
</Route>
49-
<PrivateRoute path='/dashboard' component={Dashboard} />
50-
<PrivateRoute path='/products' component={Products} />
51-
<PrivateRoute path='/orders' component={Orders} />
52-
</Jumbotron>
44+
<div class="jumbotron">
45+
<Routes>
46+
<Route
47+
exact={true}
48+
path="/"
49+
element={
50+
isAuthenticated ? <Navigate to="/dashboard" /> : <Home />
51+
}
52+
/>
53+
<Route
54+
path="/dashboard"
55+
element={
56+
<PrivateRoute currentUser={currentUser}>
57+
<Dashboard />
58+
</PrivateRoute>
59+
}
60+
/>
61+
<Route
62+
path="/products"
63+
element={
64+
<PrivateRoute currentUser={currentUser}>
65+
<Products />
66+
</PrivateRoute>
67+
}
68+
/>
69+
<Route
70+
path="/orders"
71+
element={
72+
<PrivateRoute currentUser={currentUser}>
73+
<Orders />
74+
</PrivateRoute>
75+
}
76+
/>
77+
</Routes>
78+
</div>
5379
</Container>
5480
<Container>
5581
<Footer />

lab2/client/src/components/navigation/component/privateRoute.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@
1414
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1515
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1616
*/
17-
import React from 'react';
18-
import { Redirect, Route } from 'react-router-dom';
17+
import { Navigate } from 'react-router-dom';
1918
import { connect } from 'react-redux';
2019

21-
const PrivateRoute = ({ component: Component, currentUser, ...rest }) => (
22-
<Route { ...rest } render={props => (
23-
currentUser.isAuthenticated
24-
? <Component { ...props } />
25-
: <Redirect to='/' />
26-
)} />
27-
);
20+
const PrivateRoute = ({ currentUser, children }) => {
21+
if (!currentUser.isAuthenticated) {
22+
return <Navigate to='/' replace={true} />;
23+
}
24+
return children;
25+
};
2826

2927
const mapStateToProps = state => {
3028
return {

lab2/client/src/components/user/actions/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1616
*/
1717
import Axios from 'axios';
18-
import jwt from 'jsonwebtoken';
18+
import { jwtDecode } from 'jwt-decode';
1919
import config from '../../../shared/config';
2020
import {
2121
RECEIVE_AUTHENTICATE_USER,
@@ -53,7 +53,7 @@ export const authenticateUser = (userChallenge) => {
5353
sessionStorage.setItem('isAuthenticated', 'true');
5454
sessionStorage.setItem('idToken', idToken);
5555

56-
const decoded = jwt.decode(idToken);
56+
const decoded = jwtDecode(idToken);
5757
const user = {
5858
firstName: decoded.given_name,
5959
lastName: decoded.family_name,

lab2/client/src/components/user/reducers/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import {
2020
REQUEST_REGISTER_USER,
2121
RECEIVE_REGISTER_USER,
2222
} from '../actionTypes';
23-
import jwt from 'jsonwebtoken';
23+
import { jwtDecode } from 'jwt-decode';
2424

2525
const isAuthenticated = sessionStorage.getItem('isAuthenticated');
2626
const idToken = sessionStorage.getItem('idToken');
27-
const decoded = jwt.decode(idToken);
27+
const decoded = idToken ? jwtDecode(idToken) : null;
2828

2929
const initialState = {
3030
firstName: decoded ? decoded.firstName : null,

lab2/client/src/store/configureStore.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1616
*/
1717
import { createStore, applyMiddleware } from 'redux';
18-
import thunk from 'redux-thunk';
18+
import { thunk } from 'redux-thunk';
1919
import { rootReducer } from '../reducers';
2020

2121
const configureStore = () => {

lab2/client/src/store/configureStore.prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1616
*/
1717
import { createStore, applyMiddleware } from 'redux';
18-
import thunk from 'redux-thunk';
18+
import { thunk } from 'redux-thunk';
1919
import { rootReducer } from '../reducers';
2020

2121
const configureStore = () => {

resources/lab1.template

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ Resources:
444444
Properties:
445445
FunctionName: !Sub saas-factory-srvls-wrkshp-clear-bucket-lab1-${AWS::Region}
446446
Role: !GetAtt LambdaExecutionRole.Arn
447-
Runtime: java8
447+
Runtime: java21
448448
Timeout: 900
449449
MemorySize: 1024
450450
Handler: com.amazon.aws.partners.saasfactory.ClearS3Bucket
@@ -470,7 +470,7 @@ Resources:
470470
Properties:
471471
FunctionName: !Sub saas-factory-srvls-wrkshp-create-keypair-${AWS::Region}
472472
Role: !GetAtt LambdaExecutionRole.Arn
473-
Runtime: java8
473+
Runtime: java21
474474
Timeout: 300
475475
MemorySize: 1024
476476
Handler: com.amazon.aws.partners.saasfactory.CreateKeyPair
@@ -998,7 +998,7 @@ Resources:
998998
Properties:
999999
FunctionName: !Sub saas-factory-srvls-wrkshp-ssm-secure-${AWS::Region}
10001000
Role: !GetAtt LambdaExecutionRole.Arn
1001-
Runtime: java8
1001+
Runtime: java21
10021002
Timeout: 300
10031003
MemorySize: 1024
10041004
Handler: com.amazon.aws.partners.saasfactory.SSMPutParamSecure
@@ -1075,7 +1075,7 @@ Resources:
10751075
Properties:
10761076
FunctionName: !Sub saas-factory-srvls-wrkshp-bootstrap-rds-${AWS::Region}
10771077
Role: !GetAtt LambdaExecutionRole.Arn
1078-
Runtime: java8
1078+
Runtime: java21
10791079
Timeout: 900
10801080
MemorySize: 1024
10811081
VpcConfig: # Has to be a VPC Lambda because we're talking to RDS
@@ -1132,7 +1132,7 @@ Resources:
11321132
Properties:
11331133
FunctionName: !Sub saas-factory-srvls-wrkshp-rds-add-db-user-${AWS::Region}
11341134
Role: !GetAtt LambdaExecutionRole.Arn
1135-
Runtime: java8
1135+
Runtime: java21
11361136
Timeout: 900
11371137
MemorySize: 1024
11381138
VpcConfig: # Has to be a VPC Lambda because we're talking to RDS
@@ -1212,7 +1212,7 @@ Resources:
12121212
Properties:
12131213
FunctionName: !Sub saas-factory-srvls-wrkshp-rds-pooled-${AWS::Region}
12141214
Role: !GetAtt LambdaExecutionRole.Arn
1215-
Runtime: java8
1215+
Runtime: java21
12161216
Timeout: 900
12171217
MemorySize: 1024
12181218
VpcConfig: # Has to be a VPC Lambda because we're talking to RDS

0 commit comments

Comments
 (0)