Giter Club home page Giter Club logo

aws-serverless-webapp-workshop's Introduction

Serverless web application

This workshop shows you how to build a dynamic, serverless web application. You'll learn how to host static web resources with Amazon S3, how to use Amazon Cognito to manage users and authentication, and how to build a RESTful API for backend processing using Amazon API Gateway, AWS Lambda and Amazon DynamoDB.

Completing the workshop

The simplest way to complete the workshop is by visiting the hosted version at webapp.serverlessworkshops.io.

What's Included

This repository includes the following folders:

  • deck: PDF copies of the presentation materials for this workshop.
  • resources: Any required sample code, IAM policies, or Cloudformation templates needed to complete the workshop.
  • workshop: A Hugo site with instructions for completing the workshop.

Running locally

  1. Clone this repository.
  2. Install Hugo locally.
  3. Navigate to the workshop directory
    cd aws-serverless-webapp-workshop/workshop
  4. Launch the website locally with the following command:
    hugo serve
  5. Visit http://localhost:1313 in your browser and complete the workshop

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: MIT-0

aws-serverless-webapp-workshop's People

Contributors

amazon-auto avatar bfreiberg avatar deki avatar geseib avatar gpoul avatar guikcd avatar jbesw avatar liukkonend avatar morekaly avatar mrichman avatar peskypotato avatar rts-rob avatar samdengler avatar teknogeek0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-serverless-webapp-workshop's Issues

How to host these code on AWS S3?

Hi team,
Could you please help me fix this issue?
The AWS Amplify service is not accessible on AWS China region. So I plan to host the static site on AWS S3 and follow the tutorial to build my serverless website.
https://aws.amazon.com/getting-started/projects/build-serverless-web-app-lambda-apigateway-s3-dynamodb-cognito/module-1/

Unfortunately, I sync the site code to my bucket failed using this command.
aws s3 sync s3://wildrydes-us-east-1/WebApplication/1_StaticWebHosting/website s3://wildrydes --region cn-north-1

This is the output message.
fatal error: An error occurred (NoSuchBucket) when calling the ListObjectsV2 operation: The specified bucket does not exist

ArcGIS login issue

Been using this code to teach my beginning AWS students- great project! I've just tested this again and now having problems with the map background not loading. Looks like ArcGIS is requiring a password. After signing in and going to the rides.html page, the page now has a popup showing:

Please sign in to access the item on ArcGIS Online (0e02e6f86d02455091796eaae811d9b5)

Not sure if ArcGIS has made this data private or some other issue. Hopefully someone can let me know what a fix could be. Thanks in advance,
Bob

WildRydes Web Vue footer.vue component links are wrong

need to remove out the '.html' in the links
/wild-rydes/src/components/footer.vue

       <ul>
          <li><a href="/">Home</a></li>
          <li><a href="unicorns">Meet the Unicorns</a></li>
          <li><a href="investors">Investors & Board of Directors</a></li>
          <li><a href="faq">FAQ</a></li>
          <li><a href="apply">Apply</a></li>
        </ul>

Updates required

Delivered the webapp.serverlessworkshops.io/  for AWS re/Start alongside julbeck@ mmlm@ and we identified a number of required updates.

Section 1: Static Web Hosting
Repository

2.Create the git repository
 Step 4. Split out the WildRydesVue code into its own branch: If this step fails, and you then run sudo yum install git-subtree

If this happens, the user needs to be told to re-run step 4 above
, BEFORE going to step 5 Create a new directory for your CodeCommit repo:
This caused real problems for nearly everyone during the workshop

3.Deploy the site with the AWS Amplify Console
step 2. Underneath Deploy choose Get Started
Step missing - now requires Host your web app - Get Started
step 3.Select AWS CodeCommit and choose Continue

4.Modify
 the website
Step 1 From your Cloud9 environment open the index.html file in the /wild-rydes/public/ directory of the repository. - should be /WildRydesVue/public/

Section 2: User Management

Amplify CLI

step 3. Go to the root wild-rydes directory of the repository: - should be WildRydesVue

App Client

step 5. You will see that a new App client has been generated. Your web application is configured to use this App client via a config file located in wildrydes/src/aws-exports.js. - should be WildRydesVue/src/aws-exports.js.

Thanks !

ReferenceError: exports is not defined in ES module scope

Any solution on this

