docs
DNS Setting
Production

Domain Bought on Other Provider - Production 🌐

In this guide, we’ll walk you through setting up the subdomain api.yourdomain for production. We'll assume that you’ve already purchased the domain through GoDaddy, but the steps can be applied to any other domain provider as well.

Setting Up DNS for Production 🚀

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

Step 1: 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 2: Update acm-stack.ts ⚙️

Go to cdk/lib/acm-stack.ts and uncomment the line 28 and comment out line 27

Create Permission Set

Step 3: 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 4: 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 5: 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 6: 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.
  3. Don't wait until it's finished, go to Step 7 right now.
Step 7: Very Important Part!!

After running cdk deploy, our code creates a new hosted zone for yourdomain in Route 53.

Create Permission Set

However, the deployment won’t complete and gets stuck because your domain provider, such as GoDaddy, controls the DNS and is unaware of the existence of subdomains like api.awslaunchgoat.com that we just created in AWS.

Search for Route 53 in the AWS Management Console, go to the Hosted zones tab, then click on your Hosted zone name and copy the values for the NS record.

Create Permission Set

Step 8: Add NS Record

Now go to your DNS provider, which in our case is GoDaddy. We will start adding a new NS record, one by one.

Create Permission Set

Choose type NS, enter api in the name field, and paste the value in the value field.

Create Permission Set

Add the remaining NS values.

Create Permission Set

Once you've added all the NS values, the DNS will propagate, and your cdk deploy will complete successfully.

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!