SetUp AWS IOT and AWS Cognito Point and Script:
Use case is: It will automatically open police console and highlight the entry and highlights user latitude and longitude:
File that needs to be edited:
- 'aws_iot.js':
location: Hackathon-Git-Data/AWS-Files/aws/Amazon-IOT/webapp-thing/js
Create a new AWS Cognito Identity Pool
- Login to the AWS Cognito console
- Click the second blue button called "Manage Federated Identities"
- Click "Create new identity pool"
- Check the box to "Enable access to unauthenticated providers"
- The next page states "Your Cognito identites require access to your resources." This is fine, just click the blue "Allow" button to continue.
- Two new empty IAM roles are created for you, called
Cognito_MyPoolAuth_Role
andCognito_MyPoolUnauth_Role
.
- Once your pool is created, click on the "Sample Code" menu item
- Within your code, find the RED string called Identity Pool ID and record this as your IdentityPoolId.
Add permissions to users of your Identity Pool:
- Go to the AWS IAM Console
- Click Roles
- Click on the new Unauth role, such as Cognito_MyPoolUnauth_Role
- Click the "Attach Policy" button to add the appropriate permissions to your role
- For the IOT webapp, choose
AWSIoTDataAccess
or define a specific set of permissions.
Apply all settings:
- Open the Amazon-IOT/webapp-thing/js folder and locate the file
aws_config.js
- Modify the fields labeled REGION and mqttEndpoint and IdentityPoolId
- Open in the page thing1.html in your favorite browser(Hackathon-Git-Data/AWS-Files/aws/Amazon-IOT/webapp-thing/thing1.html).
- You can open the page right from within your project folder, you do not need to host it on a website.
- The page should display with a green status label saying "CONNECTED"