Skip to content

16 files changed

+1135
-0
lines changed

docs/rules/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,23 @@ These rules enforce best practices and naming conventions:
893893
|aws_prometheus_rule_group_namespace_invalid_name||
894894
|aws_prometheus_rule_group_namespace_invalid_workspace_id||
895895
|aws_prometheus_workspace_invalid_alias||
896+
|aws_quicksight_data_source_invalid_aws_account_id||
897+
|aws_quicksight_data_source_invalid_name||
898+
|aws_quicksight_data_source_invalid_type||
896899
|aws_quicksight_group_invalid_aws_account_id||
897900
|aws_quicksight_group_invalid_description||
898901
|aws_quicksight_group_invalid_group_name||
899902
|aws_quicksight_group_invalid_namespace||
903+
|aws_quicksight_group_membership_invalid_aws_account_id||
904+
|aws_quicksight_group_membership_invalid_group_name||
905+
|aws_quicksight_group_membership_invalid_member_name||
906+
|aws_quicksight_group_membership_invalid_namespace||
907+
|aws_quicksight_user_invalid_aws_account_id||
908+
|aws_quicksight_user_invalid_identity_type||
909+
|aws_quicksight_user_invalid_namespace||
910+
|aws_quicksight_user_invalid_session_name||
911+
|aws_quicksight_user_invalid_user_name||
912+
|aws_quicksight_user_invalid_user_role||
900913
|aws_redshift_cluster_invalid_availability_zone||
901914
|aws_redshift_cluster_invalid_cluster_identifier||
902915
|aws_redshift_cluster_invalid_cluster_parameter_group_name||
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+
// AwsQuicksightDataSourceInvalidAwsAccountIDRule checks the pattern is valid
15+
type AwsQuicksightDataSourceInvalidAwsAccountIDRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsQuicksightDataSourceInvalidAwsAccountIDRule returns new rule with default attributes
24+
func NewAwsQuicksightDataSourceInvalidAwsAccountIDRule() *AwsQuicksightDataSourceInvalidAwsAccountIDRule {
25+
return &AwsQuicksightDataSourceInvalidAwsAccountIDRule{
26+
resourceType: "aws_quicksight_data_source",
27+
attributeName: "aws_account_id",
28+
max: 12,
29+
min: 12,
30+
pattern: regexp.MustCompile(`^[0-9]{12}$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsQuicksightDataSourceInvalidAwsAccountIDRule) Name() string {
36+
return "aws_quicksight_data_source_invalid_aws_account_id"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsQuicksightDataSourceInvalidAwsAccountIDRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsQuicksightDataSourceInvalidAwsAccountIDRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsQuicksightDataSourceInvalidAwsAccountIDRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsQuicksightDataSourceInvalidAwsAccountIDRule) 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+
"aws_account_id must be 12 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"aws_account_id must be 12 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-9]{12}$`),
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+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsQuicksightDataSourceInvalidNameRule checks the pattern is valid
13+
type AwsQuicksightDataSourceInvalidNameRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsQuicksightDataSourceInvalidNameRule returns new rule with default attributes
21+
func NewAwsQuicksightDataSourceInvalidNameRule() *AwsQuicksightDataSourceInvalidNameRule {
22+
return &AwsQuicksightDataSourceInvalidNameRule{
23+
resourceType: "aws_quicksight_data_source",
24+
attributeName: "name",
25+
max: 128,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsQuicksightDataSourceInvalidNameRule) Name() string {
32+
return "aws_quicksight_data_source_invalid_name"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsQuicksightDataSourceInvalidNameRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsQuicksightDataSourceInvalidNameRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsQuicksightDataSourceInvalidNameRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsQuicksightDataSourceInvalidNameRule) 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+
"name must be 128 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"name must be 1 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
// AwsQuicksightDataSourceInvalidTypeRule checks the pattern is valid
14+
type AwsQuicksightDataSourceInvalidTypeRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsQuicksightDataSourceInvalidTypeRule returns new rule with default attributes
21+
func NewAwsQuicksightDataSourceInvalidTypeRule() *AwsQuicksightDataSourceInvalidTypeRule {
22+
return &AwsQuicksightDataSourceInvalidTypeRule{
23+
resourceType: "aws_quicksight_data_source",
24+
attributeName: "type",
25+
enum: []string{
26+
"ADOBE_ANALYTICS",
27+
"AMAZON_ELASTICSEARCH",
28+
"ATHENA",
29+
"AURORA",
30+
"AURORA_POSTGRESQL",
31+
"AWS_IOT_ANALYTICS",
32+
"GITHUB",
33+
"JIRA",
34+
"MARIADB",
35+
"MYSQL",
36+
"ORACLE",
37+
"POSTGRESQL",
38+
"PRESTO",
39+
"REDSHIFT",
40+
"S3",
41+
"SALESFORCE",
42+
"SERVICENOW",
43+
"SNOWFLAKE",
44+
"SPARK",
45+
"SQLSERVER",
46+
"TERADATA",
47+
"TWITTER",
48+
"TIMESTREAM",
49+
"AMAZON_OPENSEARCH",
50+
"EXASOL",
51+
},
52+
}
53+
}
54+
55+
// Name returns the rule name
56+
func (r *AwsQuicksightDataSourceInvalidTypeRule) Name() string {
57+
return "aws_quicksight_data_source_invalid_type"
58+
}
59+
60+
// Enabled returns whether the rule is enabled by default
61+
func (r *AwsQuicksightDataSourceInvalidTypeRule) Enabled() bool {
62+
return true
63+
}
64+
65+
// Severity returns the rule severity
66+
func (r *AwsQuicksightDataSourceInvalidTypeRule) Severity() string {
67+
return tflint.ERROR
68+
}
69+
70+
// Link returns the rule reference link
71+
func (r *AwsQuicksightDataSourceInvalidTypeRule) Link() string {
72+
return ""
73+
}
74+
75+
// Check checks the pattern is valid
76+
func (r *AwsQuicksightDataSourceInvalidTypeRule) Check(runner tflint.Runner) error {
77+
log.Printf("[TRACE] Check `%s` rule", r.Name())
78+
79+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
80+
var val string
81+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
82+
83+
return runner.EnsureNoError(err, func() error {
84+
found := false
85+
for _, item := range r.enum {
86+
if item == val {
87+
found = true
88+
}
89+
}
90+
if !found {
91+
runner.EmitIssueOnExpr(
92+
r,
93+
fmt.Sprintf(`"%s" is an invalid value as type`, truncateLongMessage(val)),
94+
attribute.Expr,
95+
)
96+
}
97+
return nil
98+
})
99+
})
100+
}
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+
// AwsQuicksightGroupMembershipInvalidAwsAccountIDRule checks the pattern is valid
15+
type AwsQuicksightGroupMembershipInvalidAwsAccountIDRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsQuicksightGroupMembershipInvalidAwsAccountIDRule returns new rule with default attributes
24+
func NewAwsQuicksightGroupMembershipInvalidAwsAccountIDRule() *AwsQuicksightGroupMembershipInvalidAwsAccountIDRule {
25+
return &AwsQuicksightGroupMembershipInvalidAwsAccountIDRule{
26+
resourceType: "aws_quicksight_group_membership",
27+
attributeName: "aws_account_id",
28+
max: 12,
29+
min: 12,
30+
pattern: regexp.MustCompile(`^[0-9]{12}$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsQuicksightGroupMembershipInvalidAwsAccountIDRule) Name() string {
36+
return "aws_quicksight_group_membership_invalid_aws_account_id"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsQuicksightGroupMembershipInvalidAwsAccountIDRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsQuicksightGroupMembershipInvalidAwsAccountIDRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsQuicksightGroupMembershipInvalidAwsAccountIDRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsQuicksightGroupMembershipInvalidAwsAccountIDRule) 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+
"aws_account_id must be 12 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"aws_account_id must be 12 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-9]{12}$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}

0 commit comments

Comments
 (0)