DeployFrame Docs

Deployment Configuration

Clone the repository and configure the environment variables required for deploying your AI SaaS platform

Deployment Configuration

This guide covers setting up your GitHub repository and configuring both the CDK context and environment variables required to deploy your AI SaaS platform. Setting up these configurations correctly is essential for a successful deployment of all infrastructure components.

Creating Your GitHub Personal Access Token

Create a GitHub Personal Access Token

Follow these steps to create a GitHub personal access token for AWS Amplify deployment:

  1. Log in to GitHub: Go to github.com and sign in to your account.

  2. Access Developer Settings:

    • Click on your profile photo in the top-right corner
    • Select "Settings" from the dropdown menu
    • Scroll down and click on "Developer settings" in the left sidebar
    • Click on "Personal access tokens" → "Tokens (classic)"
  3. Generate a New Token:

    • Click "Generate new token" → "Generate new token (classic)"
    • Note: You may need to confirm your password
  4. Configure Token Settings:

    • Token name: Enter a descriptive name (e.g., "AI SaaS Amplify Deployment")
    • Expiration: Choose an appropriate expiration (30 days, 60 days, or custom)
    • Scopes: Select the following permissions:
      • repo (Full control of private repositories)
      • admin:repo_hook (Full control of repository hooks)
  5. Create Token:

    • Scroll to the bottom and click "Generate token"
  6. Copy Your Token:

    • IMPORTANT: Copy the generated token immediately
    • GitHub will only show this token once
    • Store it securely for use in your .env file

Treat your token like a password. Never share it publicly or commit it to version control. If you believe your token has been compromised, revoke it immediately in GitHub and create a new one.

Repository Setup

Access Your Pre-Created Repository

After purchasing the AI SaaS Boilerplate, a private repository will be automatically created for you under the deployframe-official organization with a unique identifier.

  1. Check your email for a GitHub repository invitation
  2. The repository will be named: deployframe-official/deployframe-boilerplate-XXXXXXXXX (where XXXXXXXXX is your unique identifier)
  3. Click the invitation link in your email to accept access to the repository
  4. You will have admin access to this repository

The repository is created specifically for you and contains the complete AI SaaS Boilerplate codebase. You have full admin access and can manage it as needed.

Clone Your Repository

Clone the repository that was created for you to your local machine:

git clone https://github.com/deployframe-official/deployframe-boilerplate-XXXXXXXXX.git
cd deployframe-boilerplate-XXXXXXXXX

Replace XXXXXXXXX with your actual unique identifier from the repository name you received.

When cloning your private repository, you'll be prompted for authentication. Use your GitHub username as the username and the personal access token you created earlier as the password (GitHub has disabled password authentication for Git operations since August 2021).

Set Up Project Environment Variables

Set up environment variables for project paths that will be used throughout the deployment process:

# Set project root path
export PROJECT_ROOT=$(pwd)
export CDK_DIR=${PROJECT_ROOT}/cdk
 
echo "Project root: $PROJECT_ROOT"
echo "CDK directory: $CDK_DIR"

These environment variables will allow you to run deployment commands from any directory within your project, making the process more flexible and user-friendly.

Create and Set Up the Development Branch

The repository initially contains only the main branch. Create a dev branch for development deployment:

git checkout -b dev
git push -u origin dev

This creates a new dev branch locally, switches to it, and pushes it to the remote repository with upstream tracking. By default, the deployment will target the dev branch since the default configuration uses stage=dev.

It's recommended to start with the development environment first before deploying to production.

The repository has a monorepo structure with separate folders for frontend, backend, and infrastructure (CDK). Navigate to the CDK directory where we'll configure the deployment:

cd cdk

Understanding the Configuration Approach

The AI SaaS Boilerplate uses environment variables for all configuration settings including the application name. This approach has several advantages:

  • Consistency: All configuration is managed in one place through environment variables
  • Security: Sensitive information like API keys aren't stored in version control
  • CI/CD Friendly: Environment variables are easy to integrate with CI/CD systems like GitHub Actions
  • Flexibility: Environment-specific settings can vary between development, staging, and production

For the initial core deployment, we'll use placeholder values for third-party services like Stripe and Google OAuth. You'll update these with real values after verifying the core infrastructure.

Setting Up Environment Variables

Create Environment Variables File

Create a file named .env in your project's cdk directory:

# Application Configuration
APP_NAME=ai-saas
 
