Using example.com as the input domain, this module will:
- Create a Route53 zone for example.com
- Create a bucket named example.com
- Create a bucket named www.example.com
- Create a Route53 A record example.com for the static website bucket of example.com
- Create a Route53 A record www.example.com for the static website bucket of www.example.com
This is possibly the simplest way of sending traffic from one domain to another using AWS services. The only caveat is that two bucket names needs to be available on AWS S3.
- Put main.tf in a module folder, for example
modules/site-redirect/main.tf
Use module like this within your terraform plan:
module "redirect_example_com" {
source = "modules/site-redirect"
domain = "example.com"
redirect = "https://send.traffic.here.example.com"
# Accepts a provider, if you have multiple defined
providers {
"aws" = "aws"
}
}
Credits and inspiration:
@SeamlessIO I was considering that the provider had the appropriate role to execute all of the above resources. I am not sure what the policy above is for - for the executing user? If I am missing something, please do let me know :)