Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws_route_not_specified_target] Add "vpc_endpoint_id" Route Target #989

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/rules/aws_route_not_specified_target.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource "aws_route" "foo" {
$ tflint
1 issue(s) found:

Error: The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, or vpc_peering_connection_id. (aws_route_not_specified_target)
Error: The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, vpc_peering_connection_id or vpc_endpoint_id. (aws_route_not_specified_target)

on template.tf line 1:
1: resource "aws_route" "foo" {
Expand Down
4 changes: 2 additions & 2 deletions integration/basic/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"severity": "error",
"link": "https://github.com/terraform-linters/tflint/blob/v0.21.0/docs/rules/aws_route_not_specified_target.md"
},
"message": "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, or vpc_peering_connection_id.",
"message": "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, vpc_peering_connection_id or vpc_endpoint_id.",
"range": {
"filename": "template.tf",
"start": {
Expand Down Expand Up @@ -66,7 +66,7 @@
"severity": "error",
"link": "https://github.com/terraform-linters/tflint/blob/v0.21.0/docs/rules/aws_route_not_specified_target.md"
},
"message": "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, or vpc_peering_connection_id.",
"message": "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, vpc_peering_connection_id or vpc_endpoint_id.",
"range": {
"filename": "template.tf",
"start": {
Expand Down
7 changes: 5 additions & 2 deletions rules/awsrules/aws_route_not_specified_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (r *AwsRouteNotSpecifiedTargetRule) Link() string {
}

// Check checks whether `gateway_id`, `egress_only_gateway_id`, `nat_gateway_id`, `instance_id`
// `vpc_peering_connection_id` or `network_interface_id` is defined in a resource
// `vpc_peering_connection_id`, `network_interface_id` or `vpc_endpoint_id` is defined in a resource
func (r *AwsRouteNotSpecifiedTargetRule) Check(runner *tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule for `%s` runner", r.Name(), runner.TFConfigPath())

Expand Down Expand Up @@ -68,6 +68,9 @@ func (r *AwsRouteNotSpecifiedTargetRule) Check(runner *tflint.Runner) error {
{
Name: "transit_gateway_id",
},
{
Name: "vpc_endpoint_id",
},
},
})
if diags.HasErrors() {
Expand All @@ -89,7 +92,7 @@ func (r *AwsRouteNotSpecifiedTargetRule) Check(runner *tflint.Runner) error {
if len(body.Attributes)-nullAttributes == 0 {
runner.EmitIssue(
r,
"The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, or vpc_peering_connection_id.",
"The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, vpc_peering_connection_id or vpc_endpoint_id.",
resource.DeclRange,
)
}
Expand Down
13 changes: 11 additions & 2 deletions rules/awsrules/aws_route_not_specified_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resource "aws_route" "foo" {
Expected: tflint.Issues{
{
Rule: NewAwsRouteNotSpecifiedTargetRule(),
Message: "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, or vpc_peering_connection_id.",
Message: "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, vpc_peering_connection_id or vpc_endpoint_id.",
Range: hcl.Range{
Filename: "resource.tf",
Start: hcl.Pos{Line: 2, Column: 1},
Expand Down Expand Up @@ -109,7 +109,7 @@ resource "aws_route" "foo" {
Expected: tflint.Issues{
{
Rule: NewAwsRouteNotSpecifiedTargetRule(),
Message: "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, or vpc_peering_connection_id.",
Message: "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, vpc_peering_connection_id or vpc_endpoint_id.",
Range: hcl.Range{
Filename: "resource.tf",
Start: hcl.Pos{Line: 7, Column: 1},
Expand All @@ -118,6 +118,15 @@ resource "aws_route" "foo" {
},
},
},
{
Name: "vpc_endpoint_id is specified",
Content: `
resource "aws_route" "foo" {
route_table_id = "rtb-1234abcd"
vpc_endpoint_id = "vpce-12345678abcdefgh"
}`,
Expected: tflint.Issues{},
},
}

rule := NewAwsRouteNotSpecifiedTargetRule()
Expand Down