Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DHCP options set #20

Merged
merged 3 commits into from
Nov 11, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ These types of resources are supported:
* [NAT Gateway](https://www.terraform.io/docs/providers/aws/r/nat_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 @@ -18,6 +18,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
24 changes: 24 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@ 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}"
depends_on = ["aws_vpc.this", "aws_vpc_dhcp_options.this"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depends_on is not really needed here. Or, if this is this an edge case then provide an open issue link.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed - no edge case that I know of, I'm not entirely sure why I put that in there. Fixed!

}

###################
# Internet Gateway
###################
Expand Down
33 changes: 33 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reorder a bit - description, type, default

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 = ""
}