Skip to content

Commit 85a47cb

Browse files
bcenkerantonbabenko
authored andcommitted
Add support for DHCP options set (terraform-aws-modules#20)
* Add support for DHCP options set * code cleanup * remove unnecessary depends_on in aws_vpc_dhcp_options_association definition
1 parent 9bc4844 commit 85a47cb

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ These types of resources are supported:
1414
* [VPN Gateway](https://www.terraform.io/docs/providers/aws/r/vpn_gateway.html)
1515
* [VPC Endpoint](https://www.terraform.io/docs/providers/aws/r/vpc_endpoint.html) (S3 and DynamoDB)
1616
* [RDS DB Subnet Group](https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html)
17-
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
17+
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
18+
* [DHCP Options Set](https://www.terraform.io/docs/providers/aws/r/vpc_dhcp_options.html)
1819

1920
Usage
2021
-----

examples/complete-vpc/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ module "vpc" {
1919
enable_s3_endpoint = true
2020
enable_dynamodb_endpoint = true
2121

22+
enable_dhcp_options = true
23+
dhcp_options_domain_name = "service.consul"
24+
dhcp_options_domain_name_servers = ["127.0.0.1", "10.10.0.2"]
25+
2226
tags = {
2327
Owner = "user"
2428
Environment = "staging"

main.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@ resource "aws_vpc" "this" {
1010
tags = "${merge(var.tags, map("Name", format("%s", var.name)))}"
1111
}
1212

13+
###################
14+
# DHCP Options Set
15+
###################
16+
resource "aws_vpc_dhcp_options" "this" {
17+
count = "${var.enable_dhcp_options ? 1 : 0}"
18+
19+
domain_name = "${var.dhcp_options_domain_name}"
20+
domain_name_servers = "${var.dhcp_options_domain_name_servers}"
21+
ntp_servers = "${var.dhcp_options_ntp_servers}"
22+
netbios_name_servers = "${var.dhcp_options_netbios_name_servers}"
23+
netbios_node_type = "${var.dhcp_options_netbios_node_type}"
24+
}
25+
26+
###############################
27+
# DHCP Options Set Association
28+
###############################
29+
resource "aws_vpc_dhcp_options_association" "this" {
30+
count = "${var.enable_dhcp_options ? 1 : 0}"
31+
32+
vpc_id = "${aws_vpc.this.id}"
33+
dhcp_options_id = "${aws_vpc_dhcp_options.this.id}"
34+
}
35+
1336
###################
1437
# Internet Gateway
1538
###################

variables.tf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,36 @@ variable "elasticache_subnet_tags" {
129129
description = "Additional tags for the elasticache subnets"
130130
default = {}
131131
}
132+
133+
variable "enable_dhcp_options" {
134+
description = "Should be true if you want to specify a DHCP options set with a custom domain name, DNS servers, NTP servers, netbios servers, and/or netbios server type"
135+
default = false
136+
}
137+
138+
variable "dhcp_options_domain_name" {
139+
description = "Specifies DNS name for DHCP options set"
140+
default = ""
141+
}
142+
143+
variable "dhcp_options_domain_name_servers" {
144+
description = "Specify a list of DNS server addresses for DHCP options set, default to AWS provided"
145+
type = "list"
146+
default = ["AmazonProvidedDNS"]
147+
}
148+
149+
variable "dhcp_options_ntp_servers" {
150+
description = "Specify a list of NTP servers for DHCP options set"
151+
type = "list"
152+
default = []
153+
}
154+
155+
variable "dhcp_options_netbios_name_servers" {
156+
description = "Specify a list of netbios servers for DHCP options set"
157+
type = "list"
158+
default = []
159+
}
160+
161+
variable "dhcp_options_netbios_node_type" {
162+
description = "Specify netbios node_type for DHCP options set"
163+
default = ""
164+
}

0 commit comments

Comments
 (0)