Skip to content

7 files changed

+305
-0
lines changed

docs/rules/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,10 @@ These rules enforce best practices and naming conventions:
13271327
|aws_swf_domain_invalid_description||
13281328
|aws_swf_domain_invalid_name||
13291329
|aws_swf_domain_invalid_workflow_execution_retention_period_in_days||
1330+
|aws_timestreamwrite_database_invalid_database_name||
1331+
|aws_timestreamwrite_database_invalid_kms_key_id||
1332+
|aws_timestreamwrite_table_invalid_database_name||
1333+
|aws_timestreamwrite_table_invalid_table_name||
13301334
|aws_transfer_server_invalid_endpoint_type||
13311335
|aws_transfer_server_invalid_identity_provider_type||
13321336
|aws_transfer_server_invalid_invocation_role||
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
// AwsTimestreamwriteDatabaseInvalidDatabaseNameRule checks the pattern is valid
15+
type AwsTimestreamwriteDatabaseInvalidDatabaseNameRule struct {
16+
resourceType string
17+
attributeName string
18+
pattern *regexp.Regexp
19+
}
20+
21+
// NewAwsTimestreamwriteDatabaseInvalidDatabaseNameRule returns new rule with default attributes
22+
func NewAwsTimestreamwriteDatabaseInvalidDatabaseNameRule() *AwsTimestreamwriteDatabaseInvalidDatabaseNameRule {
23+
return &AwsTimestreamwriteDatabaseInvalidDatabaseNameRule{
24+
resourceType: "aws_timestreamwrite_database",
25+
attributeName: "database_name",
26+
pattern: regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`),
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsTimestreamwriteDatabaseInvalidDatabaseNameRule) Name() string {
32+
return "aws_timestreamwrite_database_invalid_database_name"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsTimestreamwriteDatabaseInvalidDatabaseNameRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsTimestreamwriteDatabaseInvalidDatabaseNameRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsTimestreamwriteDatabaseInvalidDatabaseNameRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsTimestreamwriteDatabaseInvalidDatabaseNameRule) 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 !r.pattern.MatchString(val) {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[a-zA-Z0-9_.-]+$`),
63+
attribute.Expr,
64+
)
65+
}
66+
return nil
67+
})
68+
})
69+
}
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+
// AwsTimestreamwriteDatabaseInvalidKmsKeyIDRule checks the pattern is valid
13+
type AwsTimestreamwriteDatabaseInvalidKmsKeyIDRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsTimestreamwriteDatabaseInvalidKmsKeyIDRule returns new rule with default attributes
21+
func NewAwsTimestreamwriteDatabaseInvalidKmsKeyIDRule() *AwsTimestreamwriteDatabaseInvalidKmsKeyIDRule {
22+
return &AwsTimestreamwriteDatabaseInvalidKmsKeyIDRule{
23+
resourceType: "aws_timestreamwrite_database",
24+
attributeName: "kms_key_id",
25+
max: 2048,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsTimestreamwriteDatabaseInvalidKmsKeyIDRule) Name() string {
32+
return "aws_timestreamwrite_database_invalid_kms_key_id"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsTimestreamwriteDatabaseInvalidKmsKeyIDRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsTimestreamwriteDatabaseInvalidKmsKeyIDRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsTimestreamwriteDatabaseInvalidKmsKeyIDRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsTimestreamwriteDatabaseInvalidKmsKeyIDRule) 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+
"kms_key_id must be 2048 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"kms_key_id must be 1 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
// AwsTimestreamwriteTableInvalidDatabaseNameRule checks the pattern is valid
15+
type AwsTimestreamwriteTableInvalidDatabaseNameRule struct {
16+
resourceType string
17+
attributeName string
18+
pattern *regexp.Regexp
19+
}
20+
21+
// NewAwsTimestreamwriteTableInvalidDatabaseNameRule returns new rule with default attributes
22+
func NewAwsTimestreamwriteTableInvalidDatabaseNameRule() *AwsTimestreamwriteTableInvalidDatabaseNameRule {
23+
return &AwsTimestreamwriteTableInvalidDatabaseNameRule{
24+
resourceType: "aws_timestreamwrite_table",
25+
attributeName: "database_name",
26+
pattern: regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`),
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsTimestreamwriteTableInvalidDatabaseNameRule) Name() string {
32+
return "aws_timestreamwrite_table_invalid_database_name"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsTimestreamwriteTableInvalidDatabaseNameRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsTimestreamwriteTableInvalidDatabaseNameRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsTimestreamwriteTableInvalidDatabaseNameRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsTimestreamwriteTableInvalidDatabaseNameRule) 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 !r.pattern.MatchString(val) {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[a-zA-Z0-9_.-]+$`),
63+
attribute.Expr,
64+
)
65+
}
66+
return nil
67+
})
68+
})
69+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
// AwsTimestreamwriteTableInvalidTableNameRule checks the pattern is valid
15+
type AwsTimestreamwriteTableInvalidTableNameRule struct {
16+
resourceType string
17+
attributeName string
18+
pattern *regexp.Regexp
19+
}
20+
21+
// NewAwsTimestreamwriteTableInvalidTableNameRule returns new rule with default attributes
22+
func NewAwsTimestreamwriteTableInvalidTableNameRule() *AwsTimestreamwriteTableInvalidTableNameRule {
23+
return &AwsTimestreamwriteTableInvalidTableNameRule{
24+
resourceType: "aws_timestreamwrite_table",
25+
attributeName: "table_name",
26+
pattern: regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`),
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsTimestreamwriteTableInvalidTableNameRule) Name() string {
32+
return "aws_timestreamwrite_table_invalid_table_name"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsTimestreamwriteTableInvalidTableNameRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsTimestreamwriteTableInvalidTableNameRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsTimestreamwriteTableInvalidTableNameRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsTimestreamwriteTableInvalidTableNameRule) 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 !r.pattern.MatchString(val) {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[a-zA-Z0-9_.-]+$`),
63+
attribute.Expr,
64+
)
65+
}
66+
return nil
67+
})
68+
})
69+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import = "aws-sdk-go/models/apis/timestream-write/2018-11-01/api-2.json"
2+
3+
mapping "aws_timestreamwrite_database" {
4+
database_name = ResourceCreateAPIName
5+
kms_key_id = StringValue2048
6+
tags = TagList
7+
}
8+
9+
mapping "aws_timestreamwrite_table" {
10+
database_name = ResourceCreateAPIName
11+
retention_properties = RetentionProperties
12+
table_name = ResourceCreateAPIName
13+
tags = TagList
14+
}

rules/models/provider.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,10 @@ var Rules = []tflint.Rule{
12551255
NewAwsSwfDomainInvalidDescriptionRule(),
12561256
NewAwsSwfDomainInvalidNameRule(),
12571257
NewAwsSwfDomainInvalidWorkflowExecutionRetentionPeriodInDaysRule(),
1258+
NewAwsTimestreamwriteDatabaseInvalidDatabaseNameRule(),
1259+
NewAwsTimestreamwriteDatabaseInvalidKmsKeyIDRule(),
1260+
NewAwsTimestreamwriteTableInvalidDatabaseNameRule(),
1261+
NewAwsTimestreamwriteTableInvalidTableNameRule(),
12581262
NewAwsTransferServerInvalidEndpointTypeRule(),
12591263
NewAwsTransferServerInvalidIdentityProviderTypeRule(),
12601264
NewAwsTransferServerInvalidInvocationRoleRule(),

0 commit comments

Comments
 (0)