I used ssm Terraform module to create windows maintenance, I have created a task on one of this windows maintenance.
I have created a json file what it will help me to create a new ssm document.
The creations of the ssm document works fine, the document needs security_id and other values, I have tried to use templeatefile but still not working, the windows maintenance fails with error “The supplied parameters for invoking the specified Automation document are incorrect.”
I have tried without local, just the resource but still not working.
Terraform code:
resource "aws_ssm_document" "t-document" {
name = "SGDocument"
document_type = "Automation"
document_format = "JSON"
content = templatefile("${path.module}/internet-SG.json.tpl",
{
SecurityGroupId = local.SecurityGroupId
AutomationAssumeRole = local.AutomationAssumeRole
})
}
Jeson file:
{
"schemaVersion": "0.3",
"parameters": {
"SecurityGroupId": {
"type": "String",
"description": "(Required) The security group ID.",
"allowedPattern": "^(sg-)([0-9a-f]){1,}$"
},
"AutomationAssumeRole": {
"type": "String",
"description": "(Optional) The ARN of the role that allows Automation to perform the actions on your behalf.",
"default": "",
"allowedPattern": "^arn:aws(-cn|-us-gov)?:iam::\\d{12}:role\\/[\\w+=,.@_\\/-]+|^$"
}
},
"mainSteps": [
{
"name": "ModifySecurityGroup",
"action": "aws:executeScript",
"onFailure": "Abort",
}
]
}