Skip to content

16 files changed

+1137
-0
lines changed

docs/rules/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,19 @@ These rules enforce best practices and naming conventions:
772772
|aws_msk_cluster_invalid_enhanced_monitoring||
773773
|aws_msk_cluster_invalid_kafka_version||
774774
|aws_network_acl_rule_invalid_rule_action||
775+
|aws_networkfirewall_firewall_invalid_description||
776+
|aws_networkfirewall_firewall_invalid_firewall_policy_arn||
777+
|aws_networkfirewall_firewall_invalid_name||
778+
|aws_networkfirewall_firewall_invalid_vpc_id||
779+
|aws_networkfirewall_firewall_policy_invalid_description||
780+
|aws_networkfirewall_firewall_policy_invalid_name||
781+
|aws_networkfirewall_logging_configuration_invalid_firewall_arn||
782+
|aws_networkfirewall_resource_policy_invalid_policy||
783+
|aws_networkfirewall_resource_policy_invalid_resource_arn||
784+
|aws_networkfirewall_rule_group_invalid_description||
785+
|aws_networkfirewall_rule_group_invalid_name||
786+
|aws_networkfirewall_rule_group_invalid_rules||
787+
|aws_networkfirewall_rule_group_invalid_type||
775788
|aws_opsworks_application_invalid_type||
776789
|aws_opsworks_instance_invalid_architecture||
777790
|aws_opsworks_instance_invalid_auto_scaling_type||
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+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsNetworkfirewallFirewallInvalidDescriptionRule checks the pattern is valid
15+
type AwsNetworkfirewallFirewallInvalidDescriptionRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
pattern *regexp.Regexp
20+
}
21+
22+
// NewAwsNetworkfirewallFirewallInvalidDescriptionRule returns new rule with default attributes
23+
func NewAwsNetworkfirewallFirewallInvalidDescriptionRule() *AwsNetworkfirewallFirewallInvalidDescriptionRule {
24+
return &AwsNetworkfirewallFirewallInvalidDescriptionRule{
25+
resourceType: "aws_networkfirewall_firewall",
26+
attributeName: "description",
27+
max: 512,
28+
pattern: regexp.MustCompile(`^.*$`),
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsNetworkfirewallFirewallInvalidDescriptionRule) Name() string {
34+
return "aws_networkfirewall_firewall_invalid_description"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsNetworkfirewallFirewallInvalidDescriptionRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsNetworkfirewallFirewallInvalidDescriptionRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsNetworkfirewallFirewallInvalidDescriptionRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsNetworkfirewallFirewallInvalidDescriptionRule) 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+
if len(val) > r.max {
62+
runner.EmitIssueOnExpr(
63+
r,
64+
"description must be 512 characters or less",
65+
attribute.Expr,
66+
)
67+
}
68+
if !r.pattern.MatchString(val) {
69+
runner.EmitIssueOnExpr(
70+
r,
71+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^.*$`),
72+
attribute.Expr,
73+
)
74+
}
75+
return nil
76+
})
77+
})
78+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule checks the pattern is valid
15+
type AwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule returns new rule with default attributes
24+
func NewAwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule() *AwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule {
25+
return &AwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule{
26+
resourceType: "aws_networkfirewall_firewall",
27+
attributeName: "firewall_policy_arn",
28+
max: 256,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^arn:aws.*`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule) Name() string {
36+
return "aws_networkfirewall_firewall_invalid_firewall_policy_arn"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsNetworkfirewallFirewallInvalidFirewallPolicyArnRule) Check(runner tflint.Runner) error {
56+
log.Printf("[TRACE] Check `%s` rule", r.Name())
57+
58+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
59+
var val string
60+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
61+
62+
return runner.EnsureNoError(err, func() error {
63+
if len(val) > r.max {
64+
runner.EmitIssueOnExpr(
65+
r,
66+
"firewall_policy_arn must be 256 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"firewall_policy_arn must be 1 characters or higher",
74+
attribute.Expr,
75+
)
76+
}
77+
if !r.pattern.MatchString(val) {
78+
runner.EmitIssueOnExpr(
79+
r,
80+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^arn:aws.*`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsNetworkfirewallFirewallInvalidNameRule checks the pattern is valid
15+
type AwsNetworkfirewallFirewallInvalidNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsNetworkfirewallFirewallInvalidNameRule returns new rule with default attributes
24+
func NewAwsNetworkfirewallFirewallInvalidNameRule() *AwsNetworkfirewallFirewallInvalidNameRule {
25+
return &AwsNetworkfirewallFirewallInvalidNameRule{
26+
resourceType: "aws_networkfirewall_firewall",
27+
attributeName: "name",
28+
max: 128,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^[a-zA-Z0-9-]+$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsNetworkfirewallFirewallInvalidNameRule) Name() string {
36+
return "aws_networkfirewall_firewall_invalid_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsNetworkfirewallFirewallInvalidNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsNetworkfirewallFirewallInvalidNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsNetworkfirewallFirewallInvalidNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsNetworkfirewallFirewallInvalidNameRule) Check(runner tflint.Runner) error {
56+
log.Printf("[TRACE] Check `%s` rule", r.Name())
57+
58+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
59+
var val string
60+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
61+
62+
return runner.EnsureNoError(err, func() error {
63+
if len(val) > r.max {
64+
runner.EmitIssueOnExpr(
65+
r,
66+
"name must be 128 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"name must be 1 characters or higher",
74+
attribute.Expr,
75+
)
76+
}
77+
if !r.pattern.MatchString(val) {
78+
runner.EmitIssueOnExpr(
79+
r,
80+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[a-zA-Z0-9-]+$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsNetworkfirewallFirewallInvalidVpcIDRule checks the pattern is valid
15+
type AwsNetworkfirewallFirewallInvalidVpcIDRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsNetworkfirewallFirewallInvalidVpcIDRule returns new rule with default attributes
24+
func NewAwsNetworkfirewallFirewallInvalidVpcIDRule() *AwsNetworkfirewallFirewallInvalidVpcIDRule {
25+
return &AwsNetworkfirewallFirewallInvalidVpcIDRule{
26+
resourceType: "aws_networkfirewall_firewall",
27+
attributeName: "vpc_id",
28+
max: 128,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^vpc-[0-9a-f]+$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsNetworkfirewallFirewallInvalidVpcIDRule) Name() string {
36+
return "aws_networkfirewall_firewall_invalid_vpc_id"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsNetworkfirewallFirewallInvalidVpcIDRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsNetworkfirewallFirewallInvalidVpcIDRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsNetworkfirewallFirewallInvalidVpcIDRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsNetworkfirewallFirewallInvalidVpcIDRule) Check(runner tflint.Runner) error {
56+
log.Printf("[TRACE] Check `%s` rule", r.Name())
57+
58+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
59+
var val string
60+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
61+
62+
return runner.EnsureNoError(err, func() error {
63+
if len(val) > r.max {
64+
runner.EmitIssueOnExpr(
65+
r,
66+
"vpc_id must be 128 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"vpc_id must be 1 characters or higher",
74+
attribute.Expr,
75+
)
76+
}
77+
if !r.pattern.MatchString(val) {
78+
runner.EmitIssueOnExpr(
79+
r,
80+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^vpc-[0-9a-f]+$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}

0 commit comments

Comments
 (0)