Commit 61f7f90a authored by Nicholas Hawkes's avatar Nicholas Hawkes Committed by GitHub

feat: Adding dynamic vpc block to handle private zones (#13)

parent 28980407
......@@ -7,7 +7,7 @@ module "zones" {
zones = {
"terraform-aws-modules-example.com" = {
comment = "terraform-aws-modules-examples.com (production)"
comment = "terraform-aws-modules-example.com (production)"
tags = {
Name = "terraform-aws-modules-example.com"
}
......@@ -19,6 +19,16 @@ module "zones" {
Name = "app.terraform-aws-modules-example.com"
}
}
"private-vpc.terraform-aws-modules-example.com" = {
comment = "private-vpc.terraform-aws-modules-example.com"
vpc = {
vpc_id = module.vpc.vpc_id
}
tags = {
Name = "private-vpc.terraform-aws-modules-example.com"
}
}
}
}
......@@ -97,3 +107,10 @@ module "cloudfront" {
cloudfront_default_certificate = true
}
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
name = "my-vpc-for-private-route53-zone"
cidr = "10.0.0.0/16"
}
......@@ -21,7 +21,7 @@ This module creates Route53 zones.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| create | Whether to create Route53 zone | `bool` | `true` | no |
| zones | Map of Route53 zone parameters | `map(any)` | `{}` | no |
| zones | Map of Route53 zone parameters | `any` | `{}` | no |
## Outputs
......
resource "aws_route53_zone" "this" {
for_each = var.create ? var.zones : {}
for_each = var.create ? var.zones : tomap({})
name = each.key
comment = lookup(each.value, "comment", null)
force_destroy = lookup(each.value, "force_destroy", false)
dynamic "vpc" {
for_each = length(keys(lookup(each.value, "vpc", {}))) == 0 ? [] : [lookup(each.value, "vpc", {})]
content {
vpc_id = vpc.value.vpc_id
vpc_region = lookup(vpc.value, "vpc_region", null)
}
}
tags = lookup(each.value, "tags", null)
}
......@@ -6,6 +6,6 @@ variable "create" {
variable "zones" {
description = "Map of Route53 zone parameters"
type = map(any)
type = any
default = {}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment