This repository demonstrates how to set up the Serverless Website Analytics open project for the AWS Community Day 2024 in Columbus, Ohio. This demo is intended for educational purposes and is not configured for production use.
This repository showcases the setup and deployment of the Serverless Website Analytics project. It is part of a presentation at AWS Community Day 2024 highlighting serverless technologies and analytics.
The Serverless Web Analytics Demo SPA Application repository points to Serverless Website Analytics for demonstration purposes. The SPA application setup and configuration can be found there.
The project structure includes:
- bin/: Entry point for the CDK application
- lib/: Contains the CDK stack definitions and utility modules
- lib/stacks/: CDK stack definitions for the project
- lib/utils/: Utility modules used across the project
Ensure you have the following installed:
- Node.js and npm
- AWS CLI
- AWS CDK
-
Clone the Repository:
git clone https://github.com/cebert/serverless-website-analytics-demo cd serverless-website-analytics-demo
-
Install Dependencies:
npm install
-
Configure AWS CLI:
Ensure your AWS CLI is configured with the necessary permissions to deploy the stacks.
aws configure
-
Set Environment Variables:
Set the required environment variable to subscribe an email address to SNS alarm notifications. This is not strictly necessary but is helpful for monitoring purposes. You can store your email address an environmental variable
.bash_profile
,.zshrc
, or a.env
file:export EMAIL_ADDRESS="[email protected]"
If using a
.env
file, you can load it using thedotenv
package:npm install dotenv
Then, create a
.env
file:echo "[email protected]" > .env
This avoids needing to store a secret in source control.
Load the environment variables at the beginning of your entry file:
import * as dotenv from 'dotenv'; dotenv.config();
-
Configure Authorization: This demonstration repository does not enable access controls to demonstrate the admin page at a conference. I would encourage you to either enable Cognito authorization or at least basic HTTP auth. Serverless website analytics supports this and you simply need to enable in in configuration.
-
Bootstrap the CDK:
If this is your first time deploying a CDK app in the account/region, you need to bootstrap it:
cdk bootstrap
-
Deploy the Stacks:
Deploy the stacks using the CDK CLI:
cdk deploy --all
I do not plan on actively maintaining this sample SPA application after AWS Community Day 2024, so feel free to fork it.
This project is licensed under the MIT License. See the LICENSE file for details.
Special thanks to the contributors of the Serverless Website Analytics project.