Skip to content

18 files changed

+1341
-0
lines changed

docs/rules/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,22 @@ These rules enforce best practices and naming conventions:
581581
|aws_flow_log_invalid_log_destination_type||
582582
|aws_flow_log_invalid_traffic_type||
583583
|aws_fms_admin_account_invalid_account_id||
584+
|aws_fsx_backup_invalid_file_system_id||
585+
|aws_fsx_backup_invalid_volume_id||
584586
|aws_fsx_lustre_file_system_invalid_weekly_maintenance_start_time||
587+
|aws_fsx_ontap_file_system_invalid_daily_automatic_backup_start_time||
588+
|aws_fsx_ontap_file_system_invalid_deployment_type||
589+
|aws_fsx_ontap_file_system_invalid_endpoint_ip_address_range||
590+
|aws_fsx_ontap_file_system_invalid_fsx_admin_password||
591+
|aws_fsx_ontap_file_system_invalid_preferred_subnet_id||
592+
|aws_fsx_ontap_file_system_invalid_weekly_maintenance_start_time||
593+
|aws_fsx_ontap_storage_virtual_machine_invalid_file_system_id||
594+
|aws_fsx_ontap_storage_virtual_machine_invalid_name||
595+
|aws_fsx_ontap_storage_virtual_machine_invalid_root_volume_security_style||
596+
|aws_fsx_ontap_volume_invalid_junction_path||
597+
|aws_fsx_ontap_volume_invalid_name||
598+
|aws_fsx_ontap_volume_invalid_security_style||
599+
|aws_fsx_ontap_volume_invalid_storage_virtual_machine_id||
585600
|aws_fsx_windows_file_system_invalid_active_directory_id||
586601
|aws_fsx_windows_file_system_invalid_daily_automatic_backup_start_time||
587602
|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+
// AwsFsxBackupInvalidFileSystemIDRule checks the pattern is valid
15+
type AwsFsxBackupInvalidFileSystemIDRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsFsxBackupInvalidFileSystemIDRule returns new rule with default attributes
24+
func NewAwsFsxBackupInvalidFileSystemIDRule() *AwsFsxBackupInvalidFileSystemIDRule {
25+
return &AwsFsxBackupInvalidFileSystemIDRule{
26+
resourceType: "aws_fsx_backup",
27+
attributeName: "file_system_id",
28+
max: 21,
29+
min: 11,
30+
pattern: regexp.MustCompile(`^(fs-[0-9a-f]{8,})$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsFsxBackupInvalidFileSystemIDRule) Name() string {
36+
return "aws_fsx_backup_invalid_file_system_id"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsFsxBackupInvalidFileSystemIDRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsFsxBackupInvalidFileSystemIDRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsFsxBackupInvalidFileSystemIDRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsFsxBackupInvalidFileSystemIDRule) 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+
"file_system_id must be 21 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"file_system_id must be 11 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), `^(fs-[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+
// AwsFsxBackupInvalidVolumeIDRule checks the pattern is valid
15+
type AwsFsxBackupInvalidVolumeIDRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsFsxBackupInvalidVolumeIDRule returns new rule with default attributes
24+
func NewAwsFsxBackupInvalidVolumeIDRule() *AwsFsxBackupInvalidVolumeIDRule {
25+
return &AwsFsxBackupInvalidVolumeIDRule{
26+
resourceType: "aws_fsx_backup",
27+
attributeName: "volume_id",
28+
max: 23,
29+
min: 23,
30+
pattern: regexp.MustCompile(`^(fsvol-[0-9a-f]{17,})$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsFsxBackupInvalidVolumeIDRule) Name() string {
36+
return "aws_fsx_backup_invalid_volume_id"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsFsxBackupInvalidVolumeIDRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsFsxBackupInvalidVolumeIDRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsFsxBackupInvalidVolumeIDRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsFsxBackupInvalidVolumeIDRule) 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+
"volume_id must be 23 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"volume_id must be 23 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), `^(fsvol-[0-9a-f]{17,})$`),
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+
// AwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule checks the pattern is valid
15+
type AwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule returns new rule with default attributes
24+
func NewAwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule() *AwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule {
25+
return &AwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule{
26+
resourceType: "aws_fsx_ontap_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 *AwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule) Name() string {
36+
return "aws_fsx_ontap_file_system_invalid_daily_automatic_backup_start_time"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsFsxOntapFileSystemInvalidDailyAutomaticBackupStartTimeRule) 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+
// AwsFsxOntapFileSystemInvalidDeploymentTypeRule checks the pattern is valid
14+
type AwsFsxOntapFileSystemInvalidDeploymentTypeRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsFsxOntapFileSystemInvalidDeploymentTypeRule returns new rule with default attributes
21+
func NewAwsFsxOntapFileSystemInvalidDeploymentTypeRule() *AwsFsxOntapFileSystemInvalidDeploymentTypeRule {
22+
return &AwsFsxOntapFileSystemInvalidDeploymentTypeRule{
23+
resourceType: "aws_fsx_ontap_file_system",
24+
attributeName: "deployment_type",
25+
enum: []string{
26+
"MULTI_AZ_1",
27+
},
28+
}
29+
}
30+
31+
// Name returns the rule name
32+
func (r *AwsFsxOntapFileSystemInvalidDeploymentTypeRule) Name() string {
33+
return "aws_fsx_ontap_file_system_invalid_deployment_type"
34+
}
35+
36+
// Enabled returns whether the rule is enabled by default
37+
func (r *AwsFsxOntapFileSystemInvalidDeploymentTypeRule) Enabled() bool {
38+
return true
39+
}
40+
41+
// Severity returns the rule severity
42+
func (r *AwsFsxOntapFileSystemInvalidDeploymentTypeRule) Severity() string {
43+
return tflint.ERROR
44+
}
45+
46+
// Link returns the rule reference link
47+
func (r *AwsFsxOntapFileSystemInvalidDeploymentTypeRule) Link() string {
48+
return ""
49+
}
50+
51+
// Check checks the pattern is valid
52+
func (r *AwsFsxOntapFileSystemInvalidDeploymentTypeRule) 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+
}

0 commit comments

Comments
 (0)