Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Output Name servers (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Puneeth-n authored Jul 6, 2020
1 parent caeb3d6 commit b8011ce
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ MIT Licensed. See [LICENSE](LICENSE) for full details.
| enable\_dns\_hostnames | Enable DNS hostnames | `bool` | `true` | no |
| enable\_dns\_support | Enable DNS support | `bool` | `true` | no |
| nat\_az\_number | Subnet number to deploy NAT gateway in | `number` | `0` | no |
| private\_subnet\_tags | n/a | `map` | `{}` | no |
| public\_subnet\_tags | n/a | `map` | `{}` | no |
| private\_subnet\_tags | n/a | `map(string)` | `{}` | no |
| public\_subnet\_tags | n/a | `map(string)` | `{}` | no |
| subdomain | Subdomain name | `string` | `""` | no |
| tags | n/a | `map` | `{}` | no |
| tags | n/a | `map(string)` | `{}` | no |

## Outputs

Expand All @@ -58,6 +58,7 @@ MIT Licensed. See [LICENSE](LICENSE) for full details.
| private\_subnets | Private subnets |
| private\_zone\_id | Private hosted zone ID |
| public\_subdomain | Public subdomain name |
| public\_subdomain\_name\_servers | Public subdomain name servers |
| public\_subdomain\_zone\_id | Subdomain hosted zone ID |
| public\_subnets | Public subnets |
| subdomain\_zone\_id | Subdomain hosted zone ID |
Expand Down
10 changes: 8 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ locals {
private_zone_id = var.enable ? aws_route53_zone.net0ps[0].zone_id : ""
private_subdomain = var.enable ? aws_route53_zone.net0ps[0].name : ""

public_subdomain_zone_id = var.enable && var.subdomain != "" ? aws_route53_zone.subdomain[0].zone_id : ""
public_subdomain = var.enable && var.subdomain != "" ? var.subdomain : ""
public_subdomain_zone_id = var.enable && var.subdomain != "" ? aws_route53_zone.subdomain[0].zone_id : ""
public_subdomain = var.enable && var.subdomain != "" ? var.subdomain : ""
public_subdomain_name_servers = var.enable && var.subdomain != "" ? aws_route53_zone.subdomain[0].name_servers : []

vpc_private_routing_table_id = var.enable ? aws_default_route_table.private[0].id : ""
vpc_public_routing_table_id = var.enable ? aws_route_table.public[0].id : ""
Expand Down Expand Up @@ -64,6 +65,11 @@ output "public_subdomain" {
description = "Public subdomain name"
}

output "public_subdomain_name_servers" {
value = local.outputs.public_subdomain_name_servers
description = "Public subdomain name servers"
}

output "private_subdomain" {
value = local.outputs.private_subdomain
description = "Private subdomain name"
Expand Down
13 changes: 13 additions & 0 deletions tests/vpc_localstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ func ValidateTerraformModuleOutputs(t *testing.T, terraformOptions *terraform.Op
ValidateVPCRoute53ZoneID(t, terraformOptions)
ValidateVPCRoute53ZoneName(t, terraformOptions)

ValidateVPCSubdomainNameServers(t, terraformOptions)

ValidateVPCRoute53ZoneName(t, terraformOptions)

ValidateVPCRoutingTables(t, terraformOptions)
Expand All @@ -209,6 +211,17 @@ func ValidateVPCSubnets(t *testing.T, terraformOptions *terraform.Options) {
assert.NotEqual(t, public_subnets, private_subnets)
}

func ValidateVPCSubdomainNameServers(t *testing.T, terraformOptions *terraform.Options) {
publicSubdomainNameServers := terraform.OutputList(t, terraformOptions, "public_subdomain_name_servers")

if terraformOptions.Vars["subdomain"] == "" {
assert.Len(t, publicSubdomainNameServers, 0)
} else {
assert.Greater(t, len(publicSubdomainNameServers), 0)
}

}

func ValidateVPC(t *testing.T, terraformOptions *terraform.Options) {
vpc_id := terraform.Output(t, terraformOptions, "vpc_id")
assert.Regexp(t, "vpc-*", vpc_id)
Expand Down

0 comments on commit b8011ce

Please sign in to comment.