Skip to content

17 files changed

+1154
-0
lines changed

docs/rules/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,11 @@ These rules enforce best practices and naming conventions:
12501250
|aws_storagegateway_cached_iscsi_volume_invalid_snapshot_id||
12511251
|aws_storagegateway_cached_iscsi_volume_invalid_source_volume_arn||
12521252
|aws_storagegateway_cached_iscsi_volume_invalid_target_name||
1253+
|aws_storagegateway_file_system_association_invalid_audit_destination_arn||
1254+
|aws_storagegateway_file_system_association_invalid_gateway_arn||
1255+
|aws_storagegateway_file_system_association_invalid_location_arn||
1256+
|aws_storagegateway_file_system_association_invalid_password||
1257+
|aws_storagegateway_file_system_association_invalid_username||
12531258
|aws_storagegateway_gateway_invalid_activation_key||
12541259
|aws_storagegateway_gateway_invalid_gateway_name||
12551260
|aws_storagegateway_gateway_invalid_gateway_timezone||
@@ -1271,6 +1276,15 @@ These rules enforce best practices and naming conventions:
12711276
|aws_storagegateway_smb_file_share_invalid_location_arn||
12721277
|aws_storagegateway_smb_file_share_invalid_object_acl||
12731278
|aws_storagegateway_smb_file_share_invalid_role_arn||
1279+
|aws_storagegateway_stored_iscsi_volume_invalid_disk_id||
1280+
|aws_storagegateway_stored_iscsi_volume_invalid_gateway_arn||
1281+
|aws_storagegateway_stored_iscsi_volume_invalid_kms_key||
1282+
|aws_storagegateway_stored_iscsi_volume_invalid_network_interface_id||
1283+
|aws_storagegateway_stored_iscsi_volume_invalid_snapshot_id||
1284+
|aws_storagegateway_stored_iscsi_volume_invalid_target_name||
1285+
|aws_storagegateway_tape_pool_invalid_pool_name||
1286+
|aws_storagegateway_tape_pool_invalid_retention_lock_type||
1287+
|aws_storagegateway_tape_pool_invalid_storage_class||
12741288
|aws_storagegateway_upload_buffer_invalid_disk_id||
12751289
|aws_storagegateway_upload_buffer_invalid_gateway_arn||
12761290
|aws_storagegateway_working_storage_invalid_disk_id||
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule checks the pattern is valid
13+
type AwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
}
18+
19+
// NewAwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule returns new rule with default attributes
20+
func NewAwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule() *AwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule {
21+
return &AwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule{
22+
resourceType: "aws_storagegateway_file_system_association",
23+
attributeName: "audit_destination_arn",
24+
max: 1024,
25+
}
26+
}
27+
28+
// Name returns the rule name
29+
func (r *AwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule) Name() string {
30+
return "aws_storagegateway_file_system_association_invalid_audit_destination_arn"
31+
}
32+
33+
// Enabled returns whether the rule is enabled by default
34+
func (r *AwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule) Enabled() bool {
35+
return true
36+
}
37+
38+
// Severity returns the rule severity
39+
func (r *AwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule) Severity() string {
40+
return tflint.ERROR
41+
}
42+
43+
// Link returns the rule reference link
44+
func (r *AwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule) Link() string {
45+
return ""
46+
}
47+
48+
// Check checks the pattern is valid
49+
func (r *AwsStoragegatewayFileSystemAssociationInvalidAuditDestinationArnRule) Check(runner tflint.Runner) error {
50+
log.Printf("[TRACE] Check `%s` rule", r.Name())
51+
52+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
53+
var val string
54+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
55+
56+
return runner.EnsureNoError(err, func() error {
57+
if len(val) > r.max {
58+
runner.EmitIssueOnExpr(
59+
r,
60+
"audit_destination_arn must be 1024 characters or less",
61+
attribute.Expr,
62+
)
63+
}
64+
return nil
65+
})
66+
})
67+
}
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+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule checks the pattern is valid
13+
type AwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule returns new rule with default attributes
21+
func NewAwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule() *AwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule {
22+
return &AwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule{
23+
resourceType: "aws_storagegateway_file_system_association",
24+
attributeName: "gateway_arn",
25+
max: 500,
26+
min: 50,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule) Name() string {
32+
return "aws_storagegateway_file_system_association_invalid_gateway_arn"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsStoragegatewayFileSystemAssociationInvalidGatewayArnRule) Check(runner tflint.Runner) error {
52+
log.Printf("[TRACE] Check `%s` rule", r.Name())
53+
54+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
55+
var val string
56+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
57+
58+
return runner.EnsureNoError(err, func() error {
59+
if len(val) > r.max {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
"gateway_arn must be 500 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"gateway_arn must be 50 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}
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+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsStoragegatewayFileSystemAssociationInvalidLocationArnRule checks the pattern is valid
13+
type AwsStoragegatewayFileSystemAssociationInvalidLocationArnRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsStoragegatewayFileSystemAssociationInvalidLocationArnRule returns new rule with default attributes
21+
func NewAwsStoragegatewayFileSystemAssociationInvalidLocationArnRule() *AwsStoragegatewayFileSystemAssociationInvalidLocationArnRule {
22+
return &AwsStoragegatewayFileSystemAssociationInvalidLocationArnRule{
23+
resourceType: "aws_storagegateway_file_system_association",
24+
attributeName: "location_arn",
25+
max: 512,
26+
min: 8,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsStoragegatewayFileSystemAssociationInvalidLocationArnRule) Name() string {
32+
return "aws_storagegateway_file_system_association_invalid_location_arn"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsStoragegatewayFileSystemAssociationInvalidLocationArnRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsStoragegatewayFileSystemAssociationInvalidLocationArnRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsStoragegatewayFileSystemAssociationInvalidLocationArnRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsStoragegatewayFileSystemAssociationInvalidLocationArnRule) Check(runner tflint.Runner) error {
52+
log.Printf("[TRACE] Check `%s` rule", r.Name())
53+
54+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
55+
var val string
56+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
57+
58+
return runner.EnsureNoError(err, func() error {
59+
if len(val) > r.max {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
"location_arn must be 512 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"location_arn must be 8 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
// AwsStoragegatewayFileSystemAssociationInvalidPasswordRule checks the pattern is valid
14+
type AwsStoragegatewayFileSystemAssociationInvalidPasswordRule struct {
15+
resourceType string
16+
attributeName string
17+
max int
18+
min int
19+
pattern *regexp.Regexp
20+
}
21+
22+
// NewAwsStoragegatewayFileSystemAssociationInvalidPasswordRule returns new rule with default attributes
23+
func NewAwsStoragegatewayFileSystemAssociationInvalidPasswordRule() *AwsStoragegatewayFileSystemAssociationInvalidPasswordRule {
24+
return &AwsStoragegatewayFileSystemAssociationInvalidPasswordRule{
25+
resourceType: "aws_storagegateway_file_system_association",
26+
attributeName: "password",
27+
max: 1024,
28+
min: 1,
29+
pattern: regexp.MustCompile(`^[ -~]+$`),
30+
}
31+
}
32+
33+
// Name returns the rule name
34+
func (r *AwsStoragegatewayFileSystemAssociationInvalidPasswordRule) Name() string {
35+
return "aws_storagegateway_file_system_association_invalid_password"
36+
}
37+
38+
// Enabled returns whether the rule is enabled by default
39+
func (r *AwsStoragegatewayFileSystemAssociationInvalidPasswordRule) Enabled() bool {
40+
return true
41+
}
42+
43+
// Severity returns the rule severity
44+
func (r *AwsStoragegatewayFileSystemAssociationInvalidPasswordRule) Severity() string {
45+
return tflint.ERROR
46+
}
47+
48+
// Link returns the rule reference link
49+
func (r *AwsStoragegatewayFileSystemAssociationInvalidPasswordRule) Link() string {
50+
return ""
51+
}
52+
53+
// Check checks the pattern is valid
54+
func (r *AwsStoragegatewayFileSystemAssociationInvalidPasswordRule) 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+
if len(val) > r.max {
63+
runner.EmitIssueOnExpr(
64+
r,
65+
"password must be 1024 characters or less",
66+
attribute.Expr,
67+
)
68+
}
69+
if len(val) < r.min {
70+
runner.EmitIssueOnExpr(
71+
r,
72+
"password must be 1 characters or higher",
73+
attribute.Expr,
74+
)
75+
}
76+
if !r.pattern.MatchString(val) {
77+
runner.EmitIssueOnExpr(
78+
r,
79+
`password does not match valid pattern ^[ -~]+$`,
80+
attribute.Expr,
81+
)
82+
}
83+
return nil
84+
})
85+
})
86+
}

0 commit comments

Comments
 (0)