Created
August 24, 2024 11:01
-
-
Save rinx/2782343134accb63204f62ea76262e53 to your computer and use it in GitHub Desktop.
ast-grep rule for detecting terraform resources that does not have `project` attribute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json | |
id: google-resource-no-project-attr | |
message: All google resource should have `project` attribute. | |
severity: warning | |
language: terraform | |
rule: | |
kind: block | |
all: | |
- has: | |
kind: identifier | |
pattern: resource | |
- has: | |
kind: string_lit | |
all: | |
- has: | |
kind: template_literal | |
regex: google_.* | |
- not: | |
has: | |
kind: template_literal | |
regex: google_service_account_iam_member | |
- has: | |
kind: body | |
not: | |
has: | |
kind: attribute | |
has: | |
kind: identifier | |
pattern: project |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment