Skip to content

Commit

Permalink
Add support for DHCP options set (#20)
Browse files Browse the repository at this point in the history
* Add support for DHCP options set

* code cleanup

* remove unnecessary depends_on in aws_vpc_dhcp_options_association definition
  • Loading branch information
bcenker authored and antonbabenko committed Nov 11, 2017
1 parent 9bc4844 commit 85a47cb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ These types of resources are supported:
* [VPN Gateway](https://www.terraform.io/docs/providers/aws/r/vpn_gateway.html)
* [VPC Endpoint](https://www.terraform.io/docs/providers/aws/r/vpc_endpoint.html) (S3 and DynamoDB)
* [RDS DB Subnet Group](https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html)
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
* [DHCP Options Set](https://www.terraform.io/docs/providers/aws/r/vpc_dhcp_options.html)

Usage
-----
Expand Down
4 changes: 4 additions & 0 deletions examples/complete-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module "vpc" {
enable_s3_endpoint = true
enable_dynamodb_endpoint = true

enable_dhcp_options = true
dhcp_options_domain_name = "service.consul"
dhcp_options_domain_name_servers = ["127.0.0.1", "10.10.0.2"]

tags = {
Owner = "user"
Environment = "staging"
Expand Down
23 changes: 23 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ resource "aws_vpc" "this" {
tags = "${merge(var.tags, map("Name", format("%s", var.name)))}"
}

###################
# DHCP Options Set
###################
resource "aws_vpc_dhcp_options" "this" {
count = "${var.enable_dhcp_options ? 1 : 0}"

domain_name = "${var.dhcp_options_domain_name}"
domain_name_servers = "${var.dhcp_options_domain_name_servers}"
ntp_servers = "${var.dhcp_options_ntp_servers}"
netbios_name_servers = "${var.dhcp_options_netbios_name_servers}"
netbios_node_type = "${var.dhcp_options_netbios_node_type}"
}

###############################
# DHCP Options Set Association
###############################
resource "aws_vpc_dhcp_options_association" "this" {
count = "${var.enable_dhcp_options ? 1 : 0}"

vpc_id = "${aws_vpc.this.id}"
dhcp_options_id = "${aws_vpc_dhcp_options.this.id}"
}

###################
# Internet Gateway
###################
Expand Down
33 changes: 33 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,36 @@ variable "elasticache_subnet_tags" {
description = "Additional tags for the elasticache subnets"
default = {}
}

variable "enable_dhcp_options" {
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"
default = false
}

variable "dhcp_options_domain_name" {
description = "Specifies DNS name for DHCP options set"
default = ""
}

variable "dhcp_options_domain_name_servers" {
description = "Specify a list of DNS server addresses for DHCP options set, default to AWS provided"
type = "list"
default = ["AmazonProvidedDNS"]
}

variable "dhcp_options_ntp_servers" {
description = "Specify a list of NTP servers for DHCP options set"
type = "list"
default = []
}

variable "dhcp_options_netbios_name_servers" {
description = "Specify a list of netbios servers for DHCP options set"
type = "list"
default = []
}

variable "dhcp_options_netbios_node_type" {
description = "Specify netbios node_type for DHCP options set"
default = ""
}

0 comments on commit 85a47cb

Please sign in to comment.