This project leverages the AWS Cloud Development Kit (CDK) to facilitate the configuration, deployment, operation and maintenance of tagbase-server in AWS.
This project was born out of the need to implement cloud-based persistent storage for PostgreSQL data; essentially eTUFF data stored in TagbaseDB.
Without going any further, it will benefit you to learn about AWS CDK
The project is modularized such that you can develop, test, deploy and maintain individual subsystems independently. In AWS language, each module is referred to as a Stack. For example, the TagbaseDB Stack manages resources such as a PostgreSQL-backed AWS RDS deployment and associated resources such as a security groups, inbound and outbound rules, etc.
- Python 3.6; or later including
pip
andvirtualenv
- NodeJS; long term support (LTS)
- AWS CDK; follow the tutorial thoroughly... it will way off.
Define the following global environment variables
TAGBASE_AWS_ACCOUNT
: The AWS account number to use for the deploymentTAGBASE_DEFAULT_REGION
: The target AWS region
The cdk.json
file tells the CDK Toolkit how to execute the app.
This project is set up like a standard Python project. The initialization
process also creates a virtualenv within this project, stored under the .venv
directory. To create the virtualenv it assumes that there is a python3
(or python
for Windows) executable in your path with access to the venv
package. If for any reason the automatic creation of the virtualenv fails,
you can create the virtualenv manually.
To manually create a virtualenv on MacOS and Linux:
$ python3 -m venv .venv
After the init process completes and the virtualenv is created, you can use the following step to activate your virtualenv.
$ source .venv/bin/activate
If you are a Windows platform, you would activate the virtualenv like this:
% .venv\Scripts\activate.bat
To deactivate the vurtualenv, do this:
% deactivate
Once the virtualenv is activated, you can install the required dependencies.
$ pip install -r requirements.txt
Bootstrap the CDK deployment
% cdk bootstrap
At this point you can now synthesize the CloudFormation template for this code.
$ cdk synth
N.B. If you are warned about runtime issues due to your node version not being supported, then you should upgrade to a supported node version as indicated in the warnings.
To add additional dependencies, for example other CDK libraries, just add
them to the setup.py
file and rerun the pip install -r requirements.txt
command.
There are a few options for deploying.
This deploys both the VPC and PostgreSQL stacks.
% cdk deploy --all
Assumes that you already have a host VPC and wish to deploy the TagbaseDB stack into it.
% cdk deploy tagbase-db-stack
cdk ls
list all stacks in the appcdk synth
emits the synthesized CloudFormation templatecdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk docs
open CDK documentation
Enjoy!