# Environment Stage
STAGE=dev
 
# AWS Configuration
AWS_DEFAULT_REGION=eu-west-2
AWS_ACCOUNT_ID=123456789012
 
# Domain Configuration (Leave empty for initial deployment)
DOMAIN_NAME=
 
# GitHub Configuration (Required for Amplify Deployment)
GITHUB_OWNER=deployframe-official
GITHUB_REPO=deployframe-boilerplate-XXXXXXXXX
GITHUB_TOKEN=your-github-personal-access-token
GITHUB_DEV_BRANCH=dev
GITHUB_PROD_BRANCH=main
 
# Stripe Integration (Placeholders for now)
STRIPE_API_PUBLIC_KEY=pk_test_placeholder
STRIPE_API_SECRET_KEY=sk_test_placeholder
STRIPE_WEBHOOK_SECRET_KEY=whsec_placeholder
 
# Google OAuth (Placeholders for now)
GOOGLE_OAUTH_CLIENT_ID=placeholder.apps.googleusercontent.com
GOOGLE_OAUTH_CLIENT_SECRET=placeholder_secret
 
# Google Analytics
GOOGLE_ANALYTICS_ID=G-PLACEHOLDER
 
# OpenAI API (Leave empty for initial deployment)
OPENAI_API_KEY=
 
# AWS Bedrock Configuration
AWS_BEDROCK_REGION=us-east-1
 
# Youtube API (Leave empty for initial deployment)
YOUTUBE_API_KEY=

Make sure to replace placeholders with your actual values:

  • Set your actual AWS account ID from the previous step
  • Update GITHUB_REPO with your actual unique repository identifier (replace XXXXXXXXX)
  • Add your GitHub personal access token to GITHUB_TOKEN
  • You can customize APP_NAME to your preferred application name
  • Leave DOMAIN_NAME and OPENAI_API_KEY empty for initial deployment
  • Other placeholder values (like Stripe and Google OAuth) can be updated later

The .env file should not be committed to version control. Make sure to add it to your .gitignore file.

Understanding Key Configuration Variables

Here's an explanation of the key configuration options used in the deployment process:

Environment Variables (in .env)

VariableDescriptionExample
APP_NAMEApplication name for resource naming and stack identificationai-saas
AWS_DEFAULT_REGIONThe AWS region for deploymenteu-west-2
AWS_ACCOUNT_IDYour AWS account ID123456789012
STAGEDeployment environment (dev, prod)dev
DOMAIN_NAMEDomain for the application (can be empty initially)``
GITHUB_OWNERGitHub organization name (deployframe-official)deployframe-official
GITHUB_REPOYour unique repository namedeployframe-boilerplate-XXXXXXXXX
GITHUB_TOKENGitHub personal access tokenghp_xxxxxxxxxxxx
GITHUB_DEV_BRANCHBranch name to use for development environmentdev
GITHUB_PROD_BRANCHBranch name to use for production environmentmain
STRIPE_API_PUBLIC_KEYStripe publishable keypk_test_...
STRIPE_API_SECRET_KEYStripe secret keysk_test_...
STRIPE_WEBHOOK_SECRET_KEYStripe webhook signing secretwhsec_...
GOOGLE_OAUTH_CLIENT_IDGoogle OAuth client ID....apps.googleusercontent.com
GOOGLE_OAUTH_CLIENT_SECRETGoogle OAuth client secretSecret value
GOOGLE_ANALYTICS_IDGoogle Analytics tracking IDG-XXXXXXXXXX
OPENAI_API_KEYOpenAI API key for AI services``
YOUTUBE_API_KEYYoutube API key for AI services``

Authentication Email Templates

The authentication system uses customizable email templates for user verification:

TemplateDescriptionLocation
verification_email_subject.txtSubject line for verification emailscdk/lib/core/auth/templates/
verification_email_body.txtBody content for verification emailscdk/lib/core/auth/templates/

These templates support the following placeholders:

  • {app_name} - Automatically replaced with your application name from the APP_NAME environment variable
  • {####} - Replaced with the verification code (required in the email body)

The system includes default templates that work well for most deployments. The templates are loaded at deployment time and can be customized if needed for specific branding requirements.

Next Steps

Now that you've configured both your CDK context and environment variables required for deployment, you're ready to proceed to the Core Deployment Process section to deploy the infrastructure using these settings.