-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TLS termination and Route53 DNS (#330)
* Add TLS termination and Route53 DNS * move global into environments * restructure environments out of AWS directory
- Loading branch information
Showing
35 changed files
with
283 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
...ws/environments/blake/.terraform.lock.hcl → ...rm/environments/blake/.terraform.lock.hcl
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,15 +39,16 @@ locals { | |
environment = "staging" | ||
region = "us-east-1" | ||
|
||
# TODO: Resume using this once we also Terraform the Route53 | ||
# pubpub_url = "https://v7.pubpub.org" | ||
pubpub_hostname = "blake.duqduq.org" | ||
route53_zone_id = "Z059164612717GL8VGM95" | ||
|
||
MAILGUN_SMTP_USERNAME = "[email protected]" | ||
NEXT_PUBLIC_SUPABASE_URL = "https://dsleqjuvzuoycpeotdws.supabase.co" | ||
NEXT_PUBLIC_SUPABASE_PUBLIC_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImRzbGVxanV2enVveWNwZW90ZHdzIiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODIzNTE0MjEsImV4cCI6MTk5NzkyNzQyMX0.3HHC0f7zlFXP77N0U8cS3blr7n6hhjqdYI6_ciQJams" | ||
ASSETS_BUCKET_NAME = "assets.blake.pubpub.org" | ||
} | ||
|
||
|
||
###### | ||
## | ||
## Complete generic environment | ||
|
@@ -61,6 +62,9 @@ module "deployment" { | |
environment = local.environment | ||
region = local.region | ||
|
||
pubpub_hostname = local.pubpub_hostname | ||
route53_zone_id = local.route53_zone_id | ||
|
||
MAILGUN_SMTP_USERNAME = local.MAILGUN_SMTP_USERNAME | ||
NEXT_PUBLIC_SUPABASE_URL = local.NEXT_PUBLIC_SUPABASE_URL | ||
NEXT_PUBLIC_SUPABASE_PUBLIC_KEY = local.NEXT_PUBLIC_SUPABASE_PUBLIC_KEY | ||
|
23 changes: 23 additions & 0 deletions
23
...ure/terraform/globals/.terraform.lock.hcl → ...vironments/cloudflare/.terraform.lock.hcl
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
infrastructure/terraform/environments/cloudflare/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Global Cloudflare configuration | ||
|
||
This module should generally be created by an admin, | ||
and assumees the following permissions which are sensitive: | ||
|
||
**Cloudflare read-write token** set at `CLOUDFLARE_API_TOKEN`. In general, this | ||
secret can be used for very nefarious things and should be extra sensitively protected. | ||
|
||
**AWS read-write permissions**: in `~/.aws/credentials`. see `../maskfile.md` for more info. | ||
|
||
## Relationship to AWS environments | ||
|
||
AWS environments assume existence of the Route53 zone and DNS NS records that refer authority | ||
to that zone. If you are not using Cloudflare this module is not needed for those environments, | ||
but in general to create a new env it is expected to augment this module with NS records referring | ||
to this route53 configuration for domains subordinate to that new AWS env. | ||
|
||
Therefore updates to this module, which should happen very infrequently, should be applied before | ||
you attempt to create the new AWS-ECS environment, otherwise that will fail due to the AWS Certificate | ||
Manager being unsuccessful in validating your ownership of the DNS. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# aws terraform provider config | ||
|
||
terraform { | ||
required_version = ">= 1.5.0" | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 2.0" | ||
} | ||
|
||
cloudflare = { | ||
source = "cloudflare/cloudflare" | ||
version = "~> 4.0" | ||
} | ||
} | ||
backend "s3" { | ||
bucket = "pubpub-tfstates" | ||
key = "cloudflare.tfstate" | ||
region = "us-east-1" | ||
} | ||
} | ||
|
||
|
||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
###### | ||
# | ||
## Configuration of routing from Cloudflare to Route53. | ||
# | ||
###### | ||
|
||
locals { | ||
duqduq_domain = "duqduq.org" | ||
} | ||
|
||
data "cloudflare_zone" "duqduq" { | ||
name = local.duqduq_domain | ||
} | ||
|
||
resource "aws_route53_zone" "duqduq" { | ||
name = local.duqduq_domain | ||
} | ||
|
||
# do this for all subdomains of duqduq that need to be NS'd to v7 | ||
resource "cloudflare_record" "ns" { | ||
for_each = toset(["0", "1", "2", "3"]) | ||
type = "NS" | ||
|
||
zone_id = data.cloudflare_zone.duqduq.id | ||
|
||
name = "blake.${local.duqduq_domain}" | ||
|
||
value = aws_route53_zone.duqduq.name_servers[tonumber(each.key)] | ||
} |
File renamed without changes.
Oops, something went wrong.