Documentation for our products (static site) is stored in S3. Recently, due to a new product launch, the AWS account that hosted the S3 bucket was rendered inaccessible. We had to move all the documentation to a new S3 bucket in a different AWS account. The problem we faced is how do we redirect the DNS to the new S3 bucket. We did not want to break any of the existing bookmarks. Also, I am new to hosting the documentation on S3 bucket. So, I had to figure how our documentation was being served by AWS to our customers and then come up with a migration strategy. This blog post summarizes what we did.
How AWS Serves Content from S3 bucket
From my research, we understood that our organization had configured the AWS Services in the following ways:
- Route53 service was used to register the domain docs.titaniamlabs.com.
- Cloudfront is used as the Content Distribution Network.
- A Cloudfront distribution was created to route traffic to our documentation site using the domain name.
- The Cloudfront distribution serves the content from our S3 bucket. That is, in the Cloudfront distribution our S3 bucket was set as the origin.
Redirecting DNS to Point to Our Documentation Site in a New S3 Bucket
After we understood how AWS was serving our documentation, we finalized our strategy to migrate the documentation from one S3 bucket to another. We did the followoing steps:
- Create a new S3 bucket in the new AWS account.
- Edit the CI/CD flows to update documentation to the new S3 bucket.
- Publish the documentation using CI/CD flow. Probably this is the not the right way to migrate documentation from one S3 bucket to another. But, our documentation site itself is small and rather than creating policies to allow cross-account access to S3 buckets and then do an AWS copy command, we preferred to just republish the entire site.
- Updated the Cloudfront distribution to point to our new S3 bucket as the origin.
That is it. The documentation site was now being served using the new S3 bucket. The existing bookmarks did not break.
Note that we did this activity over the weekend to minimize downtime. Our organization being a startup, we do not have a documenation site that caters to hundreds or thousands of customers. Hence, we could afford to do this kind of migration.