diff --git a/README.md b/README.md index f609da1..974e390 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 | diff --git a/outputs.tf b/outputs.tf index 4b0a236..902228f 100644 --- a/outputs.tf +++ b/outputs.tf @@ -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 : "" @@ -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" diff --git a/tests/vpc_localstack_test.go b/tests/vpc_localstack_test.go index dab5d3d..7e0cc19 100644 --- a/tests/vpc_localstack_test.go +++ b/tests/vpc_localstack_test.go @@ -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) @@ -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)