2023-08-16T06:47:53.423Z  undefined  ERROR  Uncaught Exception   {"errorType":"ReferenceError","errorMessage":"exports is not defined in ES module scope","stack":["ReferenceError: exports is not defined in ES module scope"," at file:///var/task/index.mjs:30:1"," at ModuleJob.run (node:internal/modules/esm/module_job:194:25)"]}
START RequestId: 52ab24ea-3eed-4d90-80fe-a71f0d23567d Version: $LATEST
2023-08-16T06:47:56.611Z 52ab24ea-3eed-4d90-80fe-a71f0d23567d Task timed out after 3.11 seconds

END RequestId: 52ab24ea-3eed-4d90-80fe-a71f0d23567d

amplify init create failed

Statut CREATE_FAILED :
The security token included in the request is invalid (Service: AmazonIdentityManagement; Status Code: 403; Error Code: InvalidClientTokenId; Request ID: a3bfb019-1c4f-4965-9ed0-ef7a51f6c8cf; Proxy: null)

Statut ROLLBACK_IN_PROGRESS :
The following resource(s) failed to create: [AuthRole, DeploymentBucket, UnauthRole]. Rollback requested by user.

Amplify init did not work. Lack of autorisatio. However I did create the IAM role which was supposed to have all the permissions for the workshop.

Cognito UI

Cognito UI has changed from the images included in the workshop.

Otherwise a great workshop to run through in a couple of hours.

Failure in Build

When attempting to build the project it fails, the log shows the error below:

