jckuester/awsweeper

[0.5.0] Regex filters for aws_iam_policy → id

skyzyx opened this issue · 1 comments

We have some corporate governance stuff applied over my company's 100+ AWS accounts. We developers use Terraform, the corporate governance resources are created using a variety of other tools.

I'm trying to clean-up all IAM policies that are created by developers, and not managed by these governance tools. But it would appear that regex support is not working correctly against aws_iam_policiesid field.

I've tried:

aws_iam_policy:
  - id: NOT(CloudTrail_CloudWatchLogs_Policy)
  - id: NOT(DatapipeOpsAccessPolicy)
  - id: NOT(Kentik)
  - id: NOT(turbot)

…as well as…

aws_iam_policy:
  - id: NOT(.*CloudTrail_CloudWatchLogs_Policy.*)
  - id: NOT(.*DatapipeOpsAccessPolicy.*)
  - id: NOT(.*Kentik.*)
  - id: NOT(.*turbot.*)

Am I applying the values correctly?

Hmmm…

It appears that this works. Maybe it'd be worthwhile to state that each - list item is applied as a boolean OR as opposed to a boolean AND.

aws_iam_policy:
  - id: NOT(CloudTrail_CloudWatchLogs_Policy|DatapipeOpsAccessPolicy|Kentik|turbot)