The following example policy workflow uses the mark-for-op and marked-for-op filters and
actions to chain together a set of policies to accomplish a task. In this example it
will find any ELB that isn’t attached to any instances and tag it with a delete op
and date 14 days out. The policy workflow will also email the ELB resource owner to
inform them of the upcoming deletion if the ELB remains unused. If the customer adds
an instance back to their ELB it will get unmarked so it doesn’t get deleted.

Note the use of the notify action requires the Cloud Custodian mailer to be installed
and configured.

policies:-name:elb-mark-unused-for-deletionresource:elbdescription:|Mark any ELB with no instances attached for deletion in 14 days.Also send an email to the ELB resource owner informing them its unused.filters:-"tag:maid_status":absent-Instances:[]actions:-type:mark-for-optag:maid_statusop:deletedays:14-type:notifytemplate:default.htmlpriority_header:1subject:"ELB-NoInstancesAttached-[custodian{{account}}-{{region}}]"violation_desc:"NoInstancesAreAttachedToTheFollowingELB(s):"action_desc:|Actions Taken: The unused ELBs have been marked for deletion in 14 if theyremain unused. If you still need the ELBs listed below, please attach instancesto them, otherwise please delete them if not needed anymore.to:-CloudCustodian@Company.com-resource-ownertransport:type:sqsqueue:https://sqs.us-east-1.amazonaws.com/12345678900/cloud-custodian-mailerregion:us-east-1-name:elb-unmark-if-in-useresource:elbdescription:|Remove the maid_status tag from any elb which has instances attachedso it doesn't get deleted by the following policyfilters:-"tag:maid_status":not-null-not:-Instances:[]actions:-type:remove-tagtags:[maid_status]-name:elb-delete-unusedresource:elbdescription:|Delete any marked ELB which has no instances attachedif it has been that way for 14 days or more.filters:-type:marked-for-opop:deleteactions:-delete-type:notifytemplate:default.htmlpriority_header:1subject:"ELB-DeletedStaleELB-[custodian{{account}}-{{region}}]"violation_desc:"NoInstancesAreAttachedToELBforover14days:"action_desc:"ActionsTaken:TheELBhasbeendeleted"to:-CloudCustodian@Company.com-resource-ownertransport:type:sqsqueue:https://sqs.us-east-1.amazonaws.com/12345678900/cloud-custodian-mailerregion:us-east-1