Skip to content

12 files changed

+806
-0
lines changed

docs/rules/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,15 @@ These rules enforce best practices and naming conventions:
653653
|aws_fsx_ontap_volume_invalid_name||
654654
|aws_fsx_ontap_volume_invalid_security_style||
655655
|aws_fsx_ontap_volume_invalid_storage_virtual_machine_id||
656+
|aws_fsx_openzfs_file_system_invalid_backup_id||
657+
|aws_fsx_openzfs_file_system_invalid_daily_automatic_backup_start_time||
658+
|aws_fsx_openzfs_file_system_invalid_deployment_type||
659+
|aws_fsx_openzfs_file_system_invalid_storage_type||
660+
|aws_fsx_openzfs_file_system_invalid_weekly_maintenance_start_time||
661+
|aws_fsx_openzfs_snapshot_invalid_name||
662+
|aws_fsx_openzfs_snapshot_invalid_volume_id||
663+
|aws_fsx_openzfs_volume_invalid_data_compression_type||
664+
|aws_fsx_openzfs_volume_invalid_parent_volume_id||
656665
|aws_fsx_windows_file_system_invalid_active_directory_id||
657666
|aws_fsx_windows_file_system_invalid_daily_automatic_backup_start_time||
658667
|aws_fsx_windows_file_system_invalid_weekly_maintenance_start_time||
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+
// AwsFsxOpenzfsFileSystemInvalidBackupIDRule checks the pattern is valid
15+
type AwsFsxOpenzfsFileSystemInvalidBackupIDRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsFsxOpenzfsFileSystemInvalidBackupIDRule returns new rule with default attributes
24+
func NewAwsFsxOpenzfsFileSystemInvalidBackupIDRule() *AwsFsxOpenzfsFileSystemInvalidBackupIDRule {
25+
return &AwsFsxOpenzfsFileSystemInvalidBackupIDRule{
26+
resourceType: "aws_fsx_openzfs_file_system",
27+
attributeName: "backup_id",
28+
max: 128,
29+
min: 12,
30+
pattern: regexp.MustCompile(`^(backup-[0-9a-f]{8,})$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsFsxOpenzfsFileSystemInvalidBackupIDRule) Name() string {
36+
return "aws_fsx_openzfs_file_system_invalid_backup_id"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsFsxOpenzfsFileSystemInvalidBackupIDRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsFsxOpenzfsFileSystemInvalidBackupIDRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsFsxOpenzfsFileSystemInvalidBackupIDRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsFsxOpenzfsFileSystemInvalidBackupIDRule) 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+
"backup_id must be 128 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"backup_id must be 12 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), `^(backup-[0-9a-f]{8,})$`),
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+
// AwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule checks the pattern is valid
15+
type AwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule returns new rule with default attributes
24+
func NewAwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule() *AwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule {
25+
return &AwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule{
26+
resourceType: "aws_fsx_openzfs_file_system",
27+
attributeName: "daily_automatic_backup_start_time",
28+
max: 5,
29+
min: 5,
30+
pattern: regexp.MustCompile(`^([01]\d|2[0-3]):?([0-5]\d)$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule) Name() string {
36+
return "aws_fsx_openzfs_file_system_invalid_daily_automatic_backup_start_time"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsFsxOpenzfsFileSystemInvalidDailyAutomaticBackupStartTimeRule) 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+
"daily_automatic_backup_start_time must be 5 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"daily_automatic_backup_start_time must be 5 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), `^([01]\d|2[0-3]):?([0-5]\d)$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
// AwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule checks the pattern is valid
14+
type AwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule returns new rule with default attributes
21+
func NewAwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule() *AwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule {
22+
return &AwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule{
23+
resourceType: "aws_fsx_openzfs_file_system",
24+
attributeName: "deployment_type",
25+
enum: []string{
26+
"SINGLE_AZ_1",
27+
},
28+
}
29+
}
30+
31+
// Name returns the rule name
32+
func (r *AwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule) Name() string {
33+
return "aws_fsx_openzfs_file_system_invalid_deployment_type"
34+
}
35+
36+
// Enabled returns whether the rule is enabled by default
37+
func (r *AwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule) Enabled() bool {
38+
return true
39+
}
40+
41+
// Severity returns the rule severity
42+
func (r *AwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule) Severity() string {
43+
return tflint.ERROR
44+
}
45+
46+
// Link returns the rule reference link
47+
func (r *AwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule) Link() string {
48+
return ""
49+
}
50+
51+
// Check checks the pattern is valid
52+
func (r *AwsFsxOpenzfsFileSystemInvalidDeploymentTypeRule) Check(runner tflint.Runner) error {
53+
log.Printf("[TRACE] Check `%s` rule", r.Name())
54+
55+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
56+
var val string
57+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
58+
59+
return runner.EnsureNoError(err, func() error {
60+
found := false
61+
for _, item := range r.enum {
62+
if item == val {
63+
found = true
64+
}
65+
}
66+
if !found {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
fmt.Sprintf(`"%s" is an invalid value as deployment_type`, truncateLongMessage(val)),
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}
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+
// AwsFsxOpenzfsFileSystemInvalidStorageTypeRule checks the pattern is valid
14+
type AwsFsxOpenzfsFileSystemInvalidStorageTypeRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsFsxOpenzfsFileSystemInvalidStorageTypeRule returns new rule with default attributes
21+
func NewAwsFsxOpenzfsFileSystemInvalidStorageTypeRule() *AwsFsxOpenzfsFileSystemInvalidStorageTypeRule {
22+
return &AwsFsxOpenzfsFileSystemInvalidStorageTypeRule{
23+
resourceType: "aws_fsx_openzfs_file_system",
24+
attributeName: "storage_type",
25+
enum: []string{
26+
"SSD",
27+
"HDD",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsFsxOpenzfsFileSystemInvalidStorageTypeRule) Name() string {
34+
return "aws_fsx_openzfs_file_system_invalid_storage_type"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsFsxOpenzfsFileSystemInvalidStorageTypeRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsFsxOpenzfsFileSystemInvalidStorageTypeRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsFsxOpenzfsFileSystemInvalidStorageTypeRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsFsxOpenzfsFileSystemInvalidStorageTypeRule) 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 storage_type`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}

0 commit comments

Comments
 (0)