-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1e01b27
Showing
8 changed files
with
210 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Crash log files | ||
crash.log | ||
|
||
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most | ||
# .tfvars files are managed as part of configuration and so should be included in | ||
# version control. | ||
# | ||
# example.tfvars | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
# Include override files you do wish to add to version control using negated pattern | ||
# | ||
# !example_override.tf | ||
|
||
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan | ||
# example: *tfplan* |
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 diademiemi | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,20 @@ | ||
# Terraform | ||
This repository contains [Terraform](https://www.terraform.io/) code used for [Queercraft](https://www.queercraft.net/)'s infrastructure. Currently we only use Terraform to manage our DNS records. We use [Cloudflare](https://www.cloudflare.com/) for DNS. | ||
|
||
You might also want to check out the [Terraform](https://www.terraform.io/) repository for the server, which can be found [here]( | ||
https://github.com/Queercraft/terraform_queercraft) | ||
|
||
## Contents | ||
Projects: | ||
Project | Description | ||
--- | --- | ||
[dns](projects/dns) | Terraform code for managing Queercraft's DNS records | ||
|
||
## Usage | ||
|
||
### DNS | ||
Enter the `projects/dns` directory and run `terraform init` to initialize the Terraform project. Then run `terraform apply` to apply the changes. You will be prompted to enter your Cloudflare API token and the Cloudflare zone ID. | ||
If you don't know it, you likely shouldn't be using this repository :). | ||
|
||
## License | ||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
resource "cloudflare_record" "tcpshield_verify" { | ||
zone_id = var.cloudflare_zone_id | ||
name = var.root_domain | ||
value = var.tcpshield_verify | ||
type = "TXT" | ||
ttl = 3600 | ||
proxied = false | ||
} | ||
|
||
resource "cloudflare_record" "tcpshield" { | ||
zone_id = var.cloudflare_zone_id | ||
name = "tcpshield" | ||
value = var.tcpshield_cname | ||
type = "CNAME" | ||
ttl = 3600 | ||
allow_overwrite = false | ||
proxied = false | ||
} | ||
|
||
resource "cloudflare_record" "minecraft_srv" { | ||
zone_id = var.cloudflare_zone_id | ||
name = "mc" | ||
type = "SRV" | ||
ttl = 1 | ||
proxied = false | ||
|
||
data { | ||
name = "mc.queercraft.net" | ||
service = "_minecraft" | ||
proto = "_tcp" | ||
target = "${cloudflare_record.tcpshield.name}.${var.root_domain}" | ||
port = 25565 | ||
weight = 1 | ||
priority = 1 | ||
} | ||
} | ||
|
||
locals { | ||
generic_subdomains = [ | ||
{ | ||
name = "staff" | ||
value = var.server_ip | ||
type = "A" | ||
ttl = 1 | ||
proxied = true | ||
allow_overwrite = false | ||
}, | ||
{ | ||
name = "mc" | ||
value = var.server_ip | ||
type = "A" | ||
ttl = 1 | ||
proxied = false # Sadly this breaks Bedrock connections without a paid plan | ||
allow_overwrite = false | ||
} | ||
] | ||
} | ||
|
||
resource "cloudflare_record" "sites" { | ||
for_each = { | ||
for site in local.generic_subdomains : site.name => site | ||
} | ||
zone_id = var.cloudflare_zone_id | ||
name = each.value.name | ||
value = each.value.value | ||
type = each.value.type | ||
ttl = each.value.ttl | ||
proxied = each.value.proxied | ||
allow_overwrite = each.value.allow_overwrite | ||
} |
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,8 @@ | ||
terraform { | ||
required_providers { | ||
cloudflare = { | ||
source = "cloudflare/cloudflare" | ||
version = "4.0.0" | ||
} | ||
} | ||
} |
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,3 @@ | ||
provider "cloudflare" { | ||
api_token = var.cloudflare_api_token | ||
} |
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,34 @@ | ||
variable "cloudflare_api_token" { | ||
type = string | ||
description = "Cloudflare API token" | ||
sensitive = true | ||
} | ||
|
||
variable "cloudflare_zone_id" { | ||
type = string | ||
description = "Cloudflare zone ID" | ||
} | ||
|
||
variable "tcpshield_verify" { | ||
type = string | ||
description = "TCPShield verification string" | ||
default = "tcpshield-network-verification=PAUKRKP6TUBTLQEGU4NCYXGVJ7EDR4TDD4W2ANGM2EUE4DBBW7EL5742WAIAFTJ3WCQTGJTC75KMVGSZ5TV7LYTZEJRLBER4GJYNFEY=" | ||
} | ||
|
||
variable "tcpshield_cname" { | ||
type = string | ||
description = "TCPShield CNAME" | ||
default = "821a0595c68acbbe610f313ae62672ec.ipv4.tcpshield.com" | ||
} | ||
|
||
variable "server_ip" { | ||
type = string | ||
description = "Server IP" | ||
default = "54.39.243.77" | ||
} | ||
|
||
variable "root_domain" { | ||
type = string | ||
description = "Root domain" | ||
default = "queercraft.net" | ||
} |