diff --git a/README.md b/README.md index 45b57dcf8..ca6362d46 100644 --- a/README.md +++ b/README.md @@ -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 ----- diff --git a/examples/complete-vpc/main.tf b/examples/complete-vpc/main.tf index d5bad4b93..e79f78c71 100644 --- a/examples/complete-vpc/main.tf +++ b/examples/complete-vpc/main.tf @@ -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" diff --git a/main.tf b/main.tf index 7fc4679ef..dbd7d1a66 100644 --- a/main.tf +++ b/main.tf @@ -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 ################### diff --git a/variables.tf b/variables.tf index 1a03aa864..6f39304a2 100644 --- a/variables.tf +++ b/variables.tf @@ -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" + 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 = "" +}