Skip to content

13 files changed

+819
-0
lines changed

docs/rules/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,20 @@ These rules enforce best practices and naming conventions:
461461
|aws_datasync_agent_invalid_name||
462462
|aws_datasync_location_efs_invalid_efs_file_system_arn||
463463
|aws_datasync_location_efs_invalid_subdirectory||
464+
|aws_datasync_location_fsx_windows_file_system_invalid_domain||
465+
|aws_datasync_location_fsx_windows_file_system_invalid_fsx_filesystem_arn||
466+
|aws_datasync_location_fsx_windows_file_system_invalid_password||
467+
|aws_datasync_location_fsx_windows_file_system_invalid_subdirectory||
468+
|aws_datasync_location_fsx_windows_file_system_invalid_user||
464469
|aws_datasync_location_nfs_invalid_server_hostname||
465470
|aws_datasync_location_nfs_invalid_subdirectory||
466471
|aws_datasync_location_s3_invalid_s3_bucket_arn||
467472
|aws_datasync_location_s3_invalid_subdirectory||
473+
|aws_datasync_location_smb_invalid_domain||
474+
|aws_datasync_location_smb_invalid_password||
475+
|aws_datasync_location_smb_invalid_server_hostname||
476+
|aws_datasync_location_smb_invalid_subdirectory||
477+
|aws_datasync_location_smb_invalid_user||
468478
|aws_datasync_task_invalid_cloudwatch_log_group_arn||
469479
|aws_datasync_task_invalid_destination_location_arn||
470480
|aws_datasync_task_invalid_name||
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+
// AwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule checks the pattern is valid
15+
type AwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
pattern *regexp.Regexp
20+
}
21+
22+
// NewAwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule returns new rule with default attributes
23+
func NewAwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule() *AwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule {
24+
return &AwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule{
25+
resourceType: "aws_datasync_location_fsx_windows_file_system",
26+
attributeName: "domain",
27+
max: 253,
28+
pattern: regexp.MustCompile(`^([A-Za-z0-9]+[A-Za-z0-9-.]*)*[A-Za-z0-9-]*[A-Za-z0-9]$`),
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule) Name() string {
34+
return "aws_datasync_location_fsx_windows_file_system_invalid_domain"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidDomainRule) 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+
"domain must be 253 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), `^([A-Za-z0-9]+[A-Za-z0-9-.]*)*[A-Za-z0-9-]*[A-Za-z0-9]$`),
72+
attribute.Expr,
73+
)
74+
}
75+
return nil
76+
})
77+
})
78+
}
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+
// AwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule checks the pattern is valid
15+
type AwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
pattern *regexp.Regexp
20+
}
21+
22+
// NewAwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule returns new rule with default attributes
23+
func NewAwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule() *AwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule {
24+
return &AwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule{
25+
resourceType: "aws_datasync_location_fsx_windows_file_system",
26+
attributeName: "fsx_filesystem_arn",
27+
max: 128,
28+
pattern: regexp.MustCompile(`^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):fsx:[a-z\-0-9]*:[0-9]{12}:file-system/fs-.*$`),
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule) Name() string {
34+
return "aws_datasync_location_fsx_windows_file_system_invalid_fsx_filesystem_arn"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidFsxFilesystemArnRule) 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+
"fsx_filesystem_arn must be 128 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), `^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):fsx:[a-z\-0-9]*:[0-9]{12}:file-system/fs-.*$`),
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+
"log"
7+
"regexp"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule checks the pattern is valid
14+
type AwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule struct {
15+
resourceType string
16+
attributeName string
17+
max int
18+
pattern *regexp.Regexp
19+
}
20+
21+
// NewAwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule returns new rule with default attributes
22+
func NewAwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule() *AwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule {
23+
return &AwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule{
24+
resourceType: "aws_datasync_location_fsx_windows_file_system",
25+
attributeName: "password",
26+
max: 104,
27+
pattern: regexp.MustCompile(`^.{0,104}$`),
28+
}
29+
}
30+
31+
// Name returns the rule name
32+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule) Name() string {
33+
return "aws_datasync_location_fsx_windows_file_system_invalid_password"
34+
}
35+
36+
// Enabled returns whether the rule is enabled by default
37+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule) Enabled() bool {
38+
return true
39+
}
40+
41+
// Severity returns the rule severity
42+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule) Severity() string {
43+
return tflint.ERROR
44+
}
45+
46+
// Link returns the rule reference link
47+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule) Link() string {
48+
return ""
49+
}
50+
51+
// Check checks the pattern is valid
52+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidPasswordRule) 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+
if len(val) > r.max {
61+
runner.EmitIssueOnExpr(
62+
r,
63+
"password must be 104 characters or less",
64+
attribute.Expr,
65+
)
66+
}
67+
if !r.pattern.MatchString(val) {
68+
runner.EmitIssueOnExpr(
69+
r,
70+
`password does not match valid pattern ^.{0,104}$`,
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}
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+
// AwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule checks the pattern is valid
15+
type AwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
pattern *regexp.Regexp
20+
}
21+
22+
// NewAwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule returns new rule with default attributes
23+
func NewAwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule() *AwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule {
24+
return &AwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule{
25+
resourceType: "aws_datasync_location_fsx_windows_file_system",
26+
attributeName: "subdirectory",
27+
max: 4096,
28+
pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-\+\./\(\)\$\p{Zs}]+$`),
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule) Name() string {
34+
return "aws_datasync_location_fsx_windows_file_system_invalid_subdirectory"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsDatasyncLocationFsxWindowsFileSystemInvalidSubdirectoryRule) 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+
"subdirectory must be 4096 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), `^[a-zA-Z0-9_\-\+\./\(\)\$\p{Zs}]+$`),
72+
attribute.Expr,
73+
)
74+
}
75+
return nil
76+
})
77+
})
78+
}

0 commit comments

Comments
 (0)