docs
Initial Deployment
CDK
CDK .env

Setting Up Your .env File for CDK 📝

To run our bootstrap and deploy commands for staging and production environments, we'll need to set up the .env file with the appropriate values.

1. Create the .env File 📂

  • Navigate to the cdk folder in the root directory of your project.
  • Locate the file named .env.example.
  • Copy and rename it to .env.

Your .env file should now look like this with default values:

Create Permission Set

2. Configure the .env File ⚙️

⚠️ You can change the default values if needed, but for practice, I recommend sticking with the default settings.

The .env file contains two sections: PRODUCTION, and STAGING.

  • Uncomment the section for the environment you want to use.
  • Comment out the other section.

For example, to bootstrap and deploy for Staging:

  • Uncomment the Staging section.
  • Comment out the Production section.

Common values ✨

  • AWS_REGION: The AWS region where your deployment will occur.
  • PORT: The port number on which the server will run.

ENV and Account ID ✅

  • ENVIRONMENT: The current environment where the application is running, such as staging, or production.
  • AWS_ACCOUNT_ID: Your AWS account ID.

Find Your AWS Account ID 🔍

Let's log in to your user account from the AWS Access Portal URL (hopefully, you bookmarked it!):

  1. Log In: Access the AWS Access Portal and sign in with your credentials.
  2. Locate Account ID: Once logged in, you'll see a 12-digit number—this is your AWS account ID. Create Permission Set
  3. Copy Account IDs: Copy the account ID for each account (Production and Staging).
  4. Update .env: Paste the account IDs into the AWS_ACCOUNT_ID field for each environment accordingly.

Database Configuration 🗄️

These variables will be used directly when creating your RDS instance on AWS:

DB_NAME=launchgoatProd
DB_USERNAME=launchgoatProdAdmin
DB_SECRET_NAME=launchgoatProdDbPwdSecret
DB_PORT=5432

Domain Configuration 🌐

  • DOMAIN_NAME: Leave this blank for now. We'll add it when deploying to your domain name.
  • SUBDOMAIN: The subdomain for your backend API calls (i.e. api.your-company-name.com).

GitHub Repository Setup 🐙

Provide the details of the GitHub repository you'll deploy to:

GITHUB_ORG=your-github-organization
GITHUB_REPO=your-github-repo
GITHUB_BRANCH=main
  • GITHUB_ORG: Your GitHub organization or username (i.e. awslaunchgoat).
  • GITHUB_REPO: The name of your repository (i.e. awslaunchgoat-backend).
  • GITHUB_BRANCH: The branch you want to deploy from.

⚠️ Make sure to enter values for these fields, as they are required for deployment.

One-Time Deployment Notice ⚠️

  • This CDK .env file will be used only once during the initial bootstrapping and deployment process.

  • For subsequent deployments, we'll use GitHub CI/CD with the main.yml file, which also contains an .env section. No Worries! Sounds complicated? Don't worry—we'll guide you through each step! 😊

Ready to Run Commands! 🚀

Awesome! Your CDK .env file is now configured, and you're ready to run cdk bootstrap!