The 'stack' command
The stack
command is used to manage so-called “stacks”.
Stacks
A stack is a part of OwnStats that fulfils specific purposes:
backend
: The backend contains the necessary AWS infrastructure resources, like CloudFront Distributions, S3 Buckets, Kinesis Data Firehose and the Lambda function to aggregate and query the datafrontend
: The frontend is a React SPA application that uses DuckDB to cache the web analytics data from S3 to guarantee very fast query response timesclient
: The client is the actual JavaScript tracking library that can be integrated and loaded from websites that need to be tracked
Stack-specific actions
Not all stacks make use of every action, please have a look below for the details.
Backend
The backend
stack supports the following:
install
: This will install the necessary dependencies for the backend stack with npm.deploy
: This will deploy the backend stack to your AWS account that. Usually, this will take 5-10 minutes.package
: This will package the CloudFormation IaC, and the deployment artefacts (e.g. Lambda functions), but not actually deploy the stack.remove
: This will remove (delete) the backend stack from your AWS account. It’s possible that you might have to manually clean the S3 Buckets before the stack can fully be removed.
Frontend
The frontend
stack supports the following:
install
: This will install the necessary dependencies for the frontend stack with npm.build
: This builds the frontend React application distribution with Vite, so that it can be synced to the frontend S3 Bucket via thesync
action.sync
: This syncs the contents of thefrontend/dist
directory to the frontend S3 Bucket. Thebuild
command needs to be run first.open
: This will show a clickable link to the frontend CloudFront Distribution endpoint where the frontend is available. Hint: The frontend can also run only locally vianpm run dev
in thefrontend
directory of your OwnStats installation.
Client
The client
stack supports the following:
install
: This will install the necessary dependencies for the client stack with npm.build
: This builds the client tracking scripts, so that it can be synced to the backend S3 Bucket via thesync
action.sync
: This syncs the contents of theclient/dist
directory to the backend S3 Bucket. Thebuild
command needs to be run first.
Usage
USAGE $ ownstats stack ACTION NAME
ARGUMENTS ACTION (deploy|package|remove|sync|build|install|open) The action to perform NAME (frontend|backend|client) The stack name
DESCRIPTION Interact with OwnStats stacks within an installation
Example usage
For example, if you want to deploy the backend stack, you can use the following command:
ownstats stack backend deploy
To build the frontend apllication, you could use
ownstats stack frontend build