jckuester/awsweeper

Multi filter option

opsrom opened this issue · 2 comments

Hi,
Using awsls I can retreive some IAM Roles, for example :

  • AWSCodePipelineServiceRole-eu-west-1-code-pipe
  • AWSReservedSSO_AWSManager_43EDDe333zzerqszee23
  • AWSServiceRoleForSSO
  • codebuild-as-code-build-service-role
  • MyCustomAccountAccessRole

My goal, delete all IAM Roles except :

  • those who start with "AWSReserved*"
  • those who start with "AWSServiceRole*"
  • the dedicated "MyCustomAccountAccessRole"

So awsweeper should delete :

  • AWSCodePipelineServiceRole-eu-west-1-code-pipe
  • codebuild-as-code-build-service-role

I try to build a filter.yml file to do this... but without success. How can I build a multi filtering on one attribute like "id" here.
Any help please ?

Thanks.

Hi @opsrom 👋

yes, you can do that. The following filter should work for you:

aws_iam_role:
  - id: NOT(^AWSReserved|^AWSServiceRole|^MyCustomAccountAccessRole$)

Hi @jckuester

It's the only syntax that I hadn't tried :)
Thank you very much, it works perfectly !