Search in sources :

Example 1 with OrphanedInstanceRule

use of com.netflix.simianarmy.aws.janitor.rule.instance.OrphanedInstanceRule in project SimianArmy by Netflix.

the class BasicJanitorMonkeyContext method getInstanceJanitor.

private InstanceJanitor getInstanceJanitor() {
    JanitorRuleEngine ruleEngine = createJanitorRuleEngine();
    if (configuration().getBoolOrElse("simianarmy.janitor.rule.orphanedInstanceRule.enabled", false)) {
        ruleEngine.addRule(new OrphanedInstanceRule(monkeyCalendar, (int) configuration().getNumOrElse("simianarmy.janitor.rule.orphanedInstanceRule.instanceAgeThreshold", 2), (int) configuration().getNumOrElse("simianarmy.janitor.rule.orphanedInstanceRule.retentionDaysWithOwner", 3), (int) configuration().getNumOrElse("simianarmy.janitor.rule.orphanedInstanceRule.retentionDaysWithoutOwner", 8), configuration().getBoolOrElse("simianarmy.janitor.rule.orphanedInstanceRule.opsworks.parentage", false)));
    }
    if (configuration().getBoolOrElse("simianarmy.janitor.rule.untaggedRule.enabled", false) && getUntaggedRuleResourceSet().contains("INSTANCE")) {
        ruleEngine.addRule(new UntaggedRule(monkeyCalendar, getPropertySet("simianarmy.janitor.rule.untaggedRule.requiredTags"), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithOwner", 3), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithoutOwner", 8)));
    }
    JanitorCrawler instanceCrawler;
    if (configuration().getBoolOrElse("simianarmy.janitor.edda.enabled", false)) {
        instanceCrawler = new EddaInstanceJanitorCrawler(createEddaClient(), awsClient().region());
    } else {
        instanceCrawler = new InstanceJanitorCrawler(awsClient());
    }
    BasicJanitorContext instanceJanitorCtx = new BasicJanitorContext(monkeyRegion, ruleEngine, instanceCrawler, janitorResourceTracker, monkeyCalendar, configuration(), recorder());
    return new InstanceJanitor(awsClient(), instanceJanitorCtx);
}
Also used : UntaggedRule(com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule) OrphanedInstanceRule(com.netflix.simianarmy.aws.janitor.rule.instance.OrphanedInstanceRule)

Aggregations

UntaggedRule (com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule)1 OrphanedInstanceRule (com.netflix.simianarmy.aws.janitor.rule.instance.OrphanedInstanceRule)1