This repository shows how to configure a new domain on AWS, and assumes there are two AWS accounts for dev and prod.
NOTE: A production deployment should be first when provisioning a new domain.
Follow the steps below to initiate your domain configuration:
- Export the AWS production credentials to your environment.
- Configure necessary AWS resources with a new file under
./aws/<domain>.yml
. - (Optional) Configure subdomain AWS resources with another file under
./aws/<subdomain>.yml
. - Reference this file(s) under
./serverless.yml
in theresources
section. - Configure all required
dev
andprod
parameters in./serverless.yml
in thecustom.param.*
section. - Validate your configuration with the command
npm run validate:prod
. - Deploy the AWS domain resources to your
prod
environment with the commandnpm run deploy:prod
.
NOTE: You can also configure
./circleci/config.yml
to automatically handle environment-specific deployments.
During the deployment process, remember the following steps to speed-up the deployment:
- Select the created ACM certificate (
*.example.com
) and manually add the certificate records in the hosted zone you've created. - Lower the domain's hosted zone TTL (
example.com
), and revert them back once the changes are picked-up. - Manually copy the domain's hosted zone NS records (
example.com
), and paste them to your domain's registrar. - If you are deploying a CloudFront resource, remember to initiate an invalidation request.
- Revert the default domain's hosted zone TTL (
example.com
).
Note: At this point, your ACM certificate should be issued and the CloudFront resource successfully deployed.
- Export the AWS development credentials to your environment.
- Configure necessary AWS resources with a new file under
./aws/<domain>.yml
. - (Optional) Configure subdomain AWS resources with another file under
./aws/<subdomain>.yml
. - (Optional) Use CloudFormation conditions in
./aws/cfnConditions.yml
to deploydev
-only AWS resources. - Reference this file(s) under
./serverless.yml
in theresources
section. - Configure all required
dev
andprod
parameters in./serverless.yml
in thecustom.param.*
section. - Validate your configuration with the command
npm run validate:dev
. - Deploy the AWS domain resources to your
prod
environment with the commandnpm run deploy:dev
.
NOTE: You can also configure
./circleci/config.yml
to automatically handle environment-specific deployments.
During the deployment process, remember the following steps to speed-up the deployment:
- Select the created ACM certificate (
*.dev.example.com
), and manually add the certificate records in the hosted zone you've created. - Lower the domain's hosted zone TTL (
dev.example.com
), and revert them back once the changes are picked-up. - Manually copy the domain's hosted zone NS records (
dev.example.com
), and paste them to your domain's hosted zone (example.com
) in theproduction
AWS account. - If you are deploying a CloudFront resource, remember to initiate an invalidation request.
- Revert the default domain's hosted zone TTL (
dev.example.com
).
Note: At this point, your ACM certificate should be issued and the CloudFront resource successfully deployed.