Error creating SSM document: InvalidDocumentContent

600 views
Skip to first unread message

Tony Wong

unread,
Jul 4, 2020, 12:21:23 PM7/4/20
to terrafo...@googlegroups.com
any idea what this error mean?

trying to join ec2 instance to domain with ssm doc


resource "aws_ssm_document" "ad-server-domain-join-document" {
name = "myapp_dir_default_doc"
document_type = "Command"

content = <<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}",
“dnsIpAddresses”: ${jsonencode(aws_directory_service_directory.AD.dns_ip_addresses)}
}
}
}
}
DOC
}

resource "aws_ssm_association" "ad-server-association" {
name = "dir_default_doc"
instance_id = aws_instance.ec2.id
}


Error: Error creating SSM document: InvalidDocumentContent: JSON not well-formed. at Line: 9, Column: 20

  on ssm.tf line 1, in resource "aws_ssm_document" "ad-server-domain-join-document":
   1: resource "aws_ssm_document" "ad-server-domain-join-document" {



Error: Error creating SSM association: InvalidDocument: Invalid document provided

  on ssm.tf line 22, in resource "aws_ssm_association" "ad-server-association":
  22: resource "aws_ssm_association" "ad-server-association" {

Adam

unread,
Jul 5, 2020, 3:08:03 AM7/5/20
to terrafo...@googlegroups.com
Have you run your json through a json parser? 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/CALmkhkqFNdp%3DptXbQxGQF%2B1UaOF0CyQ0fgfYdT1Gjts6Qp0CnQ%40mail.gmail.com.

Jamie Gruener

unread,
Jul 6, 2020, 11:54:22 AM7/6/20
to terrafo...@googlegroups.com

Maybe this is a cut/paste issue with your email client, but the quotes around `dnsIpAddresses` are rendered as smart quotes below, not straight quotes.

 

--Jamie

Tony Wong

unread,
Jul 7, 2020, 5:04:46 PM7/7/20
to terrafo...@googlegroups.com
I tried taking the dnsIPaddresses line out

but this is still giving me an error


aws_ssm_document.ad-server-domain-join-document: Creating...

Error: Error creating SSM document: InvalidDocumentContent: JSON not well-formed. at Line: 12, Column: 303


  on ssm.tf line 1, in resource "aws_ssm_document" "ad-server-domain-join-document":
   1: resource "aws_ssm_document" "ad-server-domain-join-document" {

resource "aws_ssm_document" "ad-server-domain-join-document" {
name = "myapp_dir_default_doc"
document_type = "Command"

content = <<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}"
}
}
}
DOC
depends_on = ["aws_directory_service_directory.AD"]

}

resource "aws_ssm_association" "ad-server-association" {
name = "dir_default_doc"
instance_id = aws_instance.ec2.id
    depends_on = ["aws_ssm_document.ad-server-domain-join-document", "aws_instance.ec2"]
}

Adam

unread,
Jul 8, 2020, 4:04:34 AM7/8/20
to terrafo...@googlegroups.com
Have you tried pasting your JSON into a json parser, for e.g. at http://json.parser.online.fr ? It looks like your JSON is still incorrectly structured.

Adam

Tony Wong

unread,
Jul 8, 2020, 12:40:45 PM7/8/20
to terrafo...@googlegroups.com
this is output i get


String parse: 1 error
JS eval fails
resource "aws_ssm_document" "myapp_dir_default_doc" { name = "myapp_dir_default_doc" document_type = "Command" content = <<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}", "dnsIpAddresses": [ sort(aws_directory_service_directory.myapp.dns_ip_addresses)[0] sort(aws_directory_service_directory.myapp.dns_ip_addresses)[1] ] } } } } DOC depends_on = ["aws_directory_service_directory.myapp_ad"] } resource "aws_ssm_association" "myapp_adwriter" { name = "myapp_dir_default_doc" instance_id = "${aws_instance.vm_adwriter.id}" depends_on = ["aws_ssm_document.myapp_dir_default_doc", "aws_instance.vm_adwriter"] }

Jamie Gruener

unread,
Jul 8, 2020, 1:09:06 PM7/8/20
to terrafo...@googlegroups.com

Copy/paste your JSON (from first character after the first DOC to the last character preceding the second DOC) into the parser provided below and your error will become evident.

 

--Jamie

Reply all
Reply to author
Forward
0 new messages