2021-06-16T00:06:17.804Z [INFO]: # Cloning repository: https://git-codecommit.us-east-2.amazonaws.com/v1/repos/wild-rydes
2021-06-16T00:06:18.265Z [INFO]: Cloning into 'wild-rydes'...
2021-06-16T00:06:24.828Z [INFO]: remote:
2021-06-16T00:06:25.971Z [INFO]: remote: Counting objects: 0
2021-06-16T00:06:26.019Z [INFO]: remote: Counting objects: 174
2021-06-16T00:06:26.184Z [INFO]: remote: Counting objects: 174
remote: Counting objects: 174, done.
2021-06-16T00:06:28.169Z [INFO]: Receiving objects:   0% (1/174)
2021-06-16T00:06:28.181Z [INFO]: Receiving objects:   1% (2/174)
2021-06-16T00:06:28.195Z [INFO]: Receiving objects:   2% (4/174)
2021-06-16T00:06:28.232Z [INFO]: Receiving objects:   3% (6/174)

                                                                                
Receiving objects:   4% (7/174)
2021-06-16T00:06:28.238Z [INFO]: Receiving objects:   5% (9/174)
2021-06-16T00:06:28.243Z [INFO]: Receiving objects:   6% (11/174)
2021-06-16T00:06:28.244Z [INFO]: Receiving objects:   7% (13/174)
2021-06-16T00:06:28.254Z [INFO]: Receiving objects:   8% (14/174)
2021-06-16T00:06:28.254Z [INFO]: Receiving objects:   9% (16/174)
2021-06-16T00:06:28.257Z [INFO]: Receiving objects:  10% (18/174)
2021-06-16T00:06:28.257Z [INFO]: Receiving objects:  11% (20/174)

                                                                                
Receiving objects:  12% (21/174)
2021-06-16T00:06:28.259Z [INFO]: Receiving objects:  13% (23/174)
2021-06-16T00:06:28.260Z [INFO]: Receiving objects:  14% (25/174)
2021-06-16T00:06:28.261Z [INFO]: Receiving objects:  15% (27/174)
2021-06-16T00:06:28.261Z [INFO]: Receiving objects:  16% (28/174)
2021-06-16T00:06:28.261Z [INFO]: Receiving objects:  17% (30/174)
2021-06-16T00:06:28.261Z [INFO]: Receiving objects:  18% (32/174)
2021-06-16T00:06:28.267Z [INFO]: Receiving objects:  19% (34/174)
2021-06-16T00:06:28.267Z [INFO]: Receiving objects:  20% (35/174)
2021-06-16T00:06:28.268Z [INFO]: Receiving objects:  21% (37/174)
2021-06-16T00:06:28.268Z [INFO]: Receiving objects:  22% (39/174)
2021-06-16T00:06:28.271Z [INFO]: Receiving objects:  23% (41/174)
2021-06-16T00:06:28.273Z [INFO]: Receiving objects:  24% (42/174)
2021-06-16T00:06:28.273Z [INFO]: Receiving objects:  25% (44/174)
2021-06-16T00:06:28.292Z [INFO]: Receiving objects:  26% (46/174)
2021-06-16T00:06:28.292Z [INFO]: Receiving objects:  27% (47/174)
2021-06-16T00:06:28.297Z [INFO]: Receiving objects:  28% (49/174)
2021-06-16T00:06:28.297Z [INFO]: Receiving objects:  29% (51/174)
2021-06-16T00:06:28.300Z [INFO]: Receiving objects:  30% (53/174)
2021-06-16T00:06:28.306Z [INFO]: Receiving objects:  31% (54/174)
2021-06-16T00:06:28.306Z [INFO]: Receiving objects:  32% (56/174)
2021-06-16T00:06:28.306Z [INFO]: Receiving objects:  33% (58/174)
2021-06-16T00:06:28.308Z [INFO]: Receiving objects:  34% (60/174)
2021-06-16T00:06:28.308Z [INFO]: Receiving objects:  35% (61/174)
2021-06-16T00:06:28.314Z [INFO]: Receiving objects:  36% (63/174)
2021-06-16T00:06:28.320Z [INFO]: Receiving objects:  37% (65/174)

                                                                                
Receiving objects:  38% (67/174)
2021-06-16T00:06:28.320Z [INFO]: Receiving objects:  39% (68/174)
2021-06-16T00:06:28.340Z [INFO]: Receiving objects:  40% (70/174)
2021-06-16T00:06:28.344Z [INFO]: Receiving objects:  41% (72/174)
2021-06-16T00:06:28.345Z [INFO]: Receiving objects:  42% (74/174)

                                                                                
Receiving objects:  43% (75/174)
2021-06-16T00:06:28.354Z [INFO]: Receiving objects:  44% (77/174)
2021-06-16T00:06:28.356Z [INFO]: Receiving objects:  45% (79/174)
2021-06-16T00:06:28.356Z [INFO]: Receiving objects:  46% (81/174)

                                                                                
Receiving objects:  47% (82/174)

                                                                                
Receiving objects:  48% (84/174)
2021-06-16T00:06:28.358Z [INFO]: Receiving objects:  49% (86/174)
2021-06-16T00:06:28.361Z [INFO]: Receiving objects:  50% (87/174)
2021-06-16T00:06:28.367Z [INFO]: Receiving objects:  51% (89/174)
2021-06-16T00:06:28.370Z [INFO]: Receiving objects:  52% (91/174)
2021-06-16T00:06:28.370Z [INFO]: Receiving objects:  53% (93/174)
2021-06-16T00:06:28.375Z [INFO]: Receiving objects:  54% (94/174)
2021-06-16T00:06:28.375Z [INFO]: Receiving objects:  55% (96/174)

                                                                                
Receiving objects:  56% (98/174)

                                                                                
Receiving objects:  57% (100/174)
2021-06-16T00:06:28.377Z [INFO]: Receiving objects:  58% (101/174)
2021-06-16T00:06:28.380Z [INFO]: Receiving objects:  59% (103/174)
2021-06-16T00:06:28.381Z [INFO]: Receiving objects:  60% (105/174)
2021-06-16T00:06:28.382Z [INFO]: Receiving objects:  61% (107/174)
2021-06-16T00:06:28.384Z [INFO]: Receiving objects:  62% (108/174)
2021-06-16T00:06:28.384Z [INFO]: Receiving objects:  63% (110/174)

                                                                                
Receiving objects:  64% (112/174)

                                                                                
Receiving objects:  65% (114/174)
2021-06-16T00:06:28.390Z [INFO]: Receiving objects:  66% (115/174)
2021-06-16T00:06:28.390Z [INFO]: Receiving objects:  67% (117/174)
2021-06-16T00:06:28.390Z [INFO]: Receiving objects:  68% (119/174)
2021-06-16T00:06:28.391Z [INFO]: Receiving objects:  69% (121/174)

                                                                                
Receiving objects:  70% (122/174)
2021-06-16T00:06:28.391Z [INFO]: Receiving objects:  71% (124/174)
2021-06-16T00:06:28.391Z [INFO]: Receiving objects:  72% (126/174)

                                                                                
Receiving objects:  73% (128/174)

                                                                                
Receiving objects:  74% (129/174)

                                                                                
Receiving objects:  75% (131/174)
2021-06-16T00:06:28.392Z [INFO]: Receiving objects:  76% (133/174)
2021-06-16T00:06:28.394Z [INFO]: Receiving objects:  77% (134/174)
2021-06-16T00:06:28.395Z [INFO]: Receiving objects:  78% (136/174)
2021-06-16T00:06:28.395Z [INFO]: Receiving objects:  79% (138/174)

                                                                                
Receiving objects:  80% (140/174)

                                                                                
Receiving objects:  81% (141/174)

                                                                                
Receiving objects:  82% (143/174)

                                                                                
Receiving objects:  83% (145/174)

                                                                                
Receiving objects:  84% (147/174)

                                                                                
Receiving objects:  85% (148/174)

                                                                                
Receiving objects:  86% (150/174)

                                                                                
Receiving objects:  87% (152/174)

                                                                                
Receiving objects:  88% (154/174)

                                                                                
Receiving objects:  89% (155/174)
2021-06-16T00:06:28.396Z [INFO]: Receiving objects:  90% (157/174)

                                                                                
Receiving objects:  91% (159/174)

                                                                                
Receiving objects:  92% (161/174)

                                                                                
Receiving objects:  93% (162/174)

                                                                                
Receiving objects:  94% (164/174)

                                                                                
Receiving objects:  95% (166/174)

                                                                                
Receiving objects:  96% (168/174)

                                                                                
Receiving objects:  97% (169/174)

                                                                                
Receiving objects:  98% (171/174)

                                                                                
Receiving objects:  99% (173/174)
2021-06-16T00:06:28.468Z [INFO]: Receiving objects: 100% (174/174)

                                                                                
Receiving objects: 100% (174/174), 21.64 MiB | 72.17 MiB/s, done.
2021-06-16T00:06:28.469Z [INFO]: Resolving deltas:   0% (0/8)

                                                                                
Resolving deltas:  12% (1/8)

                                                                                
Resolving deltas:  25% (2/8)

                                                                                
Resolving deltas:  37% (3/8)

                                                                                
Resolving deltas:  87% (7/8)

                                                                                
Resolving deltas: 100% (8/8)

                                                                                
Resolving deltas: 100% (8/8), done.
2021-06-16T00:06:28.846Z [INFO]: # Checking for Git submodules at: /codebuild/output/src664534611/src/wild-rydes/.gitmodules
2021-06-16T00:06:28.870Z [INFO]: # Retrieving cache...
2021-06-16T00:06:28.909Z [INFO]: # Extracting cache...
2021-06-16T00:06:28.917Z [INFO]: # Extraction completed
2021-06-16T00:06:28.918Z [INFO]: # Retrieving environment cache...
2021-06-16T00:06:28.938Z [INFO]: # Retrieved environment cache
2021-06-16T00:06:28.939Z [INFO]: # Ensuring NPM package '@aws-amplify/cli' is version: 'latest'
2021-06-16T00:06:35.298Z [INFO]: # Patching NPM package '@aws-amplify/cli' from 4.29.4 to 5.0.0...
2021-06-16T00:07:29.745Z [INFO]: # Done patching NPM package '@aws-amplify/cli'
2021-06-16T00:07:35.801Z [INFO]: ## Starting Backend Build
                                 # Starting phase: build
