Skip to content

Resource: awsSsmMaintenanceWindowTarget

Provides an SSM Maintenance Window Target resource

Example Usage

Instance Target

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsSsmMaintenanceWindowWindow =
  new aws.ssmMaintenanceWindow.SsmMaintenanceWindow(this, "window", {
    cutoff: 1,
    duration: 3,
    name: "maintenance-window-webapp",
    schedule: "cron(0 16 ? * TUE *)",
  });
new aws.ssmMaintenanceWindowTarget.SsmMaintenanceWindowTarget(this, "target1", {
  description: "This is a maintenance window target",
  name: "maintenance-window-target",
  resourceType: "INSTANCE",
  targets: [
    {
      key: "tag:Name",
      values: ["acceptance_test"],
    },
  ],
  windowId: awsSsmMaintenanceWindowWindow.id,
});

Resource Group Target

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsSsmMaintenanceWindowWindow =
  new aws.ssmMaintenanceWindow.SsmMaintenanceWindow(this, "window", {
    cutoff: 1,
    duration: 3,
    name: "maintenance-window-webapp",
    schedule: "cron(0 16 ? * TUE *)",
  });
new aws.ssmMaintenanceWindowTarget.SsmMaintenanceWindowTarget(this, "target1", {
  description: "This is a maintenance window target",
  name: "maintenance-window-target",
  resourceType: "RESOURCE_GROUP",
  targets: [
    {
      key: "resource-groups:ResourceTypeFilters",
      values: ["AWS::EC2::Instance"],
    },
  ],
  windowId: awsSsmMaintenanceWindowWindow.id,
});

Argument Reference

The following arguments are supported:

  • windowId - (Required) The Id of the maintenance window to register the target with.
  • name - (Optional) The name of the maintenance window target.
  • description - (Optional) The description of the maintenance window target.
  • resourceType - (Required) The type of target being registered with the Maintenance Window. Possible values are instance and RESOURCE_GROUP.
  • targets - (Required) The targets to register with the maintenance window. In other words, the instances to run commands on when the maintenance window runs. You can specify targets using instance IDs, resource group names, or tags that have been applied to instances. For more information about these examples formats see (https://docs.aws.amazon.com/systems-manager/latest/userguide/mw-cli-tutorial-targets-examples.html)
  • ownerInformation - (Optional) User-provided value that will be included in any CloudWatch events raised while running tasks for these targets in this Maintenance Window.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The ID of the maintenance window target.

Import

SSM Maintenance Window targets can be imported using WINDOW_ID/WINDOW_TARGET_ID, e.g.,

$ terraform import aws_ssm_maintenance_window_target.example mw-0c50858d01EXAMPLE/23639a0b-ddbc-4bca-9e72-78d96EXAMPLE