Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use module to handle redirects for 18F Jobs #410

Merged
merged 5 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform 0.11.14
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,32 @@ This repository holds the source code for configuring DNS for domains managed by
Assuming you're TTS staff, it's recommended that you **make the change in a branch on this repository itself, rather than on a fork**, because the credentials aren't shared with forks. (The `master` branch is [protected](https://help.github.com/articles/about-protected-branches/) to limit write access only to certain staff, and to ensure history doesn't get overwritten, etc.) For major changes, it is recommended to keep the TTL value low just before and during the change period in order to make it easier to verify the changes went through as expected.

1. Is the domain pointing to the right nameservers? In other words, is there a file for the domain under [`terraform/`](terraform) already?
* **Yes:** Continue to next step.
* **No:**
1. Add a file for the domain (or subdomain, if the second-level domain isn't being added), to create the [public hosted zone](http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingHostedZone.html).
* [`18f.us`](terraform/18f.us.tf) is a good example to copy from.
* You'll be using Terraform's [`aws_route53_zone`](https://www.terraform.io/docs/providers/aws/d/route53_zone.html).
1. After the pull request is merged, to get the name servers for your domain check the output for your build in [CircleCI](https://circleci.com/gh/18F/dns). If you need further assistance, check with [#admins-dns](https://gsa-tts.slack.com/messages/C4L58EQ5T).
1. Change the nameservers for the domain to point to AWS.
* For `.gov` domains, this will be done by the "domain manager" in [dotgov.gov](https://www.dotgov.gov/). The domain manager is likely someone in the respective agency's IT department.
- **Yes:** Continue to next step.
- **No:**
1. Add a file for the domain (or subdomain, if the second-level domain isn't being added), to create the [public hosted zone](http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingHostedZone.html).
- [`18f.us`](terraform/18f.us.tf) is a good example to copy from.
- You'll be using Terraform's [`aws_route53_zone`](https://www.terraform.io/docs/providers/aws/d/route53_zone.html).
1. After the pull request is merged, to get the name servers for your domain check the output for your build in [CircleCI](https://circleci.com/gh/18F/dns). If you need further assistance, check with [#admins-dns](https://gsa-tts.slack.com/messages/C4L58EQ5T).
1. Change the nameservers for the domain to point to AWS.
- For `.gov` domains, this will be done by the "domain manager" in [dotgov.gov](https://www.dotgov.gov/). The domain manager is likely someone in the respective agency's IT department.
1. Add the relevant additional [record sets](http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/rrsets-working-with.html). In Terraform, these are known as [`aws_route53_record`](https://www.terraform.io/docs/providers/aws/r/route53_record.html)s. Generally speaking, the required arguments are:
* `zone_id`
* `name`
* `type`
* Either `alias` or `records`
* If `alias`, then `evaluate_target_health` is also required and `ttl` is not allowed.
* If `records`, then `ttl` is also required and `evaluate_target_health` is not allowed.
- `zone_id`
- `name`
- `type`
- Either `alias` or `records`
- If `alias`, then `evaluate_target_health` is also required and `ttl` is not allowed.
- If `records`, then `ttl` is also required and `evaluate_target_health` is not allowed.

It's worth noting that if you are pointing to a CloudFront distro, you should use Route 53's own `alias` and not a CNAME record. In fact, CNAMEing a top-level domain (or the top level of a delegated subdomain) is not allowed in DNS. See the various examples in the repo, such as [this one](https://github.com/18F/dns/blob/deploy/terraform/usa.gov.tf#L8-L17).

On merge, changes are deployed to an AWS account hosting the Route53 records automatically by a [CircleCI](https://circleci.com/gh/18F/dns) job.

**Please note: only production systems with an ATO that are [categorized](https://before-you-ship.18f.gov/ato/levels/) as Low impact should have their DNS configuration here. If you wish to create DNS records for pre-production systems, please use the domain `sandbox.gov` which is available in the [TTS Sandbox account](https://before-you-ship.18f.gov/infrastructure/sandbox/).**

### Redirects

We are [moving](https://github.com/18F/pages-redirects/issues/149) from [pages-redirects](https://github.com/18F/pages-redirects#domain-redirects) to fully configuring them in this repository. See the [`18f_gov__join_18f_gov_redirect`](https://github.com/18F/dns/search?q=18f_gov__join_18f_gov_redirect) example.

## Public domain

This project is in the worldwide [public domain](LICENSE.md). As stated in the [license](LICENSE.md):
Expand Down
21 changes: 8 additions & 13 deletions terraform/18f.gov.tf
Original file line number Diff line number Diff line change
Expand Up @@ -645,20 +645,15 @@ resource "aws_route53_record" "18f_gov_innovation-toolkit-prototype_18f_gov_a" {
}
}

resource "aws_route53_record" "18f_gov_jobs_18f_gov_cname" {
zone_id = "${aws_route53_zone.18f_gov_zone.zone_id}"
name = "jobs.18f.gov."
type = "CNAME"
ttl = 300
records = ["d2o3l1lqmcr15h.cloudfront.net."]
}
module "18f_gov__join_18f_gov_redirect" {
source = "mediapop/redirect/aws"
version = "1.2.0"

resource "aws_route53_record" "18f_gov_join_18f_gov_cname" {
zone_id = "${aws_route53_zone.18f_gov_zone.zone_id}"
name = "join.18f.gov."
type = "CNAME"
ttl = 300
records = ["dpjnqahvua4qy.cloudfront.net"]
domains = {
"18f.gov." = ["jobs.18f.gov", "join.18f.gov"]
}

redirect_to = "https://18f.gsa.gov/join/"
}

resource "aws_route53_record" "18f_gov_lean-product-design_18f_gov_a" {
Expand Down