Terraform Module to create the DNS entries for GitHub Pages.
This was developed primarily for myself, but I am releasing it in the hopes it helps someone else. This works only with Cloudflare DNS.
This will create A and AAAA records for the apex of your domain name. If you do not want this, you can set use_apex
to false
in the module block. You should use CNAMEs in that case by specifying them in the gh_pages_cnames
set.
Note: This does not create the repository.
This can be found on the Terraform Registry.
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0"
}
}
}
provider "cloudflare" {
api_token = var.cf_api_token
}
module "example" {
source = "robbyoconnor/github-pages-dns/cloudflare"
version = "1.0.0"
gh_username = "robbyoconnor" # optional, if you enable cnames, it will use this to generate username.github.io
gh_pages_cnames = ["www", "anotherone", "thrice"] # optional
cf_zone_id = var.cf_zone_id
cf_api_token = var.cf_api_token
}
Name | Version |
---|---|
cloudflare | ~> 3.0 |
Name | Version |
---|---|
cloudflare | 3.1.0 |
No modules.
Name | Type |
---|---|
cloudflare_record.apex_a_records | resource |
cloudflare_record.apex_aaaa | resource |
cloudflare_record.cnames | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
cf_api_token | This is the API token. You can obtain it at https://dash.cloudflare.com/profile/api-tokens | string |
n/a | yes |
cf_zone_id | The ID of the cloudflare zone | string |
n/a | yes |
gh_pages_cnames | CNAMEs for your github pages. This can span multiple repositories. | set(string) |
[] |
no |
gh_pages_ipv4 | IPv4 records for GitHub pages | list(string) |
[ |
no |
gh_pages_ipv6 | IPv6 records for GitHub pages | list(string) |
[ |
no |
gh_username | Your github username (or org name). Required if CNAMEs are specified. | string |
"" |
no |
use_apex | Sometimes people don't use the apex and rather use a subdomain, in that case, a CNAME is fine. | bool |
true |
no |
No outputs.