Create AWS Systems Manager Maintenance Window without a target

AWS SSM is a great tool, with a lot of cool features, but I always felt that the documentation is not very good, or the console is very intuitive.

Recently I wanted to configure a maintenance window with an SSM Automation task, but the task did not take any instances as the inputs. The task was supposed to create a new instance and do some stuff on it.

So in order to workound with the limitation in which SSM requires a target to be registered, I just added a dummy instance as the target.

If you are using Terraform, the relevant snippet is as below:

resource "aws_ssm_maintenance_window_target" "ami_patching_maintenance_targets_windows" {
  window_id     = aws_ssm_maintenance_window.ami_patching_maintenance_window_windows.id
  name          = "ami-patching-maintenance-window-target-windows"
  description   = "This is used for patching the AMI"
  resource_type = "INSTANCE"
  #The targets are just kept because of requirement. They are not used
  targets {
    key    = "InstanceIds"
    values = ["i-0000000000012345"]
  }
}

Note, this code expects you to have familiarity with managing SSM using terraform. My particular usecase was to run the AWS-UpdateWindowsAmi SSM automation document in a schedule.