Skip to content

9 files changed

+516
-0
lines changed

docs/rules/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,12 @@ These rules enforce best practices and naming conventions:
523523
|aws_efs_mount_target_invalid_file_system_id||
524524
|aws_efs_mount_target_invalid_ip_address||
525525
|aws_efs_mount_target_invalid_subnet_id||
526+
|aws_eks_addon_invalid_cluster_name||
527+
|aws_eks_addon_invalid_resolve_conflicts||
528+
|aws_eks_addon_invalid_service_account_role_arn||
526529
|aws_eks_cluster_invalid_name||
530+
|aws_eks_node_group_invalid_ami_type||
531+
|aws_eks_node_group_invalid_capacity_type||
527532
|aws_elastic_beanstalk_application_invalid_description||
528533
|aws_elastic_beanstalk_application_invalid_name||
529534
|aws_elastic_beanstalk_application_version_invalid_application||
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
// AwsEcsAccountSettingDefaultInvalidNameRule checks the pattern is valid
14+
type AwsEcsAccountSettingDefaultInvalidNameRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsEcsAccountSettingDefaultInvalidNameRule returns new rule with default attributes
21+
func NewAwsEcsAccountSettingDefaultInvalidNameRule() *AwsEcsAccountSettingDefaultInvalidNameRule {
22+
return &AwsEcsAccountSettingDefaultInvalidNameRule{
23+
resourceType: "aws_ecs_account_setting_default",
24+
attributeName: "name",
25+
enum: []string{
26+
"serviceLongArnFormat",
27+
"taskLongArnFormat",
28+
"containerInstanceLongArnFormat",
29+
"awsvpcTrunking",
30+
"containerInsights",
31+
},
32+
}
33+
}
34+
35+
// Name returns the rule name
36+
func (r *AwsEcsAccountSettingDefaultInvalidNameRule) Name() string {
37+
return "aws_ecs_account_setting_default_invalid_name"
38+
}
39+
40+
// Enabled returns whether the rule is enabled by default
41+
func (r *AwsEcsAccountSettingDefaultInvalidNameRule) Enabled() bool {
42+
return true
43+
}
44+
45+
// Severity returns the rule severity
46+
func (r *AwsEcsAccountSettingDefaultInvalidNameRule) Severity() string {
47+
return tflint.ERROR
48+
}
49+
50+
// Link returns the rule reference link
51+
func (r *AwsEcsAccountSettingDefaultInvalidNameRule) Link() string {
52+
return ""
53+
}
54+
55+
// Check checks the pattern is valid
56+
func (r *AwsEcsAccountSettingDefaultInvalidNameRule) Check(runner tflint.Runner) error {
57+
log.Printf("[TRACE] Check `%s` rule", r.Name())
58+
59+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
60+
var val string
61+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
62+
63+
return runner.EnsureNoError(err, func() error {
64+
found := false
65+
for _, item := range r.enum {
66+
if item == val {
67+
found = true
68+
}
69+
}
70+
if !found {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
fmt.Sprintf(`"%s" is an invalid value as name`, truncateLongMessage(val)),
74+
attribute.Expr,
75+
)
76+
}
77+
return nil
78+
})
79+
})
80+
}
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+
// AwsEksAddonInvalidClusterNameRule checks the pattern is valid
15+
type AwsEksAddonInvalidClusterNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsEksAddonInvalidClusterNameRule returns new rule with default attributes
24+
func NewAwsEksAddonInvalidClusterNameRule() *AwsEksAddonInvalidClusterNameRule {
25+
return &AwsEksAddonInvalidClusterNameRule{
26+
resourceType: "aws_eks_addon",
27+
attributeName: "cluster_name",
28+
max: 100,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^[0-9A-Za-z][A-Za-z0-9\-_]*`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsEksAddonInvalidClusterNameRule) Name() string {
36+
return "aws_eks_addon_invalid_cluster_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsEksAddonInvalidClusterNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsEksAddonInvalidClusterNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsEksAddonInvalidClusterNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsEksAddonInvalidClusterNameRule) 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+
"cluster_name must be 100 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"cluster_name must be 1 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), `^[0-9A-Za-z][A-Za-z0-9\-_]*`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
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+
// AwsEksAddonInvalidResolveConflictsRule checks the pattern is valid
14+
type AwsEksAddonInvalidResolveConflictsRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsEksAddonInvalidResolveConflictsRule returns new rule with default attributes
21+
func NewAwsEksAddonInvalidResolveConflictsRule() *AwsEksAddonInvalidResolveConflictsRule {
22+
return &AwsEksAddonInvalidResolveConflictsRule{
23+
resourceType: "aws_eks_addon",
24+
attributeName: "resolve_conflicts",
25+
enum: []string{
26+
"OVERWRITE",
27+
"NONE",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsEksAddonInvalidResolveConflictsRule) Name() string {
34+
return "aws_eks_addon_invalid_resolve_conflicts"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsEksAddonInvalidResolveConflictsRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsEksAddonInvalidResolveConflictsRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsEksAddonInvalidResolveConflictsRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsEksAddonInvalidResolveConflictsRule) 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 resolve_conflicts`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}
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+
// AwsEksAddonInvalidServiceAccountRoleArnRule checks the pattern is valid
13+
type AwsEksAddonInvalidServiceAccountRoleArnRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsEksAddonInvalidServiceAccountRoleArnRule returns new rule with default attributes
21+
func NewAwsEksAddonInvalidServiceAccountRoleArnRule() *AwsEksAddonInvalidServiceAccountRoleArnRule {
22+
return &AwsEksAddonInvalidServiceAccountRoleArnRule{
23+
resourceType: "aws_eks_addon",
24+
attributeName: "service_account_role_arn",
25+
max: 255,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsEksAddonInvalidServiceAccountRoleArnRule) Name() string {
32+
return "aws_eks_addon_invalid_service_account_role_arn"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsEksAddonInvalidServiceAccountRoleArnRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsEksAddonInvalidServiceAccountRoleArnRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsEksAddonInvalidServiceAccountRoleArnRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsEksAddonInvalidServiceAccountRoleArnRule) 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+
"service_account_role_arn must be 255 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"service_account_role_arn must be 1 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}

0 commit comments

Comments
 (0)