Using Terraform, how can I add multiple search domains to /etc/resolve.conf to an AWS EC2 instance?

0

1

in my AWS ec2 linux instance I need my /etc/resolve.conf file to look something like

search my.domain my.other.domain
nameserver 10.10.10.10

my terraform object looks like

resource "aws_vpc_dhcp_options" "dns_option" {
    domain_name = "${var.environment}.my.domain"
    domain_name_servers = ["${split(",", var.vpc_dns_server)}"]
}

I need to add multiple domain_name objects I think?

nick fox

Posted 2017-11-09T14:54:23.207

Reputation: 121

This question could really do with 'hashicorp' and 'terraform' tags but I don't have the reputation to add them. – nick fox – 2017-11-09T14:55:10.680

Answers

0

You need to do the following:

  1. Add the aws_vpc_dhcp_options_association to your code:

    resource "aws_vpc_dhcp_options_association" "vpc_dhcp_association" { vpc_id = "vpc-abcdefab" dhcp_options_id = "${aws_vpc_dhcp_options.dns_option.id}" }

    • For your VPC ID you can reference it with something like ${aws_vpc.myvpc.id}
  2. To have multiple domains on your resolv.conf file you need to put multiple domain names separated by space like this:

    resource "aws_vpc_dhcp_options" "dns_option" { domain_name = "${var.environment1}.my.domain ${var.environment2}.my.other.domain" }

Algeriassic

Posted 2017-11-09T14:54:23.207

Reputation: 723