I have created Maintenance window and task to start EC2 instance using terraform below is the code:
resource "aws_ssm_maintenance_window_task" "StopTask" {
count = var.Enabled == "true" ? 1 : 0
max_concurrency = "100%"
max_errors = "100%"
name = "StopJumpEc2"
priority = 1
service_role_arn = aws_iam_role.EC2_start_stop.0.arn
task_arn = "AWS-StopEC2Instance"
task_type = "AUTOMATION"
window_id = aws_ssm_maintenance_window.StopWindow.0.id
targets {
key = "WindowTargetIds"
values = [
aws_ssm_maintenance_window_target.WinOsPatches_StopServer_Target.0.id
]
}
task_invocation_parameters {
automation_parameters {
document_version = "$DEFAULT"
parameter { // same result if you remove or add this :(
name = "AutomationAssumeRole"
values = [
"",
]
}
parameter {
name = "InstanceId"
values = [
"{{RESOURCE_ID}}",
]
}
}
}