Auto Scaling Groups (ASG)

Filters

security-group

Filter for ASG’s that have a certain security group.

Schema:
{
  "default": {
    "type": "object"
  },
  "key": {
    "type": "string"
  },
  "match-resource": {
    "type": "boolean"
  },
  "op": {
    "enum": [
      "glob",
      "contains",
      "equal",
      "eq",
      "lt",
      "ge",
      "greater-than",
      "gte",
      "not-in",
      "in",
      "regex",
      "difference",
      "ne",
      "less-than",
      "lte",
      "intersect",
      "le",
      "not-equal",
      "gt",
      "ni"
    ]
  },
  "operator": {
    "enum": [
      "and",
      "or"
    ]
  },
  "value": {
    "oneOf": [
      {
        "type": "array"
      },
      {
        "type": "string"
      },
      {
        "type": "boolean"
      },
      {
        "type": "number"
      },
      {
        "type": "null"
      }
    ]
  },
  "value_from": {
    "additionalProperties": "False",
    "properties": {
      "expr": {
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "format": {
        "enum": [
          "csv",
          "json",
          "txt",
          "csv2dict"
        ]
      },
      "url": {
        "type": "string"
      }
    },
    "required": [
      "url"
    ],
    "type": "object"
  },
  "value_type": {
    "enum": [
      "age",
      "integer",
      "expiration",
      "normalize",
      "size",
      "cidr",
      "cidr_size",
      "swap",
      "resource_count",
      "expr",
      "unique_size"
    ]
  }
}
subnet

Filter on ASG’s

Schema:
{
  "default": {
    "type": "object"
  },
  "key": {
    "type": "string"
  },
  "match-resource": {
    "type": "boolean"
  },
  "op": {
    "enum": [
      "glob",
      "contains",
      "equal",
      "eq",
      "lt",
      "ge",
      "greater-than",
      "gte",
      "not-in",
      "in",
      "regex",
      "difference",
      "ne",
      "less-than",
      "lte",
      "intersect",
      "le",
      "not-equal",
      "gt",
      "ni"
    ]
  },
  "operator": {
    "enum": [
      "and",
      "or"
    ]
  },
  "value": {
    "oneOf": [
      {
        "type": "array"
      },
      {
        "type": "string"
      },
      {
        "type": "boolean"
      },
      {
        "type": "number"
      },
      {
        "type": "null"
      }
    ]
  },
  "value_from": {
    "additionalProperties": "False",
    "properties": {
      "expr": {
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "format": {
        "enum": [
          "csv",
          "json",
          "txt",
          "csv2dict"
        ]
      },
      "url": {
        "type": "string"
      }
    },
    "required": [
      "url"
    ],
    "type": "object"
  },
  "value_type": {
    "enum": [
      "age",
      "integer",
      "expiration",
      "normalize",
      "size",
      "cidr",
      "cidr_size",
      "swap",
      "resource_count",
      "expr",
      "unique_size"
    ]
  }
}
launch-config

Filter ASG by launch config attributes.

Schema:
{
  "default": {
    "type": "object"
  },
  "key": {
    "type": "string"
  },
  "op": {
    "enum": [
      "glob",
      "contains",
      "equal",
      "eq",
      "lt",
      "ge",
      "greater-than",
      "gte",
      "not-in",
      "in",
      "regex",
      "difference",
      "ne",
      "less-than",
      "lte",
      "intersect",
      "le",
      "not-equal",
      "gt",
      "ni"
    ]
  },
  "value": {
    "oneOf": [
      {
        "type": "array"
      },
      {
        "type": "string"
      },
      {
        "type": "boolean"
      },
      {
        "type": "number"
      },
      {
        "type": "null"
      }
    ]
  },
  "value_from": {
    "additionalProperties": "False",
    "properties": {
      "expr": {
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "format": {
        "enum": [
          "csv",
          "json",
          "txt",
          "csv2dict"
        ]
      },
      "url": {
        "type": "string"
      }
    },
    "required": [
      "url"
    ],
    "type": "object"
  },
  "value_type": {
    "enum": [
      "age",
      "integer",
      "expiration",
      "normalize",
      "size",
      "cidr",
      "cidr_size",
      "swap",
      "resource_count",
      "expr",
      "unique_size"
    ]
  }
}
valid

Filters ASG’s to find those that are structurally valid.

Schema:
{}
invalid

Filters ASG’s to find those that are structurally invalid.

Schema:
{}
not-encrypted

Check if an ASG is configured to have unencrypted volumes.

Schema:
{
  "exclude_image": {
    "type": "boolean"
  }
}
image-age

Filter ASG by image age (in days).

Schema:
{
  "days": {
    "type": "number"
  },
  "op": {
    "enum": [
      "glob",
      "contains",
      "equal",
      "eq",
      "lt",
      "ge",
      "greater-than",
      "gte",
      "not-in",
      "in",
      "regex",
      "difference",
      "ne",
      "less-than",
      "lte",
      "intersect",
      "le",
      "not-equal",
      "gt",
      "ni"
    ],
    "type": "string"
  }
}
image

Filter by ASG image

Schema:
{
  "default": {
    "type": "object"
  },
  "key": {
    "type": "string"
  },
  "op": {
    "enum": [
      "glob",
      "contains",
      "equal",
      "eq",
      "lt",
      "ge",
      "greater-than",
      "gte",
      "not-in",
      "in",
      "regex",
      "difference",
      "ne",
      "less-than",
      "lte",
      "intersect",
      "le",
      "not-equal",
      "gt",
      "ni"
    ]
  },
  "value": {
    "oneOf": [
      {
        "type": "array"
      },
      {
        "type": "string"
      },
      {
        "type": "boolean"
      },
      {
        "type": "number"
      },
      {
        "type": "null"
      }
    ]
  },
  "value_from": {
    "additionalProperties": "False",
    "properties": {
      "expr": {
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "format": {
        "enum": [
          "csv",
          "json",
          "txt",
          "csv2dict"
        ]
      },
      "url": {
        "type": "string"
      }
    },
    "required": [
      "url"
    ],
    "type": "object"
  },
  "value_type": {
    "enum": [
      "age",
      "integer",
      "expiration",
      "normalize",
      "size",
      "cidr",
      "cidr_size",
      "swap",
      "resource_count",
      "expr",
      "unique_size"
    ]
  }
}
vpc-id

Filters ASG based on the VpcId

Schema:
{
  "default": {
    "type": "object"
  },
  "op": {
    "enum": [
      "glob",
      "contains",
      "equal",
      "eq",
      "lt",
      "ge",
      "greater-than",
      "gte",
      "not-in",
      "in",
      "regex",
      "difference",
      "ne",
      "less-than",
      "lte",
      "intersect",
      "le",
      "not-equal",
      "gt",
      "ni"
    ]
  },
  "value": {
    "oneOf": [
      {
        "type": "array"
      },
      {
        "type": "string"
      },
      {
        "type": "boolean"
      },
      {
        "type": "number"
      },
      {
        "type": "null"
      }
    ]
  },
  "value_from": {
    "additionalProperties": "False",
    "properties": {
      "expr": {
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "format": {
        "enum": [
          "csv",
          "json",
          "txt",
          "csv2dict"
        ]
      },
      "url": {
        "type": "string"
      }
    },
    "required": [
      "url"
    ],
    "type": "object"
  },
  "value_type": {
    "enum": [
      "age",
      "integer",
      "expiration",
      "normalize",
      "size",
      "cidr",
      "cidr_size",
      "swap",
      "resource_count",
      "expr",
      "unique_size"
    ]
  }
}
progagated-tags

Filter ASG based on propagated tags

Schema:
{
  "keys": {
    "items": {
      "type": "string"
    },
    "type": "array"
  },
  "match": {
    "type": "boolean"
  },
  "propagate": {
    "type": "boolean"
  }
}
capacity-delta

Filter returns ASG that have less instances than desired or required

Schema:
{}
user-data

Filter for ASG’s with launch configs containing user data matching the value given.

Schema:
{
  "default": {
    "type": "object"
  },
  "key": {
    "type": "string"
  },
  "op": {
    "enum": [
      "glob",
      "contains",
      "equal",
      "eq",
      "lt",
      "ge",
      "greater-than",
      "gte",
      "not-in",
      "in",
      "regex",
      "difference",
      "ne",
      "less-than",
      "lte",
      "intersect",
      "le",
      "not-equal",
      "gt",
      "ni"
    ]
  },
  "value": {
    "oneOf": [
      {
        "type": "array"
      },
      {
        "type": "string"
      },
      {
        "type": "boolean"
      },
      {
        "type": "number"
      },
      {
        "type": "null"
      }
    ]
  },
  "value_from": {
    "additionalProperties": "False",
    "properties": {
      "expr": {
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "format": {
        "enum": [
          "csv",
          "json",
          "txt",
          "csv2dict"
        ]
      },
      "url": {
        "type": "string"
      }
    },
    "required": [
      "url"
    ],
    "type": "object"
  },
  "value_type": {
    "enum": [
      "age",
      "integer",
      "expiration",
      "normalize",
      "size",
      "cidr",
      "cidr_size",
      "swap",
      "resource_count",
      "expr",
      "unique_size"
    ]
  }
}

Actions

tag-trim

Trim the number of tags to avoid hitting tag limits.

Schema:
{
  "preserve": {
    "items": {
      "type": "string"
    },
    "type": "array"
  },
  "space": {
    "type": "integer"
  }
}
resize

Resize the min/max/desired instances in an ASG.

Schema:
{
  "desired-size": {
    "anyOf": [
      {
        "enum": [
          "current"
        ]
      },
      {
        "minimum": 0,
        "type": "integer"
      }
    ]
  },
  "desired_size": {
    "anyOf": [
      {
        "enum": [
          "current"
        ]
      },
      {
        "minimum": 0,
        "type": "integer"
      }
    ]
  },
  "max-size": {
    "minimum": 0,
    "type": "integer"
  },
  "min-size": {
    "minimum": 0,
    "type": "integer"
  },
  "restore-options-tag": {
    "type": "string"
  },
  "save-options-tag": {
    "type": "string"
  }
}
remove-tag or untag or unmark

Removes tag from ASG.

Schema:
{
  "key": {
    "type": "string"
  }
}
tag or mark

Create or update tag on ASG.

Schema:
{
  "key": {
    "type": "string"
  },
  "msg": {
    "type": "string"
  },
  "propagate": {
    "type": "boolean"
  },
  "tag": {
    "type": "string"
  },
  "value": {
    "type": "string"
  }
}
propagate-tags

Propagate tags to an ASG instances. In AWS changing an ASG tag does not propagate to instances. This action exists to do that, and can also trim older tags not present on the ASG anymore that are still present on instances.

Schema:
{
  "tags": {
    "items": {
      "type": "string"
    },
    "type": "array"
  },
  "trim": {
    "type": "boolean"
  }
}
rename-tag

Rename a tag on an AutoScaleGroup.

Schema:
{
  "dest": {
    "required": true,
    "type": "string"
  },
  "propagate": {
    "type": "boolean"
  },
  "source": {
    "required": true,
    "type": "string"
  }
}
mark-for-op

Tag ASG for an operation.

Schema:
{
  "days": {
    "minimum": 0,
    "type": "number"
  },
  "hours": {
    "minimum": 0,
    "type": "number"
  },
  "key": {
    "type": "string"
  },
  "message": {
    "type": "string"
  },
  "op": {
    "enum": [
      "suspend",
      "resume",
      "delete"
    ]
  },
  "tag": {
    "type": "string"
  }
}
suspend

Multistep process to stop an ASG. Suspend processes, note load balancer in tag, detach load balancer, and then stop instances.

Schema:
{
  "exclude": {
    "items": {
      "enum": [
        "Launch",
        "Terminate",
        "HealthCheck",
        "ReplaceUnhealthy",
        "AZRebalance",
        "AlarmNotification",
        "ScheduledActions",
        "AddToLoadBalancer"
      ]
    },
    "title": "ASG Processes to not suspend",
    "type": "array"
  }
}
resume

Multi-step process to resume an ASG. Start any stopped EC2 instances, reattach ELB, and resume ASG processes.

Schema:
{
  "delay": {
    "type": "number"
  }
}
delete

Delete ASG.

Schema:
{
  "force": {
    "type": "boolean"
  }
}
offhour or OffHour

Turn resources off based on a schedule. c7n.offhours

Schema:
{
  "default_tz": {
    "required": true,
    "type": "string"
  },
  "offhour": {
    "maximum": 23,
    "minimum": 0,
    "required": true,
    "type": "integer"
  },
  "opt-out": {
    "type": "boolean"
  },
  "skip-days": {
    "items": {
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}",
      "type": "string"
    },
    "type": "array"
  },
  "skip-days-from": {
    "additionalProperties": "False",
    "properties": {
      "expr": {
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "format": {
        "enum": [
          "csv",
          "json",
          "txt",
          "csv2dict"
        ]
      },
      "url": {
        "type": "string"
      }
    },
    "required": [
      "url"
    ],
    "type": "object"
  },
  "tag": {
    "type": "string"
  },
  "weekends": {
    "type": "boolean"
  },
  "weekends-only": {
    "type": "boolean"
  }
}
onhour or onhour

Turn resources on based on a schedule. c7n.offhours

Schema:
{
  "default_tz": {
    "required": true,
    "type": "string"
  },
  "onhour": {
    "maximum": 23,
    "minimum": 0,
    "required": true,
    "type": "integer"
  },
  "opt-out": {
    "type": "boolean"
  },
  "skip-days": {
    "items": {
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}",
      "type": "string"
    },
    "type": "array"
  },
  "skip-days-from": {
    "additionalProperties": "False",
    "properties": {
      "expr": {
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "format": {
        "enum": [
          "csv",
          "json",
          "txt",
          "csv2dict"
        ]
      },
      "url": {
        "type": "string"
      }
    },
    "required": [
      "url"
    ],
    "type": "object"
  },
  "tag": {
    "type": "string"
  },
  "weekends": {
    "type": "boolean"
  },
  "weekends-only": {
    "type": "boolean"
  }
}

Launch Configs

delete

Delete a launch configuration.

Schema:
{
  "force": {
    "type": "boolean"
  }
}