2021-06-16T00:07:45.784Z [INFO]: �[0mAmplify AppID found: d30lcoh54e6r9b. Amplify App name is: wild-rydes�[0m
2021-06-16T00:07:45.891Z [INFO]: �[0mBackend environment prod found in Amplify Console app: wild-rydes�[0m
2021-06-16T00:07:46.703Z [WARNING]: - Fetching updates to backend environment: prod from the cloud.
2021-06-16T00:07:46.889Z [WARNING]: ✔ Successfully pulled backend environment prod from the cloud.
2021-06-16T00:07:46.893Z [INFO]: 
2021-06-16T00:07:49.894Z [INFO]: �[33mNote: It is recommended to run this command from the root of your app directory�[39m
2021-06-16T00:07:55.451Z [WARNING]: - Initializing your environment: prod
2021-06-16T00:07:55.713Z [WARNING]: ✔ Initialized provider successfully.
2021-06-16T00:07:56.014Z [WARNING]: - Updating resources in the cloud. This may take a few minutes...
2021-06-16T00:07:56.689Z [WARNING]: Error updating cloudformation stack
2021-06-16T00:07:56.691Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud
2021-06-16T00:07:56.692Z [WARNING]: ✖ There was an error initializing your environment.
2021-06-16T00:07:56.696Z [INFO]: �[0mError [ValidationError]: No updates are to be performed.�[0m
                                 �[0m    at Request.extractError (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/protocol/query.js:50:29)�[0m
                                 �[0m    at Request.callListeners (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:106:20)�[0m
                                 �[0m    at Request.emit (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:78:10)�[0m
                                 �[0m    at Request.emit (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:688:14)�[0m
                                 �[0m    at Request.transition (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:22:10)�[0m
                                 �[0m    at AcceptorStateMachine.runTo (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:14:12)�[0m
                                 �[0m    at /root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:26:10�[0m
                                 �[0m    at Request.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:38:9)�[0m
                                 �[0m    at Request.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:690:12)�[0m
                                 �[0m    at Request.callListeners (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:116:18)�[0m
                                 �[0m    at Request.emit (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:78:10)�[0m
                                 �[0m    at Request.emit (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:688:14)�[0m
                                 �[0m    at Request.transition (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:22:10)�[0m
                                 �[0m    at AcceptorStateMachine.runTo (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:14:12)�[0m
                                 �[0m    at /root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:26:10�[0m
                                 �[0m    at Request.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:38:9)�[0m
                                 �[0m    at Request.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:690:12)�[0m
                                 �[0m    at Request.callListeners (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:116:18)�[0m
                                 �[0m    at callNextListener (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:96:12)�[0m
                                 �[0m    at IncomingMessage.onEnd (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/event_listeners.js:313:13)�[0m
                                 �[0m    at IncomingMessage.emit (events.js:326:22)�[0m
                                 �[0m    at IncomingMessage.EventEmitter.emit (domain.js:483:12)�[0m
                                 �[0m    at endReadableNT (_stream_readable.js:1241:12)�[0m
                                 �[0m    at processTicksAndRejections (internal/process/task_queues.js:84:21) {�[0m
                                 �[0m  code: 'ValidationError',�[0m
                                 �[0m  time: 2021-06-16T00:07:56.689Z,�[0m
                                 �[0m  requestId: '2766a9b6-04dc-4e10-bb78-ec8887349c2f',�[0m
                                 �[0m  statusCode: 400,�[0m
                                 �[0m  retryable: false,�[0m
                                 �[0m  retryDelay: 18.478256571125627�[0m
                                 �[0m}�[0m
2021-06-16T00:07:56.717Z [ERROR]: !!! Build failed
2021-06-16T00:07:56.717Z [ERROR]: !!! Non-Zero Exit Code detected
2021-06-16T00:07:56.717Z [INFO]: # Starting environment caching...
2021-06-16T00:07:56.718Z [INFO]: # Environment caching completed
Terminating logging...

TypeError: Cannot read properties of undefined (reading 'editorTheme')

I'm following the serverless workshop guide.
When I try to configure the webapp on AWS Amplify, I get this error:
There was an error detecting your build settings. TypeError: Cannot read properties of undefined (reading 'editorTheme')
I've also tried cloning the dev branch and changing Amplify CLI version, but same result.

Capture

Frontend Build Error in Amplify

Module build failed (from ./node_modules/thread-loader/dist/cjs.js):

020-11-03T17:43:20.483Z [INFO]: ERROR Failed to compile with 1 errors5:43:20 PM 2020-11-03T17:43:20.485Z [INFO]: Module build failed (from ./node_modules/thread-loader/dist/cjs.js): Thread Loader (Worker 0) No ESLint configuration found. at PoolWorker.fromErrorObj (/codebuild/output/src472483307/src/AmplifyTest/node_modules/thread-loader/dist/WorkerPool.js:262:12) at Config.getLocalConfigHierarchy (/codebuild/output/src472483307/src/AmplifyTest/node_modules/eslint/lib/config.js:268:39) at Config.getConfigHierarchy (/codebuild/output/src472483307/src/AmplifyTest/node_modules/eslint/lib/config.js:192:43) at Config.getConfigVector (/codebuild/output/src472483307/src/AmplifyTest/node_modules/eslint/lib/config.js:299:21) at Config.getConfig (/codebuild/output/src472483307/src/AmplifyTest/node_modules/eslint/lib/config.js:342:29) at processText (/codebuild/output/src472483307/src/AmplifyTest/node_modules/eslint/lib/cli-engine.js:181:33) at CLIEngine.executeOnText (/codebuild/output/src472483307/src/AmplifyTest/node_modules/eslint/lib/cli-engine.js:690:40) at lint (/codebuild/output/src472483307/src/AmplifyTest/node_modules/eslint-loader/index.js:278:17) at transform (/codebuild/output/src472483307/src/AmplifyTest/node_modules/eslint-loader/index.js:252:18) at /codebuild/output/src472483307/src/AmplifyTest/node_modules/loader-fs-cache/index.js:127:18 at ReadFileContext.callback (/codebuild/output/src472483307/src/AmplifyTest/node_modules/loader-fs-cache/index.js:31:14) You may use special comments to disable some warnings. Use // eslint-disable-next-line to ignore the next line. Use /* eslint-disable */ to ignore all warnings in a file. 2020-11-03T17:43:20.486Z [WARNING]: ERROR Build failed with errors.

When attempting to build in AWS Amplify, following the workshop. This is from the initial deploy in the repository page of the workshop.

Initial build fails: unable to access CodeCommit repository

I was following the workshop steps, and after I was done with Static Web Hosting > Deploy, I found out that the build step failed in the deployment.
After further investigation, I found out that the permission policy attached to the Amplify IAM role is not configured to use CodeCommit.

JSON for IAM Policy for reference.
{
  "Version": "2012-10-17",
  "Statement": [
      {
          "Sid": "CLICloudformationPolicy",
          "Effect": "Allow",
          "Action": [
              "cloudformation:CreateChangeSet",
              "cloudformation:CreateStack",
              "cloudformation:DeleteStack",
              "cloudformation:DescribeChangeSet",
              "cloudformation:DescribeStackEvents",
              "cloudformation:DescribeStackResource",
              "cloudformation:DescribeStackResources",
              "cloudformation:DescribeStacks",
              "cloudformation:ExecuteChangeSet",
              "cloudformation:GetTemplate",
              "cloudformation:UpdateStack",
              "cloudformation:ListStackResources"
          ],
          "Resource": [
              "arn:aws:cloudformation:*:*:stack/amplify-*"
          ]
      },
      {
          "Sid": "CLIManageviaCFNPolicy",
          "Effect": "Allow",
          "Action": [
              "iam:ListRoleTags",
              "iam:TagRole",
              "iam:AttachRolePolicy",
              "iam:CreatePolicy",
              "iam:DeletePolicy",
              "iam:DeleteRole",
              "iam:DeleteRolePolicy",
              "iam:DetachRolePolicy",
              "iam:PutRolePolicy",
              "iam:UpdateRole",
              "iam:GetRole",
              "iam:GetPolicy",
              "iam:GetRolePolicy",
              "iam:PassRole",
              "iam:ListPolicyVersions",
              "iam:CreatePolicyVersion",
              "iam:DeletePolicyVersion",
              "iam:CreateRole",
              "iam:ListRolePolicies",
              "iam:PutRolePermissionsBoundary",
              "iam:DeleteRolePermissionsBoundary",
              "appsync:CreateApiKey",
              "appsync:CreateDataSource",
              "appsync:CreateFunction",
              "appsync:CreateResolver",
              "appsync:CreateType",
              "appsync:DeleteApiKey",
              "appsync:DeleteDataSource",
              "appsync:DeleteFunction",
              "appsync:DeleteResolver",
              "appsync:DeleteType",
              "appsync:GetDataSource",
              "appsync:GetFunction",
              "appsync:GetIntrospectionSchema",
              "appsync:GetResolver",
              "appsync:GetSchemaCreationStatus",
              "appsync:GetType",
              "appsync:GraphQL",
              "appsync:ListApiKeys",
              "appsync:ListDataSources",
              "appsync:ListFunctions",
              "appsync:ListGraphqlApis",
              "appsync:ListResolvers",
              "appsync:ListResolversByFunction",
              "appsync:ListTypes",
              "appsync:StartSchemaCreation",
              "appsync:UpdateApiKey",
              "appsync:UpdateDataSource",
              "appsync:UpdateFunction",
              "appsync:UpdateResolver",
              "appsync:UpdateType",
              "appsync:TagResource",
              "appsync:CreateGraphqlApi",
              "appsync:DeleteGraphqlApi",
              "appsync:GetGraphqlApi",
              "appsync:ListTagsForResource",
              "appsync:UpdateGraphqlApi",
              "apigateway:DELETE",
              "apigateway:GET",
              "apigateway:PATCH",
              "apigateway:POST",
              "apigateway:PUT",
              "cognito-idp:CreateUserPool",
              "cognito-identity:CreateIdentityPool",
              "cognito-identity:DeleteIdentityPool",
              "cognito-identity:DescribeIdentity",
              "cognito-identity:DescribeIdentityPool",
              "cognito-identity:SetIdentityPoolRoles",
              "cognito-identity:GetIdentityPoolRoles",
              "cognito-identity:UpdateIdentityPool",
              "cognito-idp:CreateUserPoolClient",
              "cognito-idp:DeleteGroup",
              "cognito-idp:DeleteUserPool",
              "cognito-idp:DeleteUserPoolClient",
              "cognito-idp:DescribeUserPool",
              "cognito-idp:DescribeUserPoolClient",
              "cognito-idp:ListTagsForResource",
              "cognito-idp:ListUserPoolClients",
              "cognito-idp:UpdateUserPoolClient",
              "cognito-idp:CreateGroup",
              "cognito-idp:DeleteGroup",
              "cognito-identity:TagResource",
              "cognito-idp:TagResource",
              "cognito-idp:UpdateUserPool",
              "lambda:AddPermission",
              "lambda:CreateFunction",
              "lambda:DeleteFunction",
              "lambda:GetFunction",
              "lambda:GetFunctionConfiguration",
              "lambda:InvokeAsync",
              "lambda:InvokeFunction",
              "lambda:RemovePermission",
              "lambda:UpdateFunctionCode",
              "lambda:UpdateFunctionConfiguration",
              "lambda:ListTags",
              "lambda:TagResource",
              "lambda:UntagResource",
              "lambda:DeleteFunction",
              "lambda:AddLayerVersionPermission",
              "lambda:CreateEventSourceMapping",
              "lambda:DeleteEventSourceMapping",
              "lambda:DeleteLayerVersion",
              "lambda:GetEventSourceMapping",
              "lambda:GetLayerVersion",
              "lambda:ListEventSourceMappings",
              "lambda:ListLayerVersions",
              "lambda:PublishLayerVersion",
              "lambda:RemoveLayerVersionPermission",
              "dynamodb:CreateTable",
              "dynamodb:DeleteItem",
              "dynamodb:DeleteTable",
              "dynamodb:DescribeContinuousBackups",
              "dynamodb:DescribeTable",
              "dynamodb:DescribeTimeToLive",
              "dynamodb:ListStreams",
              "dynamodb:PutItem",
              "dynamodb:TagResource",
              "dynamodb:ListTagsOfResource",
              "dynamodb:UpdateContinuousBackups",
              "dynamodb:UpdateItem",
              "dynamodb:UpdateTable",
              "dynamodb:UpdateTimeToLive",
              "s3:CreateBucket",
              "s3:ListBucket",
              "s3:PutBucketAcl",
              "s3:PutBucketCORS",
              "s3:PutBucketNotification",
              "s3:PutBucketPolicy",
              "s3:PutBucketWebsite",
              "s3:PutObjectAcl",
              "cloudfront:CreateCloudFrontOriginAccessIdentity",
              "cloudfront:CreateDistribution",
              "cloudfront:DeleteCloudFrontOriginAccessIdentity",
              "cloudfront:DeleteDistribution",
              "cloudfront:GetCloudFrontOriginAccessIdentity",
              "cloudfront:GetCloudFrontOriginAccessIdentityConfig",
              "cloudfront:GetDistribution",
              "cloudfront:GetDistributionConfig",
              "cloudfront:TagResource",
              "cloudfront:UntagResource",
              "cloudfront:UpdateCloudFrontOriginAccessIdentity",
              "cloudfront:UpdateDistribution",
              "events:DeleteRule",
              "events:DescribeRule",
              "events:ListRuleNamesByTarget",
              "events:PutRule",
              "events:PutTargets",
              "events:RemoveTargets",
              "mobiletargeting:GetApp",
              "kinesis:AddTagsToStream",
              "kinesis:CreateStream",
              "kinesis:DeleteStream",
              "kinesis:DescribeStream",
              "kinesis:PutRecords",
              "es:AddTags",
              "es:CreateElasticsearchDomain",
              "es:DeleteElasticsearchDomain",
              "es:DescribeElasticsearchDomain",
              "s3:PutEncryptionConfiguration"
          ],
          "Resource": "*",
          "Condition": {
              "ForAnyValue:StringEquals": {
                  "aws:CalledVia": [
                      "cloudformation.amazonaws.com"
                  ]
              }
          }
      },
      {
          "Sid": "CLISDKCalls",
          "Effect": "Allow",
          "Action": [
              "appsync:GetIntrospectionSchema",
              "appsync:GraphQL",
              "appsync:UpdateApiKey",
              "appsync:ListApiKeys",
              "s3:PutObject",
              "s3:GetObject",
              "s3:ListBucket",
              "s3:ListBucketVersions",
              "s3:DeleteBucket",
              "s3:DeleteBucketPolicy",
              "s3:DeleteBucketWebsite",
              "s3:DeleteObject",
              "s3:DeleteObjectVersion",
              "s3:GetBucketLocation",
              "s3:ListAllMyBuckets",
              "amplify:*",
              "amplifybackend:*",
              "sts:AssumeRole",
              "mobiletargeting:*",
              "cognito-idp:AdminAddUserToGroup",
              "cognito-idp:AdminCreateUser",
              "cognito-idp:CreateGroup",
              "cognito-idp:DeleteGroup",
              "cognito-idp:DeleteUser",
              "cognito-idp:ListUsers",
              "cognito-idp:AdminGetUser",
              "cognito-idp:ListUsersInGroup",
              "cognito-idp:AdminDisableUser",
              "cognito-idp:AdminRemoveUserFromGroup",
              "cognito-idp:AdminResetUserPassword",
              "cognito-idp:AdminListGroupsForUser",
              "cognito-idp:ListGroups",
              "cognito-idp:AdminDeleteUser",
              "cognito-idp:AdminListUserAuthEvents",
              "cognito-idp:AdminDeleteUser",
              "cognito-idp:AdminConfirmSignUp",
              "cognito-idp:AdminEnableUser",
              "cognito-idp:AdminUpdateUserAttributes",
              "cognito-idp:DescribeIdentityProvider",
              "cognito-idp:DescribeUserPool",
              "cognito-idp:DeleteUserPool",
              "cognito-idp:DescribeUserPoolClient",
              "cognito-idp:CreateUserPool",
              "cognito-idp:CreateUserPoolClient",
              "cognito-idp:UpdateUserPool",
              "cognito-idp:AdminSetUserPassword",
              "cognito-idp:ListUserPools",
              "cognito-idp:ListUserPoolClients",
              "cognito-identity:GetIdentityPoolRoles",
              "cognito-identity:SetIdentityPoolRoles",
              "cognito-identity:CreateIdentityPool",
              "cognito-identity:DeleteIdentityPool",
              "cognito-identity:ListIdentityPools",
              "cognito-identity:DescribeIdentityPool",
              "dynamodb:DescribeTable",
              "lambda:GetFunction",
              "lambda:CreateFunction",
              "lambda:AddPermission",
              "lambda:DeleteFunction",
              "iam:PutRolePolicy",
              "iam:CreatePolicy",
              "iam:AttachRolePolicy",
              "iam:ListPolicyVersions",
              "iam:ListAttachedRolePolicies",
              "iam:CreateRole",
              "iam:PassRole",
              "iam:ListRolePolicies",
              "iam:DeleteRolePolicy",
              "iam:CreatePolicyVersion",
              "iam:DeletePolicyVersion",
              "iam:DeleteRole",
              "cloudformation:ListStacks",
              "sns:CreateSMSSandboxPhoneNumber",
              "sns:GetSMSSandboxAccountStatus",
              "sns:VerifySMSSandboxPhoneNumber",
              "sns:DeleteSMSSandboxPhoneNumber",
              "sns:ListSMSSandboxPhoneNumbers",
              "sns:ListOriginationNumbers"
          ],
          "Resource": "*"
      },
      {
          "Sid": "AmplifySSMCalls",
          "Effect": "Allow",
          "Action": [
              "ssm:PutParameter",
              "ssm:DeleteParameter",
              "ssm:GetParametersByPath",
              "ssm:GetParameters",
              "ssm:GetParameter",
              "ssm:DeleteParameters"
          ],
          "Resource": "arn:aws:ssm:*:*:parameter/amplify/*"
      }
  ]
}

After attaching AWSCodeCommitReadOnly to the Amplify Service Role, the build phase was able to clone the repo.

CORS not getting enabled on POST via API Gateway

Enabling cors via API gateway doesn't return the required headers. Looks like you cannot enable CORS via API gateway if you've configured lambda as proxy integration. This is mentioned here:
https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html#how-to-cors-consolelf.

Had to manually update the lambda code to include the following:

                "Access-Control-Allow-Headers" : "Content-Type",
                "Access-Control-Allow-Methods": "OPTIONS,POST,GET"

Here's the place where you should modify in case you run into a similar issue:

        callback(null, {
            statusCode: 201,
            body: JSON.stringify({
                RideId: rideId,
                Unicorn: unicorn,
                UnicornName: unicorn.Name,
                Eta: '30 seconds',
                Rider: username,
            }),
            headers: {
                'Access-Control-Allow-Origin': '*',
                "Access-Control-Allow-Headers" : "Content-Type",
                "Access-Control-Allow-Methods": "OPTIONS,POST,GET"
            },
        });

This now makes the unicorn pop up in my requested location.

Testing Doesn't work

I have tried Node.js 18x - 12x and nothing works.

Response
{
"errorType": "ReferenceError",
"errorMessage": "require is not defined in ES module scope, you can use import instead",
"trace": [
"ReferenceError: require is not defined in ES module scope, you can use import instead",
" at file:///var/task/index.mjs:4:25",
" at ModuleJob.run (node:internal/modules/esm/module_job:194:25)"
]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.