Coder Social home page Coder Social logo

aws-samples / aws-appsync-iot-core-realtime-dashboard Goto Github PK

View Code? Open in Web Editor NEW
112.0 14.0 31.0 6.78 MB

This sample application demonstrates a React based web dashboard receiving real-time updates from IoT sensors. The solution is built with AWS AppSync, AWS Amplify, Amazon Location Service, and AWS IoT Core technologies.

License: MIT No Attribution

JavaScript 87.92% HTML 1.34% TypeScript 8.73% CSS 2.02%
aws aws-lambda react iot graphql appsync dynamodb cognito aws-iot-core aws-iot

aws-appsync-iot-core-realtime-dashboard's Introduction

Realtime IoT Dashboard with AWS AppSync and Amazon Location Service

This application demonstrates a web application dashboard receiving real-time updates from a series of IoT sensors. It depicts a fictitious set of pH sensors deployed around the San Francisco Bay. The solution is built with React, AWS AppSync, Amazon Location Service, AWS Amplify, and AWS IoT technologies.

Image description

The sensors are represented as the colored dots. Their color will fluxuate between red, green, and yellow based on the messages received from the sensors.

Architecture

Image description

  1. The sensor component is developed with the AWS IoT Device SDK for JavaScript. The sensors are registered as Things in IoT Core and publish random values to the Cloud on a configurable frequency. Metadata about each sensor, such as its geolocation, is stored in a Thing Shadow.

  2. Rules in IoT Core subscribe to the message topic and forward the JSON payload to a Lambda function and the IoT Analytics pipeline.

  3. The Node.js Lambda function executes a GraphQL mutation in AppSync. The mutation saves the sensor's value in DynamoDB and broadcasts the value in real-time to the web dashboard. The Lambda function uses an IAM role and policy to obtain permissions to interact with AppSync.

  4. The React web dashboard application is written in JavaScript and subscribes to the AppSync sensor subscriptions. When new values are received, an Amazon Location Service map is updated in real-time to reflect the new sensor values. The application uses Cognito to authenticate users and allow them to perform the AppSync subscription.

Getting Started

Prerequisites

The following software was used in the development of this application. While it may work with alternative versions, we recommend you deploy the specified minimum version.

  1. An AWS account in which you have Administrator access.

  2. AWS CLI (v2.15.3) the AWS Command Line Interface (CLI) is used to configure your connection credentials to AWS. These credentials are used by the CDK, Amplify, and the CLI.

  3. Node.js (v18.19.0) with NPM (v10.1.0)

  4. Amplify CLI (v12.10.1) Amplify is used to create the AWS AppSync API and generate the client side Swift code to interact with AWS.

After you have installed and configured Amplify, take note of the AWS profile you selected during the configuration. If you created a profile other than default, you will need the profile name for later steps in the deployment.

Installation

Clone this code repository

$ git clone https://github.com/aws-samples/aws-appsync-iot-core-realtime-dashboard.git

Switch to the project's web folder

$ cd aws-appsync-iot-core-realtime-dashboard/web

Install the web app's Node.js packages

$ npm install

Initialize your Amplify environment

$ amplify init

? Enter a name for the environment: dev
? Choose your default editor: [select your favorite IDE]
? Select the authentication method you want to use: AWS Profile
? Please choose the profile you want to use: default

When you select your profile, make sure to select the same profile you used when configuring Amplify.

Amplify will then begin to provision your account for the project deployment.

Once your account has been provisioned, entering the 'amplify status' command will show you the resources Amplify will create in your account:

$ amplify status

Current Environment: dev

