title: Join EC2 Instance to AD domain via terraform
body: <p>I hope you can help me with my problem. I am trying to automatically let my ec2 instance joins an ad domain with my terraform script. Since Terraform does not support any "Domain join directory" option I wanted to try to create an SSM Document to let Systems Manager make that for me. Actually I got the following Code:</p>
  
  <pre><code>resource "aws_directory_service_directory" "ad" {
    name     = "active-directory-service.com"
    password = "${var.ad-password}"
    edition  = "Standard"
    size     = "Small"
    type     = "MicrosoftAD"
  
    vpc_settings {
      vpc_id     = "${aws_vpc.vpc.id}"
      subnet_ids = ["${aws_subnet.ds-subnet.0.id}", 
                    "${aws_subnet.ds-subnet.1.id}"
                    ]
    }
  
  }
  
  resource "aws_vpc_dhcp_options" "vpc-dhcp-options" {
    domain_name          = "${var.dir_domain_name}"
    domain_name_servers  = aws_directory_service_directory.ad.dns_ip_addresses
  
  }
  resource "aws_vpc_dhcp_options_association" "dns_resolver" {
     vpc_id          =  aws_vpc.vpc.id
     dhcp_options_id = aws_vpc_dhcp_options.vpc-dhcp-options.id
  }
  
  resource "aws_ssm_document" "ad-server-domain-join-document" {
      name  = "myapp_dir_default_doc"
      document_type = "Command"
  
  content = &lt;&lt;DOC
  {
          "schemaVersion": "1.0",
          "description": "Join an instance to a domain",
          "runtimeConfig": {
             "aws:domainJoin": {
                 "properties": {
                    "directoryId": "${aws_directory_service_directory.ad.id}",
                    "directoryName": "${var.dir_domain_name}",
                    "directoryOU": "${var.dir_computer_ou}",
                    "dnsIpAddresses": [
                       "${aws_directory_service_directory.ad.dns_ip_addresses[0]}",
                       "${aws_directory_service_directory.ad.dns_ip_addresses[1]}"
                 }
             }
          }
  }
  DOC
  }
  
  resource "aws_ssm_association" "ad-server-association" {
      name = "dir_default_doc"
      instance_id = aws_instance.ec2-ad-instance.id
  }
  </code></pre>
  
  <p>I get the following error message: </p>
  
  <p><strong>This value does not have any indices.</strong> Can someone please tell me how to fix this issue?</p>