-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Max Xu <[email protected]>
- Loading branch information
Showing
4 changed files
with
130 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,58 @@ | ||
# DNS Module | ||
|
||
To create a zone in the sub project and then create the delegations in the parent project. | ||
|
||
# Quickstart | ||
|
||
```hcl | ||
module "gcp-dns-zone" { | ||
source = "github.com/streamnative/terraform-managed-cloud//modules/gcp/dns-zone" | ||
parent_project = "<input-here>" | ||
sub_project = "<input-here>" | ||
parent_zone_name = "<input-here>" | ||
sub_zone_name = "<input-here>" | ||
sub_zone_dns_name = "<input-here>" | ||
} | ||
``` | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >=1.2.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_google.parent"></a> [google.parent](#provider\_google.parent) | n/a | | ||
| <a name="provider_google.sub"></a> [google.sub](#provider\_google.sub) | n/a | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [google_dns_managed_zone.sub](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_managed_zone) | resource | | ||
| [google_dns_record_set.delegate](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_record_set) | resource | | ||
| [google_dns_managed_zone.parent](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/dns_managed_zone) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_parent_project"></a> [parent\_project](#input\_parent\_project) | The parent gcp project in which holds the paren zone | `string` | n/a | yes | | ||
| <a name="input_parent_zone_name"></a> [parent\_zone\_name](#input\_parent\_zone\_name) | The parent zone in which we create the delegation records | `string` | n/a | yes | | ||
| <a name="input_sub_project"></a> [sub\_project](#input\_sub\_project) | The sub project in which holds the new zone | `string` | n/a | yes | | ||
| <a name="input_sub_zone_dns_name"></a> [sub\_zone\_dns\_name](#input\_sub\_zone\_dns\_name) | The new dns name | `string` | n/a | yes | | ||
| <a name="input_sub_zone_name"></a> [sub\_zone\_name](#input\_sub\_zone\_name) | The new zone name | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> |
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 @@ | ||
provider "google" { | ||
alias = "parent" | ||
|
||
project = var.parent_project | ||
} | ||
|
||
provider "google" { | ||
alias = "sub" | ||
|
||
project = var.sub_project | ||
} | ||
|
||
resource "google_dns_managed_zone" "sub" { | ||
provider = google.sub | ||
|
||
name = var.sub_zone_name | ||
dns_name = var.sub_zone_dns_name | ||
} | ||
|
||
data "google_dns_managed_zone" "parent" { | ||
provider = google.parent | ||
|
||
name = var.parent_zone_name | ||
} | ||
|
||
resource "google_dns_record_set" "delegate" { | ||
provider = google.parent | ||
|
||
managed_zone = data.google_dns_managed_zone.parent.name | ||
name = google_dns_managed_zone.sub.dns_name | ||
type = "NS" | ||
ttl = "300" | ||
rrdatas = google_dns_managed_zone.sub.name_servers | ||
} |
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 @@ | ||
variable "parent_project" { | ||
type = string | ||
description = "The parent gcp project in which holds the paren zone" | ||
} | ||
|
||
variable "sub_project" { | ||
type = string | ||
description = "The sub project in which holds the new zone" | ||
} | ||
|
||
variable "parent_zone_name" { | ||
type = string | ||
description = "The parent zone in which we create the delegation records" | ||
} | ||
|
||
variable "sub_zone_name" { | ||
type = string | ||
description = "The new zone name" | ||
} | ||
|
||
variable "sub_zone_dns_name" { | ||
type = string | ||
description = "The new dns name" | ||
|
||
validation { | ||
condition = endswith(var.sub_zone_dns_name, ".") | ||
error_message = "DNS name must end with '.'" | ||
} | ||
} |
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,9 @@ | ||
terraform { | ||
required_version = ">=1.2.0" | ||
|
||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
} | ||
} | ||
} |