Deploy the App
Before we build and publish our app, we should free up some memory on the Cloud9 instance.
- Go to the terminal tab that is running the development webserver (where you ran npm start)
- Press Control-C to interrupt the development webserver and kill it.
- Close the preview browser.
The AWS Amplify CLI makes it easy to deploy our app to a bucket on S3 for secure https access using CloudFront distribution.
- Run the following command and select deployment mode (for this workshop, select PROD), and respond to the questions (you can accept the default value of index.html for the index and error doc).
- The output of the above command will look like:
Admin:~/environment/kendra-poc (master) $ amplify hosting add
? Select the environment setup: PROD (S3 with CloudFront using HTTPS)
? hosting bucket name kendrapoc-20191015231207-hostingbucket
? index doc for the website index.html
? error doc for the website index.html
You can now publish your app using the following command:
Command: amplify publish
- The amplify publish command includes an amplify push but also publishes changes to our hosted app
- Wait while Amplify builds a production version of our app, deploys it to the hosting bucket and creates a CloudFront distribution. This process can take up about 20 minutes.
- After the build and deploy finishes, you will see a URL for the version of deployed app. Any time you make new changes to the app, just re-run amplify publish, whenever you want to push a new build out.
- Use the URL and try out the app. You can also try the app from phone browser signed in as a fan. Try the use case where a fan (or many fans) are signed in on their mobile browsers while the operator creates a replay and it is available to the fans in near real-time.
Tip: Due to the cache at the CloudFront, the newly deployed version may not become accessible from the browser immediately after deployment. One way to get around this is to invalidate the CloudFront distribution cache.
Congratulations!
While we can always add more features, we have come a long way towards creating a Kendra index and building a search web app with access control management. That too in just a matter of a few hours! Here is a reminder of everything we accomplished.
- Created a Kendra index and configured an S3 bucket as a data-source
- Created a lambda event handler that handles the event of a file being added to the S3 bucket and ingests it in the Kendra index with appropriate user access attributes based on the subfolder the file was uploaded.
- Created a Web App to make the searches
- Configured Cognito user-pools for authentication and identity-pools for authorization.
- Built a production-ready version of the app and deployed it to S3 and CloudFront for secure web hosting
Info: Note that the Kendra service and the app is entirely serverless, which means it is cost efficient, scalable, and highly available thanks to services from AWS.
Note also that Kendra does not enforce access control however provides user context attributes. The authentication and authorization are taken care of by the application.
- The user attributes of the files/documents with respect to which groups can access which files are set in the lambda event handler while ingesting these files in the Kendra index
- Cognito based user authentication, authorization and groups are used by the application to figure out which user belongs to which group and this is included in the query that is sent by the application to the Kendra index.
Not bad for a few hours of work! Please give yourself a huge pat on the back for making it all the way to the end! Now that you have come this far, please don’t forget to clean up.