GithubHelp home page GithubHelp logo

Comments (4)

castrapel avatar castrapel commented on May 31, 2024

CC @datfinesoul

from iambic.

datfinesoul avatar datfinesoul commented on May 31, 2024

After #388 is implemented it will be easier to provide more detailed feedback as to how this would be useful. IMO it would be worth holding off until that one is done.

from iambic.

castrapel avatar castrapel commented on May 31, 2024

Internally, we're talking about a provider-agnostic way to ignore resources. A Pydantic model might look something like the following:

class ExcludedResources(BaseModel):
    """
    The ExcludedResources class allows you to specify resources that should be excluded during the template generation process in IAMbic. This class provides a provider-agnostic mechanism to selectively ignore resources based on their attributes, such as template types, names, paths, and tags.

    The exclusion criteria are defined using regular expressions, offering flexible matching capabilities. You can define multiple criteria within each attribute, and a resource must match all specified criteria to be excluded.

    The exclusion logic works based on the AND/OR boolean logic. For instance, if you specify multiple tags, a resource will be excluded if it matches the template type AND any of the specified tags. 

    Attributes:
    template_types: A list of template types to exclude. These should be defined in the form of regular expressions.
    names: A list of resource names to exclude. These should be defined in the form of regular expressions.
    paths: A list of paths to exclude. These should be defined in the form of regular expressions.
    tags: A list of tags to exclude. Each tag is a dictionary with a 'key' and 'value', both of which should be defined in the form of regular expressions.
    """
    template_types: Optional[list[str]] = Field(
        description="A list of template types to exclude. Regular expressions are supported for defining the types."
    )
    names: Optional[list[str]] = Field(
        description="A list of resource names to exclude. Regular expressions are supported for defining the names."
    )
    paths: Optional[list[str]] = Field(
        description="A list of paths to exclude. Regular expressions are supported for defining the paths."
    )
    tags: Optional[list[dict]] = Field(
        description="A list of tags to exclude. Each tag is a dictionary with 'key' and 'value' fields, both supporting regular expressions."
    )

Example template:

template_type: NOQ::Core::Config
version: '1'
core:
  exclude_resources:
    - template_types: 
        - 'NOQ::AWS::IAM::Role'
      names:
        - 'amplify-.*'
    - template_types:
        - 'NOQ::AWS::IAM::Role'
      paths:
        - '/aws-reserved/.*'
        - '/cdk/.*'
    - template_types:
        - 'NOQ::AWS::.*'
      tags:
        - key: 'aws:cloudformation:stack-name'
          value: '.*'
        - key: 'aws:cdk:asset'

from iambic.

castrapel avatar castrapel commented on May 31, 2024

Another option we discussed in Slack
(Join here) is a configuration specific to a provider. This would be an easier change because the AWS configuration is already passed around to the AWS provider plugin.

import_rules:
  - match_tags:
      - key: terraform
        # optional `value` field
    action: iambic_managed.import_only
  - match_names:
      - "AWS SSO Role*"
      - "CDK*"
      - "CloudFormation*"
    action: ignore
  - match_paths:
      - "/service-role/*"
    action: ignore
  - match_tags:
      - key: "ManagedBy"
        value: "CDK"
    action: ignore
  - match_template_types:
      - "NOQ::AWS::IAM::ManagedPolicy"
    action: iambic_managed.import_only

from iambic.

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.