Delete all objects, including previous versions, from the S3 bucket that contains the static website content.
Update the weighted DNS record entry that points to the S3 bucket. Apply a weight of 0. Specify the domain reset option to propagate changes immediately.
Configure webpage redirect requests on the S3 bucket with a hostname that redirects to the ALB.
Remove the weighted DNS record entry that points to the S3 bucket from the example.com hosted zone. Wait for DNS propagation to become complete.
Explanations:
Deleting all objects from the S3 bucket will remove the static website content, but it does not address the DNS configuration. The weighted routing policy will still direct traffic to the S3 bucket until the DNS changes propagate.
Updating the weight of the DNS record to 0 would stop routing traffic to the S3 bucket, but it does not take immediate effect due to the existing TTL of 1 day for the DNS record. The previous static site may still be served until the TTL expires.
Configuring redirect requests on the S3 bucket would still allow the static website to be accessed if the DNS record points to it. This option does not ensure that customers are served only dynamic content.
Removing the weighted DNS record entry that points to the S3 bucket ensures that no traffic is routed to it. Once this record is deleted, customers will only access the ALB, and the static website will no longer be displayed. This is the most effective way to ensure dynamic content is served.