generated from terraform-linters/tflint-ruleset-template
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_vault_lock_configuration https://github.com/aws/aws-sdk-go/blob/main/models/apis/backup/2018-11-15/api-2.json
- Loading branch information
Showing
6 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
rules/models/aws_backup_vault_lock_configuration_invalid_backup_vault_name.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"regexp" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsBackupVaultLockConfigurationInvalidBackupVaultNameRule checks the pattern is valid | ||
type AwsBackupVaultLockConfigurationInvalidBackupVaultNameRule struct { | ||
resourceType string | ||
attributeName string | ||
pattern *regexp.Regexp | ||
} | ||
|
||
// NewAwsBackupVaultLockConfigurationInvalidBackupVaultNameRule returns new rule with default attributes | ||
func NewAwsBackupVaultLockConfigurationInvalidBackupVaultNameRule() *AwsBackupVaultLockConfigurationInvalidBackupVaultNameRule { | ||
return &AwsBackupVaultLockConfigurationInvalidBackupVaultNameRule{ | ||
resourceType: "aws_backup_vault_lock_configuration", | ||
attributeName: "backup_vault_name", | ||
pattern: regexp.MustCompile(`^[a-zA-Z0-9\-\_]{2,50}$`), | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsBackupVaultLockConfigurationInvalidBackupVaultNameRule) Name() string { | ||
return "aws_backup_vault_lock_configuration_invalid_backup_vault_name" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsBackupVaultLockConfigurationInvalidBackupVaultNameRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsBackupVaultLockConfigurationInvalidBackupVaultNameRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsBackupVaultLockConfigurationInvalidBackupVaultNameRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsBackupVaultLockConfigurationInvalidBackupVaultNameRule) Check(runner tflint.Runner) error { | ||
log.Printf("[TRACE] Check `%s` rule", r.Name()) | ||
|
||
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { | ||
var val string | ||
err := runner.EvaluateExpr(attribute.Expr, &val, nil) | ||
|
||
return runner.EnsureNoError(err, func() error { | ||
if !r.pattern.MatchString(val) { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[a-zA-Z0-9\-\_]{2,50}$`), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
69 changes: 69 additions & 0 deletions
69
rules/models/aws_backup_vault_notifications_invalid_backup_vault_name.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"regexp" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsBackupVaultNotificationsInvalidBackupVaultNameRule checks the pattern is valid | ||
type AwsBackupVaultNotificationsInvalidBackupVaultNameRule struct { | ||
resourceType string | ||
attributeName string | ||
pattern *regexp.Regexp | ||
} | ||
|
||
// NewAwsBackupVaultNotificationsInvalidBackupVaultNameRule returns new rule with default attributes | ||
func NewAwsBackupVaultNotificationsInvalidBackupVaultNameRule() *AwsBackupVaultNotificationsInvalidBackupVaultNameRule { | ||
return &AwsBackupVaultNotificationsInvalidBackupVaultNameRule{ | ||
resourceType: "aws_backup_vault_notifications", | ||
attributeName: "backup_vault_name", | ||
pattern: regexp.MustCompile(`^[a-zA-Z0-9\-\_]{2,50}$`), | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsBackupVaultNotificationsInvalidBackupVaultNameRule) Name() string { | ||
return "aws_backup_vault_notifications_invalid_backup_vault_name" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsBackupVaultNotificationsInvalidBackupVaultNameRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsBackupVaultNotificationsInvalidBackupVaultNameRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsBackupVaultNotificationsInvalidBackupVaultNameRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsBackupVaultNotificationsInvalidBackupVaultNameRule) Check(runner tflint.Runner) error { | ||
log.Printf("[TRACE] Check `%s` rule", r.Name()) | ||
|
||
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { | ||
var val string | ||
err := runner.EvaluateExpr(attribute.Expr, &val, nil) | ||
|
||
return runner.EnsureNoError(err, func() error { | ||
if !r.pattern.MatchString(val) { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[a-zA-Z0-9\-\_]{2,50}$`), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
69 changes: 69 additions & 0 deletions
69
rules/models/aws_backup_vault_policy_invalid_backup_vault_name.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"regexp" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsBackupVaultPolicyInvalidBackupVaultNameRule checks the pattern is valid | ||
type AwsBackupVaultPolicyInvalidBackupVaultNameRule struct { | ||
resourceType string | ||
attributeName string | ||
pattern *regexp.Regexp | ||
} | ||
|
||
// NewAwsBackupVaultPolicyInvalidBackupVaultNameRule returns new rule with default attributes | ||
func NewAwsBackupVaultPolicyInvalidBackupVaultNameRule() *AwsBackupVaultPolicyInvalidBackupVaultNameRule { | ||
return &AwsBackupVaultPolicyInvalidBackupVaultNameRule{ | ||
resourceType: "aws_backup_vault_policy", | ||
attributeName: "backup_vault_name", | ||
pattern: regexp.MustCompile(`^[a-zA-Z0-9\-\_]{2,50}$`), | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsBackupVaultPolicyInvalidBackupVaultNameRule) Name() string { | ||
return "aws_backup_vault_policy_invalid_backup_vault_name" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsBackupVaultPolicyInvalidBackupVaultNameRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsBackupVaultPolicyInvalidBackupVaultNameRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsBackupVaultPolicyInvalidBackupVaultNameRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsBackupVaultPolicyInvalidBackupVaultNameRule) Check(runner tflint.Runner) error { | ||
log.Printf("[TRACE] Check `%s` rule", r.Name()) | ||
|
||
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { | ||
var val string | ||
err := runner.EvaluateExpr(attribute.Expr, &val, nil) | ||
|
||
return runner.EnsureNoError(err, func() error { | ||
if !r.pattern.MatchString(val) { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[a-zA-Z0-9\-\_]{2,50}$`), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters