Skip to content

13 files changed

+853
-0
lines changed

docs/rules/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,12 +902,22 @@ These rules enforce best practices and naming conventions:
902902
|aws_route53_zone_invalid_comment||
903903
|aws_route53_zone_invalid_delegation_set_id||
904904
|aws_route53_zone_invalid_name||
905+
|aws_s3_bucket_intelligent_tiering_configuration_invalid_status||
905906
|aws_s3_bucket_invalid_acceleration_status||
906907
|aws_s3_bucket_invalid_request_payer||
907908
|aws_s3_bucket_inventory_invalid_included_object_versions||
908909
|aws_s3_bucket_object_invalid_acl||
909910
|aws_s3_bucket_object_invalid_server_side_encryption||
910911
|aws_s3_bucket_object_invalid_storage_class||
912+
|aws_s3_object_copy_invalid_acl||
913+
|aws_s3_object_copy_invalid_metadata_directive||
914+
|aws_s3_object_copy_invalid_object_lock_legal_hold_status||
915+
|aws_s3_object_copy_invalid_object_lock_mode||
916+
|aws_s3_object_copy_invalid_request_payer||
917+
|aws_s3_object_copy_invalid_server_side_encryption||
918+
|aws_s3_object_copy_invalid_source||
919+
|aws_s3_object_copy_invalid_storage_class||
920+
|aws_s3_object_copy_invalid_tagging_directive||
911921
|aws_s3control_access_point_policy_invalid_access_point_arn||
912922
|aws_s3control_bucket_invalid_bucket||
913923
|aws_s3control_bucket_invalid_outpost_id||
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+
// AwsS3BucketIntelligentTieringConfigurationInvalidStatusRule checks the pattern is valid
14+
type AwsS3BucketIntelligentTieringConfigurationInvalidStatusRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsS3BucketIntelligentTieringConfigurationInvalidStatusRule returns new rule with default attributes
21+
func NewAwsS3BucketIntelligentTieringConfigurationInvalidStatusRule() *AwsS3BucketIntelligentTieringConfigurationInvalidStatusRule {
22+
return &AwsS3BucketIntelligentTieringConfigurationInvalidStatusRule{
23+
resourceType: "aws_s3_bucket_intelligent_tiering_configuration",
24+
attributeName: "status",
25+
enum: []string{
26+
"Enabled",
27+
"Disabled",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsS3BucketIntelligentTieringConfigurationInvalidStatusRule) Name() string {
34+
return "aws_s3_bucket_intelligent_tiering_configuration_invalid_status"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsS3BucketIntelligentTieringConfigurationInvalidStatusRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsS3BucketIntelligentTieringConfigurationInvalidStatusRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsS3BucketIntelligentTieringConfigurationInvalidStatusRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsS3BucketIntelligentTieringConfigurationInvalidStatusRule) 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 status`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
// AwsS3ObjectCopyInvalidACLRule checks the pattern is valid
14+
type AwsS3ObjectCopyInvalidACLRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsS3ObjectCopyInvalidACLRule returns new rule with default attributes
21+
func NewAwsS3ObjectCopyInvalidACLRule() *AwsS3ObjectCopyInvalidACLRule {
22+
return &AwsS3ObjectCopyInvalidACLRule{
23+
resourceType: "aws_s3_object_copy",
24+
attributeName: "acl",
25+
enum: []string{
26+
"private",
27+
"public-read",
28+
"public-read-write",
29+
"authenticated-read",
30+
"aws-exec-read",
31+
"bucket-owner-read",
32+
"bucket-owner-full-control",
33+
},
34+
}
35+
}
36+
37+
// Name returns the rule name
38+
func (r *AwsS3ObjectCopyInvalidACLRule) Name() string {
39+
return "aws_s3_object_copy_invalid_acl"
40+
}
41+
42+
// Enabled returns whether the rule is enabled by default
43+
func (r *AwsS3ObjectCopyInvalidACLRule) Enabled() bool {
44+
return true
45+
}
46+
47+
// Severity returns the rule severity
48+
func (r *AwsS3ObjectCopyInvalidACLRule) Severity() string {
49+
return tflint.ERROR
50+
}
51+
52+
// Link returns the rule reference link
53+
func (r *AwsS3ObjectCopyInvalidACLRule) Link() string {
54+
return ""
55+
}
56+
57+
// Check checks the pattern is valid
58+
func (r *AwsS3ObjectCopyInvalidACLRule) Check(runner tflint.Runner) error {
59+
log.Printf("[TRACE] Check `%s` rule", r.Name())
60+
61+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
62+
var val string
63+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
64+
65+
return runner.EnsureNoError(err, func() error {
66+
found := false
67+
for _, item := range r.enum {
68+
if item == val {
69+
found = true
70+
}
71+
}
72+
if !found {
73+
runner.EmitIssueOnExpr(
74+
r,
75+
fmt.Sprintf(`"%s" is an invalid value as acl`, truncateLongMessage(val)),
76+
attribute.Expr,
77+
)
78+
}
79+
return nil
80+
})
81+
})
82+
}
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+
// AwsS3ObjectCopyInvalidMetadataDirectiveRule checks the pattern is valid
14+
type AwsS3ObjectCopyInvalidMetadataDirectiveRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsS3ObjectCopyInvalidMetadataDirectiveRule returns new rule with default attributes
21+
func NewAwsS3ObjectCopyInvalidMetadataDirectiveRule() *AwsS3ObjectCopyInvalidMetadataDirectiveRule {
22+
return &AwsS3ObjectCopyInvalidMetadataDirectiveRule{
23+
resourceType: "aws_s3_object_copy",
24+
attributeName: "metadata_directive",
25+
enum: []string{
26+
"COPY",
27+
"REPLACE",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsS3ObjectCopyInvalidMetadataDirectiveRule) Name() string {
34+
return "aws_s3_object_copy_invalid_metadata_directive"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsS3ObjectCopyInvalidMetadataDirectiveRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsS3ObjectCopyInvalidMetadataDirectiveRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsS3ObjectCopyInvalidMetadataDirectiveRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsS3ObjectCopyInvalidMetadataDirectiveRule) 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 metadata_directive`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}
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+
// AwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule checks the pattern is valid
14+
type AwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule returns new rule with default attributes
21+
func NewAwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule() *AwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule {
22+
return &AwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule{
23+
resourceType: "aws_s3_object_copy",
24+
attributeName: "object_lock_legal_hold_status",
25+
enum: []string{
26+
"ON",
27+
"OFF",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule) Name() string {
34+
return "aws_s3_object_copy_invalid_object_lock_legal_hold_status"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsS3ObjectCopyInvalidObjectLockLegalHoldStatusRule) 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 object_lock_legal_hold_status`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}

0 commit comments

Comments
 (0)