┌──────────┬───────────────────┬───────────┬───────────────────┐
│ Category │ Resource name     │ Operation │ Provider plugin   │
├──────────┼───────────────────┼───────────┼───────────────────┤
│ Auth     │ web27eb814a       │ Create    │ awscloudformation │
├──────────┼───────────────────┼───────────┼───────────────────┤
│ Geo      │ map4a1c588e       │ Create    │ awscloudformation │
├──────────┼───────────────────┼───────────┼───────────────────┤
│ Api      │ sensorsapi        │ Create    │ awscloudformation │
├──────────┼───────────────────┼───────────┼───────────────────┤
│ Function │ listsensors       │ Create    │ awscloudformation │
├──────────┼───────────────────┼───────────┼───────────────────┤
│ Function │ createsensorvalue │ Create    │ awscloudformation │
├──────────┼───────────────────┼───────────┼───────────────────┤
│ Custom   │ iotrule           │ Create    │ awscloudformation │
└──────────┴───────────────────┴───────────┴───────────────────┘

Deploy the app infrastructure to your AWS account

$ amplify push

? Are you sure you want to continue? Y
? Do you want to update code for your updated GraphQL API (Y/n) Y

? This will overwrite your current graphql queries, mutations and subscriptions Y

You will then see a series of output messages as Amplify builds and deploys the app's CloudFormation Templates, creating the app infrastucture in your AWS account.

Resources being created in your account include:

  • AppSync GraphQL API
  • DynamoDB Table
  • Cognito User Pool
  • Lambda Functions (2)
  • IoT Rule
  • Amazon Location Service Map

Install the IoT sensor simulator

Open a new terminal window then switch to the app's sensor folder (aws-appsync-iot-core-realtime-dashboard/sensor).

Install the Node js packages, and run the Node js app to create your sensor as a Thing in AWS IoT Core. It will also create and install the certificates your sensor needs to authenticate to IoT Core.

From the app's sensor folder:

$ npm install
$ node create-sensors.js [--profile] [--region]

Note - the profile and region arguments are optional. If not specified the app will create the sensors using your default AWS Profile in us-east-1

Run the web app

Start the IoT sensor

From the sensor terminal window:

$ node index.js

You will see output from the app as it connects to IoT Core and publishes new messages for six sensors every few seconds.

published to shadow topic $aws/things/sensor-sf-north/shadow/update {"state":{"reported":{"name":"SF Bay - North","enabled":true,"geo":{"latitude":37.800307,"longitude":-122.354788}}}}

published to telemetry topic dt/bay-health/SF/sensor-sf-north/sensor-value {"pH":5,"temperature":54.7,"salinity":25,"disolvedO2":6.1,"timestamp":1591831843844}

Start the web app

Switch back to the terminal window pointing to the web folder and run:

$ npm run dev

This will launch the application in your machine's default web browser.

Sign-up and Sign-in

The web app requires users to authenticate via Cognito. The first screen you will see is a logon screen. Click the Create account link and create a new account using your email address.

Cognito will then email you a confirmation code. Enter this code into the subsequent confirmation screen and logon to the app with your credentials.

Use the web app

You should now see a screen similar to the one at the top of this guide. If you look at the terminal window running the sensor app, you shoud see the values being published to the Cloud reflected in the web app's sensor icon in real-time.

Cleanup

Once you are finished working with this project, you may want to delete the resources it created in your AWS account.

From the web folder:

$ amplify delete
? Are you sure you want to continue? (This would delete all the environments of the project from the cloud and wipe out all the local amplify resource files) (Y/n)  Y

From the sensor folder:

$ node delete-sensors.js [--profile] [--region]

Note - the profile and region arguments are optional. If not specified the app will delete the sensors using your default AWS Profile in us-east-1

License

This sample code is made available under a modified MIT-0 license. See the LICENSE file.

aws-appsync-iot-core-realtime-dashboard's People

Contributors

amazon-auto avatar dave-moser avatar dependabot[bot] 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  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

aws-appsync-iot-core-realtime-dashboard's Issues

compile error

npm install fail on web folder

