Skip to content

9 files changed

+522
-0
lines changed

docs/rules/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,12 @@ These rules enforce best practices and naming conventions:
378378
|aws_codepipeline_webhook_invalid_name||
379379
|aws_codepipeline_webhook_invalid_target_action||
380380
|aws_codepipeline_webhook_invalid_target_pipeline||
381+
|aws_codestarconnections_connection_invalid_host_arn||
382+
|aws_codestarconnections_connection_invalid_name||
383+
|aws_codestarconnections_connection_invalid_provider_type||
384+
|aws_codestarconnections_host_invalid_name||
385+
|aws_codestarconnections_host_invalid_provider_endpoint||
386+
|aws_codestarconnections_host_invalid_provider_type||
381387
|aws_cognito_identity_pool_invalid_developer_provider_name||
382388
|aws_cognito_identity_pool_invalid_identity_pool_name||
383389
|aws_cognito_identity_pool_roles_attachment_invalid_identity_pool_id||
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
// AwsCodestarconnectionsConnectionInvalidHostArnRule checks the pattern is valid
15+
type AwsCodestarconnectionsConnectionInvalidHostArnRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
pattern *regexp.Regexp
20+
}
21+
22+
// NewAwsCodestarconnectionsConnectionInvalidHostArnRule returns new rule with default attributes
23+
func NewAwsCodestarconnectionsConnectionInvalidHostArnRule() *AwsCodestarconnectionsConnectionInvalidHostArnRule {
24+
return &AwsCodestarconnectionsConnectionInvalidHostArnRule{
25+
resourceType: "aws_codestarconnections_connection",
26+
attributeName: "host_arn",
27+
max: 256,
28+
pattern: regexp.MustCompile(`^arn:aws(-[\w]+)*:codestar-connections:.+:[0-9]{12}:host\/.+$`),
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) Name() string {
34+
return "aws_codestarconnections_connection_invalid_host_arn"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) 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+
if len(val) > r.max {
62+
runner.EmitIssueOnExpr(
63+
r,
64+
"host_arn must be 256 characters or less",
65+
attribute.Expr,
66+
)
67+
}
68+
if !r.pattern.MatchString(val) {
69+
runner.EmitIssueOnExpr(
70+
r,
71+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^arn:aws(-[\w]+)*:codestar-connections:.+:[0-9]{12}:host\/.+$`),
72+
attribute.Expr,
73+
)
74+
}
75+
return nil
76+
})
77+
})
78+
}
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+
// AwsCodestarconnectionsConnectionInvalidNameRule checks the pattern is valid
15+
type AwsCodestarconnectionsConnectionInvalidNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsCodestarconnectionsConnectionInvalidNameRule returns new rule with default attributes
24+
func NewAwsCodestarconnectionsConnectionInvalidNameRule() *AwsCodestarconnectionsConnectionInvalidNameRule {
25+
return &AwsCodestarconnectionsConnectionInvalidNameRule{
26+
resourceType: "aws_codestarconnections_connection",
27+
attributeName: "name",
28+
max: 32,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^[\s\S]*$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) Name() string {
36+
return "aws_codestarconnections_connection_invalid_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) 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+
"name must be 32 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"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), `^[\s\S]*$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
// AwsCodestarconnectionsConnectionInvalidProviderTypeRule checks the pattern is valid
14+
type AwsCodestarconnectionsConnectionInvalidProviderTypeRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsCodestarconnectionsConnectionInvalidProviderTypeRule returns new rule with default attributes
21+
func NewAwsCodestarconnectionsConnectionInvalidProviderTypeRule() *AwsCodestarconnectionsConnectionInvalidProviderTypeRule {
22+
return &AwsCodestarconnectionsConnectionInvalidProviderTypeRule{
23+
resourceType: "aws_codestarconnections_connection",
24+
attributeName: "provider_type",
25+
enum: []string{
26+
"Bitbucket",
27+
"GitHub",
28+
"GitHubEnterpriseServer",
29+
},
30+
}
31+
}
32+
33+
// Name returns the rule name
34+
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) Name() string {
35+
return "aws_codestarconnections_connection_invalid_provider_type"
36+
}
37+
38+
// Enabled returns whether the rule is enabled by default
39+
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) Enabled() bool {
40+
return true
41+
}
42+
43+
// Severity returns the rule severity
44+
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) Severity() string {
45+
return tflint.ERROR
46+
}
47+
48+
// Link returns the rule reference link
49+
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) Link() string {
50+
return ""
51+
}
52+
53+
// Check checks the pattern is valid
54+
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) 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+
found := false
63+
for _, item := range r.enum {
64+
if item == val {
65+
found = true
66+
}
67+
}
68+
if !found {
69+
runner.EmitIssueOnExpr(
70+
r,
71+
fmt.Sprintf(`"%s" is an invalid value as provider_type`, truncateLongMessage(val)),
72+
attribute.Expr,
73+
)
74+
}
75+
return nil
76+
})
77+
})
78+
}
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+
// AwsCodestarconnectionsHostInvalidNameRule checks the pattern is valid
15+
type AwsCodestarconnectionsHostInvalidNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsCodestarconnectionsHostInvalidNameRule returns new rule with default attributes
24+
func NewAwsCodestarconnectionsHostInvalidNameRule() *AwsCodestarconnectionsHostInvalidNameRule {
25+
return &AwsCodestarconnectionsHostInvalidNameRule{
26+
resourceType: "aws_codestarconnections_host",
27+
attributeName: "name",
28+
max: 64,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^.*$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsCodestarconnectionsHostInvalidNameRule) Name() string {
36+
return "aws_codestarconnections_host_invalid_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsCodestarconnectionsHostInvalidNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsCodestarconnectionsHostInvalidNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsCodestarconnectionsHostInvalidNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsCodestarconnectionsHostInvalidNameRule) 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+
"name must be 64 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"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), `^.*$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}

0 commit comments

Comments
 (0)