Skip to content

Commit

Permalink
mapping aws_apigatewayv2 (#222)
Browse files Browse the repository at this point in the history
* mapping aws_apigatewayv2

* go generate
  • Loading branch information
PatMyron authored Dec 23, 2021
1 parent 989b9d7 commit 8a4d4e6
Show file tree
Hide file tree
Showing 11 changed files with 752 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ These rules enforce best practices and naming conventions:
|aws_api_gateway_method_response_invalid_status_code||
|aws_api_gateway_rest_api_invalid_api_key_source||
|aws_api_gateway_stage_invalid_cache_cluster_size||
|aws_apigatewayv2_api_invalid_protocol_type||
|aws_apigatewayv2_authorizer_invalid_authorizer_type||
|aws_apigatewayv2_integration_invalid_connection_type||
|aws_apigatewayv2_integration_invalid_content_handling_strategy||
|aws_apigatewayv2_integration_invalid_integration_type||
|aws_apigatewayv2_integration_invalid_passthrough_behavior||
|aws_apigatewayv2_integration_response_invalid_content_handling_strategy||
|aws_apigatewayv2_route_invalid_authorization_type||
|aws_appautoscaling_policy_invalid_policy_type||
|aws_appautoscaling_policy_invalid_scalable_dimension||
|aws_appautoscaling_policy_invalid_service_namespace||
Expand Down
77 changes: 77 additions & 0 deletions rules/models/aws_apigatewayv2_api_invalid_protocol_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsApigatewayv2APIInvalidProtocolTypeRule checks the pattern is valid
type AwsApigatewayv2APIInvalidProtocolTypeRule struct {
resourceType string
attributeName string
enum []string
}

// NewAwsApigatewayv2APIInvalidProtocolTypeRule returns new rule with default attributes
func NewAwsApigatewayv2APIInvalidProtocolTypeRule() *AwsApigatewayv2APIInvalidProtocolTypeRule {
return &AwsApigatewayv2APIInvalidProtocolTypeRule{
resourceType: "aws_apigatewayv2_api",
attributeName: "protocol_type",
enum: []string{
"WEBSOCKET",
"HTTP",
},
}
}

// Name returns the rule name
func (r *AwsApigatewayv2APIInvalidProtocolTypeRule) Name() string {
return "aws_apigatewayv2_api_invalid_protocol_type"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsApigatewayv2APIInvalidProtocolTypeRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsApigatewayv2APIInvalidProtocolTypeRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsApigatewayv2APIInvalidProtocolTypeRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsApigatewayv2APIInvalidProtocolTypeRule) 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 {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`"%s" is an invalid value as protocol_type`, truncateLongMessage(val)),
attribute.Expr,
)
}
return nil
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule checks the pattern is valid
type AwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule struct {
resourceType string
attributeName string
enum []string
}

// NewAwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule returns new rule with default attributes
func NewAwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule() *AwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule {
return &AwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule{
resourceType: "aws_apigatewayv2_authorizer",
attributeName: "authorizer_type",
enum: []string{
"REQUEST",
"JWT",
},
}
}

// Name returns the rule name
func (r *AwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule) Name() string {
return "aws_apigatewayv2_authorizer_invalid_authorizer_type"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsApigatewayv2AuthorizerInvalidAuthorizerTypeRule) 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 {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`"%s" is an invalid value as authorizer_type`, truncateLongMessage(val)),
attribute.Expr,
)
}
return nil
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsApigatewayv2IntegrationInvalidConnectionTypeRule checks the pattern is valid
type AwsApigatewayv2IntegrationInvalidConnectionTypeRule struct {
resourceType string
attributeName string
enum []string
}

// NewAwsApigatewayv2IntegrationInvalidConnectionTypeRule returns new rule with default attributes
func NewAwsApigatewayv2IntegrationInvalidConnectionTypeRule() *AwsApigatewayv2IntegrationInvalidConnectionTypeRule {
return &AwsApigatewayv2IntegrationInvalidConnectionTypeRule{
resourceType: "aws_apigatewayv2_integration",
attributeName: "connection_type",
enum: []string{
"INTERNET",
"VPC_LINK",
},
}
}

// Name returns the rule name
func (r *AwsApigatewayv2IntegrationInvalidConnectionTypeRule) Name() string {
return "aws_apigatewayv2_integration_invalid_connection_type"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsApigatewayv2IntegrationInvalidConnectionTypeRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsApigatewayv2IntegrationInvalidConnectionTypeRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsApigatewayv2IntegrationInvalidConnectionTypeRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsApigatewayv2IntegrationInvalidConnectionTypeRule) 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 {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`"%s" is an invalid value as connection_type`, truncateLongMessage(val)),
attribute.Expr,
)
}
return nil
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule checks the pattern is valid
type AwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule struct {
resourceType string
attributeName string
enum []string
}

// NewAwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule returns new rule with default attributes
func NewAwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule() *AwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule {
return &AwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule{
resourceType: "aws_apigatewayv2_integration",
attributeName: "content_handling_strategy",
enum: []string{
"CONVERT_TO_BINARY",
"CONVERT_TO_TEXT",
},
}
}

// Name returns the rule name
func (r *AwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule) Name() string {
return "aws_apigatewayv2_integration_invalid_content_handling_strategy"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsApigatewayv2IntegrationInvalidContentHandlingStrategyRule) 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 {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`"%s" is an invalid value as content_handling_strategy`, truncateLongMessage(val)),
attribute.Expr,
)
}
return nil
})
})
}
Loading

0 comments on commit 8a4d4e6

Please sign in to comment.