Document schema version, 2.2, is not supported

Viewed 133

I am struggling to get EC2 instances deployed via an ASG joined to the domain.

I get the following error each time

New-SSMAssociation : Document schema version, 2.2, is not supported by association that is created with instance id

I have tried various schema versions detailed Here however all fail with the same error

SSMdoc.tf

resource "aws_ssm_document" "ad-join-domain" {
  name          = "ad-join-domain"
  document_type = "Command"
  content = jsonencode(
    {
      "schemaVersion" = "2.2"
      "description"   = "aws:domainJoin"
      "parameters" : {
        "directoryId" : {
          "description" : "(Required) The ID of the directory.",
          "type" : "String"
        },
        "directoryName" : {
          "description" : "(Required) The name of the domain.",
          "type" : "String"
        },
        "dnsIpAddresses" : {
          "description" : "(Required) The IP addresses of the DNS servers for your directory.",
          "type" : "StringList"
        },
      },
      "mainSteps" = [
        {
          "action" = "aws:domainJoin",
          "name"   = "domainJoin",
          "inputs" = {
            "directoryId" : data.aws_directory_service_directory.adgems.id,
            "directoryName" : data.aws_directory_service_directory.adgems.name,
            "dnsIpAddresses" : [data.aws_directory_service_directory.adgems.dns_ip_addresses]
          }
        }
      ]
    }
  )
}

template.tf

data "template_file" "ad-join-template" {
  template = <<EOF
  <powershell>
    Set-DefaultAWSRegion -Region eu-west-2
    Set-Variable -name instance_id -value (Invoke-Restmethod -uri http://169.254.169.254/latest/meta-data/instance-id)
    New-SSMAssociation -InstanceId $instance_id -Name "${aws_ssm_document.ad-join-domain.name}"
  </powershell>
  EOF
}

The above is then called from the aws_launch_template terraform resource.

1 Answers

I was able to resolve the issue using a different format of the New-SSMAssociation command as found in the examples in the docs: https://docs.aws.amazon.com/powershell/latest/reference/items/New-SSMAssociation.html

This is the example listed with small modifications

$target = @{Key="instanceids";Values=@("i-0cb2b964d3e14fd9f")}
New-SSMAssociation -Name 'ad-join-domain' -Target $target

Please note that the values portion should be changed to hold the actual instance ID that is in used.

Related