Skip to content

Commit ae6ef7a

Browse files
authored
adds destination_prefix_list_id in aws_route resource type (#46)
* adds destination_prefix_list_id in aws_route resource type * fix the test case
1 parent 316dc3c commit ae6ef7a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pkg/convertor.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ func computeResourceID(resource parser.TerraformResource) string {
100100
case "aws_cloudwatch_log_stream":
101101
return fmt.Sprintf("%s:%s", v("log_group_name"), v("name"))
102102
case "aws_route":
103-
if resource.AttributeValues["destination_cidr_block"] != "" {
103+
if resource.AttributeValues["destination_prefix_list_id"] != "" {
104+
return fmt.Sprintf("%s_%s", v("route_table_id"), v("destination_prefix_list_id"))
105+
} else if resource.AttributeValues["destination_cidr_block"] != "" {
104106
return fmt.Sprintf("%s_%s", v("route_table_id"), v("destination_cidr_block"))
105107
} else {
106108
return fmt.Sprintf("%s_%s", v("route_table_id"), v("destination_ipv6_cidr_block"))

pkg/convertor_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,32 @@ func Test_ComputeTerraformImportForResource(t *testing.T) {
480480
SupportsImport: true,
481481
},
482482
},
483+
{
484+
name: "For aws_route_with_destination_prefix_list_id",
485+
terraformResource: parser.TerraformResource{
486+
Address: "aws_route.test",
487+
Type: "aws_route",
488+
AttributeValues: map[string]any{
489+
"route_table_id": "rtb-656C65616E6F72",
490+
"destination_prefix_list_id": "pl-12df45133",
491+
"destination_cidr_block": "",
492+
"destination_ipv6_cidr_block": "",
493+
},
494+
},
495+
expected: TerraformImport{
496+
ResourceAddress: "aws_route.test",
497+
ResourceID: "rtb-656C65616E6F72_pl-12df45133",
498+
SupportsImport: true,
499+
},
500+
},
483501
{
484502
name: "For aws_route_with_destination_cidr_block",
485503
terraformResource: parser.TerraformResource{
486504
Address: "aws_route.test",
487505
Type: "aws_route",
488506
AttributeValues: map[string]any{
489507
"route_table_id": "rtb-656C65616E6F72",
508+
"destination_prefix_list_id": "",
490509
"destination_cidr_block": "10.42.0.0/16",
491510
"destination_ipv6_cidr_block": "",
492511
},
@@ -504,6 +523,7 @@ func Test_ComputeTerraformImportForResource(t *testing.T) {
504523
Type: "aws_route",
505524
AttributeValues: map[string]any{
506525
"route_table_id": "rtb-656C65616E6F72",
526+
"destination_prefix_list_id": "",
507527
"destination_cidr_block": "",
508528
"destination_ipv6_cidr_block": "2620:0:2d0:200::8/1",
509529
},

0 commit comments

Comments
 (0)