0 verbose cli [
0 verbose cli '/Users/jojaehyeong/.nvm/versions/node/v15.13.0/bin/node',
0 verbose cli '/Users/jojaehyeong/.nvm/versions/node/v15.13.0/bin/npm',
0 verbose cli 'install'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 3ms
5 timing config:load:file:/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 2ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/Users/jojaehyeong/aws-appsync-iot-core-realtime-dashboard/web/.npmrc Completed in 1ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:/Users/jojaehyeong/.npmrc Completed in 2ms
12 timing config:load:user Completed in 2ms
13 timing config:load:file:/Users/jojaehyeong/.nvm/versions/node/v15.13.0/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 11ms
18 timing npm:load:configload Completed in 11ms
19 timing npm:load:setTitle Completed in 2ms
20 timing npm:load:setupLog Completed in 1ms
21 timing npm:load:cleanupLog Completed in 2ms
22 timing npm:load:configScope Completed in 0ms
23 timing npm:load:projectScope Completed in 1ms
24 timing npm:load Completed in 18ms
25 timing config:load:flatten Completed in 3ms
26 timing arborist:ctor Completed in 0ms
27 timing arborist:ctor Completed in 0ms
28 timing idealTree:init Completed in 12ms
29 timing idealTree:userRequests Completed in 0ms
30 silly idealTree buildDeps
31 silly fetch manifest @babel/cli@^7.10.1
32 http fetch GET 304 https://registry.npmjs.org/@babel%2fcli 155ms (from cache)
33 silly fetch manifest @babel/core@^7.10.2
34 http fetch GET 304 https://registry.npmjs.org/@babel%2fcore 48ms (from cache)
35 silly fetch manifest @babel/preset-env@^7.10.2
36 http fetch GET 304 https://registry.npmjs.org/@babel%2fpreset-env 45ms (from cache)
37 silly fetch manifest @material-ui/core@^4.8.3
38 http fetch GET 304 https://registry.npmjs.org/@material-ui%2fcore 76ms (from cache)
39 silly fetch manifest @types/react@^16.9.17
40 http fetch GET 304 https://registry.npmjs.org/@types%2freact 54ms (from cache)
41 silly fetch manifest react@^16.12.0
42 http fetch GET 304 https://registry.npmjs.org/react 46ms (from cache)
43 silly fetch manifest react-dom@^16.12.0
44 http fetch GET 304 https://registry.npmjs.org/react-dom 61ms (from cache)
45 silly fetch manifest @material-ui/icons@^4.5.1
46 http fetch GET 304 https://registry.npmjs.org/@material-ui%2ficons 69ms (from cache)
47 silly fetch manifest @testing-library/jest-dom@^4.2.4
48 http fetch GET 304 https://registry.npmjs.org/@testing-library%2fjest-dom 1334ms (from cache)
49 silly fetch manifest @testing-library/react@^9.4.0
50 http fetch GET 304 https://registry.npmjs.org/@testing-library%2freact 72ms (from cache)
51 silly fetch manifest @testing-library/user-event@^7.2.1
52 http fetch GET 304 https://registry.npmjs.org/@testing-library%2fuser-event 73ms (from cache)
53 silly fetch manifest @testing-library/dom@>=5
54 http fetch GET 304 https://registry.npmjs.org/@testing-library%2fdom 71ms (from cache)
55 silly fetch manifest @types/chart.js@^2.9.11
56 http fetch GET 304 https://registry.npmjs.org/@types%2fchart.js 47ms (from cache)
57 silly fetch manifest @types/jest@^24.0.25
58 http fetch GET 304 https://registry.npmjs.org/@types%2fjest 55ms (from cache)
59 silly fetch manifest @types/node@^12.12.24
60 http fetch GET 304 https://registry.npmjs.org/@types%2fnode 77ms (from cache)
61 silly fetch manifest @types/react-chartjs-2@^2.5.7
62 http fetch GET 304 https://registry.npmjs.org/@types%2freact-chartjs-2 63ms (from cache)
63 silly fetch manifest @types/react-dom@^16.9.4
64 http fetch GET 304 https://registry.npmjs.org/@types%2freact-dom 50ms (from cache)
65 silly fetch manifest @types/react-map-gl@^5.1.0
66 http fetch GET 304 https://registry.npmjs.org/@types%2freact-map-gl 51ms (from cache)
67 silly fetch manifest @types/react-router-dom@^5.1.3
68 http fetch GET 304 https://registry.npmjs.org/@types%2freact-router-dom 60ms (from cache)
69 silly fetch manifest aws-amplify@^2.2.6
70 http fetch GET 304 https://registry.npmjs.org/aws-amplify 84ms (from cache)
71 silly fetch manifest aws-amplify-react@^3.1.6
72 http fetch GET 304 https://registry.npmjs.org/aws-amplify-react 46ms (from cache)
73 silly fetch manifest @aws-amplify/analytics@^2.0.0
74 http fetch GET 304 https://registry.npmjs.org/@aws-amplify%2fanalytics 551ms (from cache)
75 silly fetch manifest @aws-amplify/api@^2.0.0
76 http fetch GET 304 https://registry.npmjs.org/@aws-amplify%2fapi 487ms (from cache)
77 silly fetch manifest @aws-amplify/pubsub@^1.2.4
78 http fetch GET 304 https://registry.npmjs.org/@aws-amplify%2fpubsub 394ms (from cache)
79 silly fetch manifest @aws-amplify/auth@^2.0.0
80 http fetch GET 304 https://registry.npmjs.org/@aws-amplify%2fauth 562ms (from cache)
81 silly fetch manifest @aws-amplify/core@^2.0.0
82 http fetch GET 304 https://registry.npmjs.org/@aws-amplify%2fcore 404ms (from cache)
83 silly fetch manifest @react-native-community/netinfo@^5.5.0
84 http fetch GET 304 https://registry.npmjs.org/@react-native-community%2fnetinfo 458ms (from cache)
85 silly fetch manifest react-native@>=0.59
86 http fetch GET 304 https://registry.npmjs.org/react-native 63ms (from cache)
87 silly fetch manifest [email protected]
88 timing idealTree Completed in 5921ms
89 timing command:install Completed in 5930ms
90 verbose stack Error: unable to resolve dependency tree
90 verbose stack at Arborist.[failPeerConflict] (/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1157:25)
90 verbose stack at Arborist.[loadPeerSet] (/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1134:34)
90 verbose stack at async Arborist.[loadPeerSet] (/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1110:11)
90 verbose stack at async Arborist.[loadPeerSet] (/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1110:11)
90 verbose stack at async Arborist.[loadPeerSet] (/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1110:11)
90 verbose stack at async Arborist.[buildDepStep] (/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:838:11)
90 verbose stack at async Arborist.buildIdealTree (/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:209:7)
90 verbose stack at async Promise.all (index 1)
90 verbose stack at async Arborist.reify (/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:131:5)
90 verbose stack at async Install.install (/Users/jojaehyeong/.nvm/versions/node/v15.13.0/lib/node_modules/npm/lib/install.js:137:5)
91 verbose cwd /Users/jojaehyeong/aws-appsync-iot-core-realtime-dashboard/web
92 verbose Darwin 20.3.0
93 verbose argv "/Users/jojaehyeong/.nvm/versions/node/v15.13.0/bin/node" "/Users/jojaehyeong/.nvm/versions/node/v15.13.0/bin/npm" "install"
94 verbose node v15.13.0
95 verbose npm v7.7.6
96 error code ERESOLVE
97 error ERESOLVE unable to resolve dependency tree
98 error
99 error While resolving: �[1mdashboard�[22m@�[1m0.1.0�[22m
99 error Found: �[1mreact�[22m@�[1m16.14.0�[22m�[2m�[22m
99 error �[2mnode_modules/react�[22m
99 error �[1mreact�[22m@"�[1m^16.12.0�[22m" from the root project
99 error
99 error Could not resolve dependency:
99 error �[35mpeer�[39m �[1mreact�[22m@"�[1m17.0.1�[22m" from �[1mreact-native�[22m@�[1m0.64.0�[22m�[2m�[22m
99 error �[2mnode_modules/react-native�[22m
99 error �[35mpeer�[39m �[1mreact-native�[22m@"�[1m>=0.59�[22m" from �[1m@react-native-community/netinfo�[22m@�[1m5.9.10�[22m�[2m�[22m
99 error �[2mnode_modules/@react-native-community/netinfo�[22m
99 error �[35mpeer�[39m �[1m@react-native-community/netinfo�[22m@"�[1m^5.5.0�[22m" from �[1m@aws-amplify/core�[22m@�[1m2.3.0�[22m�[2m�[22m
99 error �[2mnode_modules/@aws-amplify/core�[22m
99 error �[35mpeer�[39m �[1m@aws-amplify/core�[22m@"�[1m^2.0.0�[22m" from �[1maws-amplify-react�[22m@�[1m3.1.9�[22m�[2m�[22m
99 error �[2mnode_modules/aws-amplify-react�[22m
99 error 3 more (@aws-amplify/analytics, @aws-amplify/api, @aws-amplify/auth)
99 error
99 error Fix the upstream dependency conflict, or retry
99 error this command with --force, or --legacy-peer-deps
99 error to accept an incorrect (and potentially broken) dependency resolution.
99 error
99 error See /Users/jojaehyeong/.npm/eresolve-report.txt for a full report.
100 verbose exit 1

Deploying stack results in a seemingly unused DynamoDB Table

Greetings,

When I run this stack in my account, I see a DynamoDB Table created with a name like SensorValue-{generated}-dev, but when I create some sensors and simulate them, I never see any items added to the Table..

I can see the incoming events in the following places though:

  • Subscribing to the topic using the web console "MQTT Test Client".
  • Querying the configured IoT Analytics dataset.
  • Checking relevant Lambda logs in CloudWatch.
  • Even in the subscription made from my local React web app..

Could somebody carify what purpose this Table serves here?

Query on iotrule

A quick query, how did you define the iotrule in the amplify backend? With the amplify CLI?

index.js not found

After following the steps, the dashboard cant be started because index.js doesn't exist.

(base) aldemim@3c22fb0301d7 web % node index.js

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module '/Users/aldemim/ws/aws-appsync-iot-core-realtime-dashboard/web/index.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}


(base) aldemim@3c22fb0301d7 web % ll
total 1288
drwxr-xr-x     7 aldemim  staff     224 Dec 10 01:05 amplify
-rw-r--r--     1 aldemim  staff     377 Dec 10 00:25 amplify.yml
-rw-r--r--     1 aldemim  staff      63 Dec 10 00:25 babel.config.js
drwxr-xr-x  1112 aldemim  staff   35584 Dec 10 00:26 node_modules
-rw-r--r--     1 aldemim  staff  641509 Dec 10 00:25 package-lock.json
-rw-r--r--     1 aldemim  staff    1566 Dec 10 00:25 package.json
drwxr-xr-x     6 aldemim  staff     192 Dec 10 00:25 public
drwxr-xr-x    15 aldemim  staff     480 Dec 10 00:28 src
-rw-r--r--     1 aldemim  staff     491 Dec 10 00:25 tsconfig.json


(base) aldemim@3c22fb0301d7 web % ll src 
total 88
-rw-r--r--  1 aldemim  staff  7249 Dec 10 01:13 API.ts
-rw-r--r--  1 aldemim  staff  1081 Dec 10 00:25 App.tsx
drwxr-xr-x  3 aldemim  staff    96 Dec 10 00:25 api
-rw-r--r--  1 aldemim  staff   692 Dec 10 01:13 aws-exports.js
drwxr-xr-x  7 aldemim  staff   224 Dec 10 00:25 components
drwxr-xr-x  6 aldemim  staff   192 Dec 10 00:25 graphql
-rw-r--r--  1 aldemim  staff   799 Dec 10 00:25 index.tsx
drwxr-xr-x  4 aldemim  staff   128 Dec 10 00:25 pages
-rw-r--r--  1 aldemim  staff    40 Dec 10 00:25 react-app-env.d.ts
-rw-r--r--  1 aldemim  staff  5213 Dec 10 00:25 serviceWorker.ts
-rw-r--r--  1 aldemim  staff   125 Dec 10 01:16 settings.json
-rw-r--r--  1 aldemim  staff   255 Dec 10 00:25 setupTests.ts
-rw-r--r--  1 aldemim  staff   366 Dec 10 00:25 theme.tsx

There was an error building the custom resources

I follow the instructions.

$ cd aws-appsync-iot-core-realtime-dashboard/web
$ npm install
$ amplify init

I got the errors.

✖ There was an error initializing your environment.
🛑 There was an error building the custom resources
Packaging overrides failed with the error
Command failed with exit code 1: yarn install
ERROR: [Errno 2] No such file or directory: 'install'

node --version
v16.17.0

npm --version
8.15.0

amplify --version
10.6.1

need update of the mapbox-gl

for the latest version of the cocoapdos, mapbox-gl can not be run on that version. Plz update of the mobile version!! thank you

Can not create sensor

$ cd sensor
$ npm install
$ node create-sensor.js

I am getting the following error after doing the commands given above:

internal/modules/cjs/loader.js:979
throw err;
^
Error: Cannot find module '~/aws-appsync-iot-core-realtime-dashboard/sensor/create-sensor.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

web compile error

I updated npm version to the latest, then compile error occurs

/Users/jojaehyeong/aws-appsync-iot-core-realtime-dashboard/web/src/components/LineChartWidget/LineChartWidget.tsx
TypeScript error in /Users/jojaehyeong/aws-appsync-iot-core-realtime-dashboard/web/src/components/LineChartWidget/LineChartWidget.tsx(7,10):
Property 'global' does not exist on type 'Defaults'. TS2339

 5 | import { ChartOptions, defaults } from 'chart.js';
 6 | 

7 | defaults.global.defaultFontColor = '#ffffff';
| ^
8 |
9 | const useStyles = makeStyles((theme: Theme) => ({
10 | paper: {

Risk: over-authorization of AWS IoT policy

We are a security research team and we recently discovered that there is an over-authorization security issue with this project's IoT policy.
The affected file is as following:

1. aws-appsync-iot-core-realtime-dashboard/sensor/policy.json

Web content is not shown due to some source map errors

I installed and deployed the demo on my local PC following steps in README.md.
When running "amplify init", there was an warning as below:
⠇ Building resource api/sensorsapi⚠️ WARNING: Schema is using an @auth directive with deprecated provider 'iam'. Replace 'iam' provider with 'identityPool' provider.
So I changed the provider to identityPool and everything was OK for "amplify init", "amplify push" and "npm run dev".
But when I opened it in Firefox, it was blank and some errors were shown on firefox debugger:

Source map error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Resource URL: null
Source Map URL: installHook.js.map

Module "events" has been externalized for browser compatibility. Cannot access "events.EventEmitter" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

Uncaught ReferenceError: global is not defined
js index.js:24
forEachArray2 index.js:12
forEach2 index.js:54
js index.js:22
__require chunk-V4OQ3NZ2.js:11
js IsTypedArrayOutOfBounds.js:11
__require chunk-V4OQ3NZ2.js:11
js TypedArrayCreateFromConstructor.js:8
__require chunk-V4OQ3NZ2.js:11
js TypedArraySpeciesCreate.js:11
__require chunk-V4OQ3NZ2.js:11
js implementation.js:16
__require chunk-V4OQ3NZ2.js:11
js index.js:6
__require chunk-V4OQ3NZ2.js:11
js index.js:4
__require chunk-V4OQ3NZ2.js:11
node_modules maplibre-gl-js-amplify.js:13657
__require chunk-V4OQ3NZ2.js:11
js constrain_feature_movement.js:7
__require chunk-V4OQ3NZ2.js:11
js move_features.js:7
__require chunk-V4OQ3NZ2.js:11
js DirectModeOverride.js:3
__require chunk-V4OQ3NZ2.js:11
js index.js:3
__require chunk-V4OQ3NZ2.js:11
AmplifyMapDraw.js:2

Source map error: No sources are declared in this source map.
Resource URL: http://localhost:5173/node_modules/.vite/deps/chunk-V4OQ3NZ2.js?v=d1a7ef4f
Source Map URL: chunk-V4OQ3NZ2.js.map

Source map error: No sources are declared in this source map.
Resource URL: http://localhost:5173/node_modules/.vite/deps/chunk-CR7QZ4QQ.js?v=d1a7ef4f
Source Map URL: chunk-CR7QZ4QQ.js.map

Source map error: No sources are declared in this source map.
Resource URL: http://localhost:5173/node_modules/.vite/deps/aws-amplify.js?v=d1a7ef4f
Source Map URL: aws-amplify.js.map

Source map error: No sources are declared in this source map.
Resource URL: http://localhost:5173/node_modules/.vite/deps/react.js?v=d1a7ef4f
Source Map URL: react.js.map

Source map error: No sources are declared in this source map.
Resource URL: http://localhost:5173/node_modules/.vite/deps/maplibre-gl.js?v=d1a7ef4f
Source Map URL: maplibre-gl.js.map

Source map error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Resource URL: null
Source Map URL: react_devtools_backend_compact.js.map

Android complier issue

Hi,
I would like to use your project for Android environment.
I am getting this Sync error when I load this Project from "https://github.com/aws-samples/aws-appsync-iot-core-realtime-dashboard/tree/master/mobile/android"
Here the error

A problem occurred evaluating settings 'mobile'.
> Could not read script 'C:\Users\XXXXXX\AndroidStudioProjects\aws-appsync-iot-core-realtime-dashboard\mobile\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' as it does not exist.

Unrecognised resource types

Any reason for this after simply running amplify push after doing amplify init?

? Do you want to update code for your updated GraphQL API Yes
? Do you want to generate GraphQL statements (queries, mutations and subscription) based on your schema types?
This will overwrite your current graphql queries, mutations and subscriptions Yes
⠸ Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS amplify-iotdashboard-testing-221143 AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:32 GMT+0100 (British Summer Time) User Initiated                                                                                                                                                         
CREATE_IN_PROGRESS iotanalyticsbatch                   AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:35 GMT+0100 (British Summer Time)                                                                                                                                                                        
CREATE_IN_PROGRESS geoiotdashboard                     AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:35 GMT+0100 (British Summer Time)                                                                                                                                                                        
CREATE_IN_PROGRESS functionlistsensors                 AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:35 GMT+0100 (British Summer Time)                                                                                                                                                                        
CREATE_IN_PROGRESS functiongetsensor                   AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:35 GMT+0100 (British Summer Time)                                                                                                                                                                        
CREATE_IN_PROGRESS authiotdashboard6b12339b            AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:36 GMT+0100 (British Summer Time)                                                                                                                                                                        
CREATE_IN_PROGRESS UpdateRolesWithIDPFunctionRole      AWS::IAM::Role             Wed Jul 06 2022 22:14:36 GMT+0100 (British Summer Time)                                                                                                                                                                        
CREATE_FAILED      iotanalyticsbatch                   AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:36 GMT+0100 (British Summer Time) Template format error: Unrecognized resource types: [AWS::IoTAnalytics::Datastore, AWS::IoTAnalytics::Channel, AWS::IoTAnalytics::Dataset, AWS::IoTAnalytics::Pipeline]
CREATE_FAILED      geoiotdashboard                     AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:36 GMT+0100 (British Summer Time) Template format error: Unrecognized resource types: [AWS::Location::Map]                                                                                               
CREATE_IN_PROGRESS functionlistsensors                 AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:36 GMT+0100 (British Summer Time) Resource creation Initiated                                                                                                                                            
CREATE_FAILED      functionlistsensors                 AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:37 GMT+0100 (British Summer Time) Resource creation cancelled                                                                                                                                            
CREATE_FAILED      UpdateRolesWithIDPFunctionRole      AWS::IAM::Role             Wed Jul 06 2022 22:14:37 GMT+0100 (British Summer Time) Resource creation cancelled                                                                                                                                            
CREATE_FAILED      functiongetsensor                   AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:37 GMT+0100 (British Summer Time) Resource creation cancelled                                                                                                                                            
CREATE_FAILED      authiotdashboard6b12339b            AWS::CloudFormation::Stack Wed Jul 06 2022 22:14:37 GMT+0100 (British Summer Time) Resource creation cancelled     

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.