Skip to content

Commit 0ea9ad9

Browse files
committed
Add README for aws_domain_redirect.
1 parent 7e8a514 commit 0ea9ad9

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

aws_domain_redirect/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# aws_domain_redirect
2+
3+
Creates the necessary resources on AWS to implement an HTTP redirect from a domain (e.g. `redir.example.com`) to a given URL (e.g. `https://www.futurice.com/careers/women-who-code-helsinki`). Useful for creating human-friendly shortcuts for deeper links into a site, or for dynamic links (e.g. `download.example.com` always pointing to your latest release).
4+
5+
Implementing this on AWS actually requires quite a few resources:
6+
7+
- DNS records on [Route 53](https://aws.amazon.com/route53/)
8+
- A [CloudFront](https://aws.amazon.com/cloudfront/) distribution for SSL termination, for allowing secure redirection over HTTPS
9+
- An SSL certificate for the distribution from [ACM](https://aws.amazon.com/certificate-manager/)
10+
- An [S3](https://aws.amazon.com/s3/) bucket with the relevant [redirect rules](https://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html#advanced-conditional-redirects)
11+
12+
Luckily, this module encapsulates this configuration quite neatly.
13+
14+
## Example
15+
16+
Assuming you have the [AWS provider](https://www.terraform.io/docs/providers/aws/index.html) set up, and a DNS zone for `example.com` configured on Route 53:
17+
18+
```tf
19+
# "To use an ACM Certificate with CloudFront, you must request or import the certificate in the US East (N. Virginia) region."
20+
# https://docs.aws.amazon.com/acm/latest/userguide/acm-services.html
21+
# https://www.terraform.io/docs/configuration/providers.html#multiple-provider-instances
22+
provider "aws" {
23+
alias = "acm_provider" # the aws_domain_redirect module expects an "aws" provider with this alias to be present
24+
shared_credentials_file = "./aws.key" # make sure you customize this to match your regular AWS provider config
25+
region = "us-east-1" # this is the important bit, due to the aforementioned limitation of AWS regions and ACM
26+
}
27+
28+
module "my_redirect" {
29+
# Check for updates at: https://github.com/futurice/terraform-utils/compare/v3.0...master
30+
source = "git::ssh://[email protected]/futurice/terraform-utils.git//aws_domain_redirect?ref=v3.0"
31+
32+
redirect_domain = "go.example.com"
33+
redirect_url = "https://www.futurice.com/careers/"
34+
}
35+
```
36+
37+
Applying this **will take a very long time**, because both ACM and especially CloudFront are quite slow to update. After that, both `http://go.example.com` and `https://go.example.com` should redirect clients to `https://www.futurice.com/careers/`.

0 commit comments

Comments
 (0)