Giter Site home page Giter Site logo

Comments (1)

jhaage-jama avatar jhaage-jama commented on June 26, 2024

I ran into this same issue. It looks like the logic here is to see if the excluded_mapping_value is not in the mapping_value (i.e. not an excluded value) then add it to the candidates. The problem with the current logic is that each AMI needs to run through each excluded mapping value. For one or more of the excluded mapping values you pass in it won't match and then will add that AMI to the candidates list. It also has the unfortunate side effect of duplicating any AMIs that weren't going to be excluded in the first place.

I worked around this by changing the strategy and pre-populating the candidates list (same as it does when there are no --excluded-mapping-values provided) but then removing any AMIs from the list if they match any of the excluded values.

This seems to fix the two issues I was seeing:

  1. Excluded AMIs still show up in the list of candidates to delete
  2. Candidates to delete are duplicated

The bit of logic that handles this is in core.py, within the map_candidates method. Here's the section of this method I modified:

if mapping_strategy.get("excluded"): mapping_list = candidates_map.get(mapping_value) or [] mapping_list.append(ami) candidates_map[mapping_value] = mapping_list for excluded_mapping_value in mapping_strategy.get("excluded"): if excluded_mapping_value in mapping_value: print("Excluding AMI from candidates list based on exclusion: {}".format(mapping_value)) mapping_list = candidates_map.get(mapping_value) or [] mapping_list.remove(ami) candidates_map[mapping_value] = mapping_list

from aws-amicleaner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.