Skip to content

8 files changed

+428
-0
lines changed

docs/rules/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,11 @@ These rules enforce best practices and naming conventions:
727727
|aws_lightsail_static_ip_attachment_invalid_instance_name||
728728
|aws_lightsail_static_ip_attachment_invalid_static_ip_name||
729729
|aws_lightsail_static_ip_invalid_name||
730+
|aws_macie2_account_invalid_finding_publishing_frequency||
731+
|aws_macie2_account_invalid_status||
732+
|aws_macie2_classification_job_invalid_job_status||
733+
|aws_macie2_classification_job_invalid_job_type||
734+
|aws_macie2_findings_filter_invalid_action||
730735
|aws_macie_member_account_association_invalid_member_account_id||
731736
|aws_macie_s3_bucket_association_invalid_bucket_name||
732737
|aws_macie_s3_bucket_association_invalid_member_account_id||
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsMacie2AccountInvalidFindingPublishingFrequencyRule checks the pattern is valid
14+
type AwsMacie2AccountInvalidFindingPublishingFrequencyRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsMacie2AccountInvalidFindingPublishingFrequencyRule returns new rule with default attributes
21+
func NewAwsMacie2AccountInvalidFindingPublishingFrequencyRule() *AwsMacie2AccountInvalidFindingPublishingFrequencyRule {
22+
return &AwsMacie2AccountInvalidFindingPublishingFrequencyRule{
23+
resourceType: "aws_macie2_account",
24+
attributeName: "finding_publishing_frequency",
25+
enum: []string{
26+
"FIFTEEN_MINUTES",
27+
"ONE_HOUR",
28+
"SIX_HOURS",
29+
},
30+
}
31+
}
32+
33+
// Name returns the rule name
34+
func (r *AwsMacie2AccountInvalidFindingPublishingFrequencyRule) Name() string {
35+
return "aws_macie2_account_invalid_finding_publishing_frequency"
36+
}
37+
38+
// Enabled returns whether the rule is enabled by default
39+
func (r *AwsMacie2AccountInvalidFindingPublishingFrequencyRule) Enabled() bool {
40+
return true
41+
}
42+
43+
// Severity returns the rule severity
44+
func (r *AwsMacie2AccountInvalidFindingPublishingFrequencyRule) Severity() string {
45+
return tflint.ERROR
46+
}
47+
48+
// Link returns the rule reference link
49+
func (r *AwsMacie2AccountInvalidFindingPublishingFrequencyRule) Link() string {
50+
return ""
51+
}
52+
53+
// Check checks the pattern is valid
54+
func (r *AwsMacie2AccountInvalidFindingPublishingFrequencyRule) Check(runner tflint.Runner) error {
55+
log.Printf("[TRACE] Check `%s` rule", r.Name())
56+
57+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
58+
var val string
59+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
60+
61+
return runner.EnsureNoError(err, func() error {
62+
found := false
63+
for _, item := range r.enum {
64+
if item == val {
65+
found = true
66+
}
67+
}
68+
if !found {
69+
runner.EmitIssueOnExpr(
70+
r,
71+
fmt.Sprintf(`"%s" is an invalid value as finding_publishing_frequency`, truncateLongMessage(val)),
72+
attribute.Expr,
73+
)
74+
}
75+
return nil
76+
})
77+
})
78+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsMacie2AccountInvalidStatusRule checks the pattern is valid
14+
type AwsMacie2AccountInvalidStatusRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsMacie2AccountInvalidStatusRule returns new rule with default attributes
21+
func NewAwsMacie2AccountInvalidStatusRule() *AwsMacie2AccountInvalidStatusRule {
22+
return &AwsMacie2AccountInvalidStatusRule{
23+
resourceType: "aws_macie2_account",
24+
attributeName: "status",
25+
enum: []string{
26+
"PAUSED",
27+
"ENABLED",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsMacie2AccountInvalidStatusRule) Name() string {
34+
return "aws_macie2_account_invalid_status"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsMacie2AccountInvalidStatusRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsMacie2AccountInvalidStatusRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsMacie2AccountInvalidStatusRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsMacie2AccountInvalidStatusRule) Check(runner tflint.Runner) error {
54+
log.Printf("[TRACE] Check `%s` rule", r.Name())
55+
56+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
57+
var val string
58+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
59+
60+
return runner.EnsureNoError(err, func() error {
61+
found := false
62+
for _, item := range r.enum {
63+
if item == val {
64+
found = true
65+
}
66+
}
67+
if !found {
68+
runner.EmitIssueOnExpr(
69+
r,
70+
fmt.Sprintf(`"%s" is an invalid value as status`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsMacie2ClassificationJobInvalidJobStatusRule checks the pattern is valid
14+
type AwsMacie2ClassificationJobInvalidJobStatusRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsMacie2ClassificationJobInvalidJobStatusRule returns new rule with default attributes
21+
func NewAwsMacie2ClassificationJobInvalidJobStatusRule() *AwsMacie2ClassificationJobInvalidJobStatusRule {
22+
return &AwsMacie2ClassificationJobInvalidJobStatusRule{
23+
resourceType: "aws_macie2_classification_job",
24+
attributeName: "job_status",
25+
enum: []string{
26+
"RUNNING",
27+
"PAUSED",
28+
"CANCELLED",
29+
"COMPLETE",
30+
"IDLE",
31+
"USER_PAUSED",
32+
},
33+
}
34+
}
35+
36+
// Name returns the rule name
37+
func (r *AwsMacie2ClassificationJobInvalidJobStatusRule) Name() string {
38+
return "aws_macie2_classification_job_invalid_job_status"
39+
}
40+
41+
// Enabled returns whether the rule is enabled by default
42+
func (r *AwsMacie2ClassificationJobInvalidJobStatusRule) Enabled() bool {
43+
return true
44+
}
45+
46+
// Severity returns the rule severity
47+
func (r *AwsMacie2ClassificationJobInvalidJobStatusRule) Severity() string {
48+
return tflint.ERROR
49+
}
50+
51+
// Link returns the rule reference link
52+
func (r *AwsMacie2ClassificationJobInvalidJobStatusRule) Link() string {
53+
return ""
54+
}
55+
56+
// Check checks the pattern is valid
57+
func (r *AwsMacie2ClassificationJobInvalidJobStatusRule) Check(runner tflint.Runner) error {
58+
log.Printf("[TRACE] Check `%s` rule", r.Name())
59+
60+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
61+
var val string
62+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
63+
64+
return runner.EnsureNoError(err, func() error {
65+
found := false
66+
for _, item := range r.enum {
67+
if item == val {
68+
found = true
69+
}
70+
}
71+
if !found {
72+
runner.EmitIssueOnExpr(
73+
r,
74+
fmt.Sprintf(`"%s" is an invalid value as job_status`, truncateLongMessage(val)),
75+
attribute.Expr,
76+
)
77+
}
78+
return nil
79+
})
80+
})
81+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsMacie2ClassificationJobInvalidJobTypeRule checks the pattern is valid
14+
type AwsMacie2ClassificationJobInvalidJobTypeRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsMacie2ClassificationJobInvalidJobTypeRule returns new rule with default attributes
21+
func NewAwsMacie2ClassificationJobInvalidJobTypeRule() *AwsMacie2ClassificationJobInvalidJobTypeRule {
22+
return &AwsMacie2ClassificationJobInvalidJobTypeRule{
23+
resourceType: "aws_macie2_classification_job",
24+
attributeName: "job_type",
25+
enum: []string{
26+
"ONE_TIME",
27+
"SCHEDULED",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsMacie2ClassificationJobInvalidJobTypeRule) Name() string {
34+
return "aws_macie2_classification_job_invalid_job_type"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsMacie2ClassificationJobInvalidJobTypeRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsMacie2ClassificationJobInvalidJobTypeRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsMacie2ClassificationJobInvalidJobTypeRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsMacie2ClassificationJobInvalidJobTypeRule) Check(runner tflint.Runner) error {
54+
log.Printf("[TRACE] Check `%s` rule", r.Name())
55+
56+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
57+
var val string
58+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
59+
60+
return runner.EnsureNoError(err, func() error {
61+
found := false
62+
for _, item := range r.enum {
63+
if item == val {
64+
found = true
65+
}
66+
}
67+
if !found {
68+
runner.EmitIssueOnExpr(
69+
r,
70+
fmt.Sprintf(`"%s" is an invalid value as job_type`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}

0 commit comments

Comments
 (0)