docs
DNS Setting
Domain bought on AWS
Production

Domain Bought on AWS - Production 🌐

In this guide, we’ll walk you through setting up the subdomain, api.yourdomain for production. You'll configure DNS records in AWS Route 53 to manage effectively.

Purchasing a New Domain on AWS 🛒

  1. Login to Production account.

    Create Permission Set

  2. Search Route 53 in the AWS Management Console.

  3. Under the Registered Domains section, click on Register domains.

  4. Search for your preferred domain, select it, and complete the registration process.

  5. Once registered, Route 53 will automatically create a Hosted Zone for your domain. This hosted zone is where you’ll configure DNS records for both production and staging environments.

    Create Permission Set


Setting Up DNS for Production 🚀

Now that we’ve successfully bought the domain, it’s time to set things up for production!

Step 1: Get Your Hosted zone ID 🔑

Copy your Hosted zone ID.

Create Permission Set

Step 2: Update acm-stack.ts ⚙️

Open cdk/lib/nested/acm-stack.ts and paste your hosted zone ID.

Create Permission Set

Step 3: Update cdk-stack.ts ⚙️

Go to cdk/lib/cdk-stack.ts and uncomment ACMStack

Create Permission Set

Go below and uncomment the ECSStack part

Create Permission Set

Step 4: Update ecs-stack.ts ⚙️

Go to cdk/lib/nested/ecs-stack.ts and update accordingly. It's just a matter of commenting out and uncommenting.

Create Permission Set

Create Permission Set

Create Permission Set

Create Permission Set

Step 5: Configure Your .env File 📝

Now, let’s configure your .env file for production.

  • Go to cdk/.env.
  • Uncomment the Production section. Staging part should be commented out.
  • Add your domain name value for the production environment. Don't add https://

For example,

Create Permission Set

Step 6: Destroy Previous Stacks 🧹

Before we deploy the new changes, let’s clean up the old stacks:

  • Run aws sso login --profile awslaunchgoat-prod to log in.
  • Run cdk destroy --qualifier launchgoat --profile awslaunchgoat-prod to delete any previously deployed stacks.
Step 7: Bootstrap and Deploy 🚀

Now that we’ve cleaned up the old stacks, let’s bootstrap and deploy the production environment:

  1. Run cdk bootstrap --qualifier launchgoat --profile awslaunchgoat-prod to prepare your AWS environment.
  2. Then, run cdk deploy --qualifier launchgoat --require-approval never --profile awslaunchgoat-prod to deploy the new stack.

Once deployment is complete, navigate to your production URL, which should be: https://api.yourdomain (opens in a new tab)

For example, in my case, it would be: https://api.awslaunchgoat.com

Create Permission Set


Congratulations! 🎉

You’ve successfully set up your DNS with HTTPS! Your API is now:

  • Securely accessible via HTTPS.
  • Load-balanced across your containers for better performance and reliability.

Isn’t that awesome? 😄 You’ve got a secure and scalable setup ready for production!