Merge pull request #1502 from snyk/fix/aws_route_with_prefix_broken
fix: crash in deep mode on aws_routemain
commit
4c4a33326c
|
@ -20,6 +20,9 @@ func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInte
|
|||
if ipv6 := res.Attributes().GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" {
|
||||
attributes["destination_ipv6_cidr_block"] = *ipv6
|
||||
}
|
||||
if prefixes := res.Attributes().GetString("destination_prefix_list_id"); prefixes != nil && *prefixes != "" {
|
||||
attributes["destination_prefix_list_id"] = *prefixes
|
||||
}
|
||||
return attributes
|
||||
})
|
||||
resourceSchemaRepository.SetNormalizeFunc(AwsRouteResourceType, func(res *resource.Resource) {
|
||||
|
@ -30,6 +33,7 @@ func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInte
|
|||
val.DeleteIfDefault("local_gateway_id")
|
||||
val.DeleteIfDefault("destination_cidr_block")
|
||||
val.DeleteIfDefault("destination_ipv6_cidr_block")
|
||||
val.DeleteIfDefault("destination_prefix_list_id")
|
||||
val.DeleteIfDefault("egress_only_gateway_id")
|
||||
val.DeleteIfDefault("nat_gateway_id")
|
||||
val.DeleteIfDefault("instance_id")
|
||||
|
|
|
@ -34,3 +34,31 @@ func TestAcc_Aws_Route(t *testing.T) {
|
|||
},
|
||||
})
|
||||
}
|
||||
|
||||
// Splitted that case because it required a lot of unrelated resources
|
||||
func TestAcc_Aws_Route_With_PrefixListId(t *testing.T) {
|
||||
acceptance.Run(t, acceptance.AccTestCase{
|
||||
TerraformVersion: "0.15.5",
|
||||
Paths: []string{"./testdata/acc/aws_route_with_prefix_list_id"},
|
||||
Args: []string{"scan", "--deep"},
|
||||
RetryDestroy: acceptance.RetryConfig{
|
||||
Attempts: 3,
|
||||
Delay: 5 * time.Second,
|
||||
},
|
||||
Checks: []acceptance.AccCheck{
|
||||
{
|
||||
Env: map[string]string{
|
||||
"AWS_REGION": "us-east-1",
|
||||
},
|
||||
ShouldRetry: acceptance.LinearBackoff(10 * time.Minute),
|
||||
Check: func(result *test.ScanResult, stdout string, err error) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result.AssertInfrastructureIsInSync()
|
||||
result.AssertManagedCount(1)
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
*
|
||||
!aws_route
|
||||
|
21
pkg/resource/aws/testdata/acc/aws_route_with_prefix_list_id/.terraform.lock.hcl
vendored
Normal file
21
pkg/resource/aws/testdata/acc/aws_route_with_prefix_list_id/.terraform.lock.hcl
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/hashicorp/aws" {
|
||||
version = "3.75.1"
|
||||
constraints = "3.75.1"
|
||||
hashes = [
|
||||
"h1:++H0a4igODgreQL3SJuRz71JZkC69rl41R8xLYM894o=",
|
||||
"zh:11c2ee541ca1da923356c9225575ba294523d7b6af82d6171c912470ef0f90cd",
|
||||
"zh:19fe975993664252b4a2ff1079546f2b186b01d1a025a94a4f15c37e023806c5",
|
||||
"zh:442e7fc145b2debebe9279b283d07f5f736dc1776c2e5b1702728a6eb03789d0",
|
||||
"zh:7a77991b204ae2c16ac29a32226135d5fdbda40c8dafa77c5adf5439a346be77",
|
||||
"zh:89a257933181c15293c15a858fbfe7252129cc57cc2ec05b6c0b595d1bfe9d38",
|
||||
"zh:b1813ea5b6b0fd88ea85b1b21b8e4119566d1bc34feca297b4fb39d0536893cb",
|
||||
"zh:c519f3292ae431bd2381f88a95bd37c52f7a56d91feef88511e929344c180549",
|
||||
"zh:d3dbe88b661c073c174f04f73adc2720372143bdfa12f4fe8f411332e64662cf",
|
||||
"zh:e92a27e3c7295b031b5d62dd9428966c96e3157fc768b3d848a9ac60d1661c8e",
|
||||
"zh:ecd664c0d664fcf2d8a89a01462cb00bcae37da200305aef2de1b8fe185c9cd8",
|
||||
"zh:ed6ce1f9fa96aa28dd65842f852abed25f919d20b5cf53d26cec5b3f4d845725",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
aws = "3.75.1"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_vpc" "example" {
|
||||
cidr_block = "10.1.0.0/16"
|
||||
}
|
||||
|
||||
resource "aws_ec2_managed_prefix_list" "example" {
|
||||
name = "example"
|
||||
address_family = "IPv4"
|
||||
max_entries = 5
|
||||
}
|
||||
|
||||
resource "aws_route_table" "example" {
|
||||
vpc_id = aws_vpc.example.id
|
||||
}
|
||||
|
||||
resource "aws_subnet" "example" {
|
||||
vpc_id = aws_vpc.example.id
|
||||
cidr_block = "10.1.1.0/24"
|
||||
}
|
||||
|
||||
resource "aws_nat_gateway" "example" {
|
||||
connectivity_type = "private"
|
||||
subnet_id = aws_subnet.example.id
|
||||
}
|
||||
|
||||
resource "aws_route" "r" {
|
||||
route_table_id = aws_route_table.example.id
|
||||
nat_gateway_id = aws_nat_gateway.example.id
|
||||
destination_prefix_list_id = aws_ec2_managed_prefix_list.example.id
|
||||
}
|
Loading…
Reference in New Issue