/cambium-baseline

Baseline project to accelerate the development of HubSpot Apps

Primary LanguageTypeScriptMIT LicenseMIT

Cambium Advisors Application Baseline Project

Cambium Baseline Project Architecture

This package establishes a baseline starting point for HubSpot application projects. Follow the instructions below to start a new client project.

The Lambda functions pull in the @cambium-advisors/cambium-lib package.

Install and set up dependencies

  1. Install the AWS CDK globally. Note: even if you already have the CDK installed, you should probably update it to the latest. The CDK installed for the package will be the latest.
npm install aws-cdk -g

https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html#getting_started_install

  1. Install ncu.
npm i -g npm-check-updates
  1. Configure npm to pull from and publish to GitHub Package Registry

    1. Create a GitHub token with at least the package.read scope.
    2. Create/edit your ~/.npmrc file and add the following to it:
registry=https://registry.npmjs.org/
@cambium-advisors:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=YOUR_TOKEN

Create a new AWS account

  1. Create a new AWS account, preferrably after setting up your AWS Organization policies using AWS Control Tower and AWS Config.

  2. Add the profile configuration to ~/.aws/config. Example:

[profile NewProfile]
region = us-west-2
output = json
sso_start_url = https://yourcompany.awsapps.com/start#
sso_region = us-west-2
sso_account_id = ##################
sso_role_name = AWSAdministratorAccess
  1. Add profile credentials to /.aws/credentials
[NewProfile]
aws_access_key_id=xxxxxxxxxxxxxxxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxxxxx
aws_session_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Create the new project directory

  1. Create the project directory
mkdir new_project && cd new_project
  1. Bootstrap CDK for the new account

Note: don't forget the backslashes here

cdk bootstrap aws:\/\/ACCOUNT-NUMBER/REGION --profile NewProfile

See: https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html#getting_started_bootstrap

  1. Download the baseline snapshot and reset the repository

(Don't forget the . in the clone command. Easiest to copy and paste this exactly.)

git clone https://github.com/cambium-advisors/cambium-baseline.git . && rm -rf .git && git init && git branch -m dev
  1. Update repo dependencies
ncu -u --reject @types/node && npm i

Run your initial install

Run npm intall for each lambda directory:

npm run reinstall

Deploy your infrastructure

Update the package.json file:

  1. Change the name of the package to something meaningful for your project
  2. Change the name of the profile used in the 'deploy' script to the profile name you added to ~/.aws/config.

Now, deploy the baseline as-is in order to create the necessary database tables and secrets.

npm run deploy

Configure OAuth

  1. Create a new HubSpot Public App and get the credentials.

  2. Run createApp to finish your setup.

npm run createApp

Start building

From here you can customize the infrastructure by editing lib/cambium-baseline-stack.ts.

The OAuth handler should be ready to go as-is, but you'll need to implement any webhook processors that are required.

You will likely also want to add custom domains to your environment, by uncommenting the CustomDomain lines in the baseline stack.

Useful CDK resources