cycloidio / terracognita

Reads from existing public and private cloud providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration
MIT License
2.2k stars 164 forks source link

-e --exclude does not exclude resources #398

Open MajorRockStar opened 1 year ago

MajorRockStar commented 1 year ago

General information: Using -e or --exclude does not exclude the resources. I have tried with individual resources and multiple resources.

Describe the bug:

Running the following command but the resources are still included.

terracognita aws --aws-access-key ${AWS_ACCESS_KEY_ID} --aws-default-region eu-west-2 --aws-secret-access-key ${AWS_SECRET_ACCESS_KEY} --tfstate services/services.tfstate --hcl services --exclude aws_lb -e aws_lb_cookie_stickiness_policy -e aws_lb_listener -e aws_lb_listener_certificate -e aws_lb_listener_rule -e aws_lb_target_group -e aws_lb_target_group_attachment

The command then errors as follows.

Starting Terracognita with version v0.8.4 Importing with filters: Tags: [], Include: [], Exclude: [aws_lb aws_lb_cookie_stickiness_policy aws_lb_listener aws_lb_listener_certificate aws_lb_listener_rule aws_lb_target_group aws_lb_target_group_attachment], Targets: [], Importing aws_instance [25/25] Done! Importing aws_alb [2/2] Done! Importing aws_alb_listener [2/2] Done! Error: could not import from aws: error while reading from resource "aws_alb_listener_certificate": ValidationError: This operation does not support Gateway Load Balancer Listeners. status code: 400, request id: 19bba2e3-bced-4818-9e19-49afcc7da3b6

Log message

Error: could not import from aws: error while reading from resource "aws_alb_listener_certificate": ValidationError: This operation does not support Gateway Load Balancer Listeners. status code: 400, request id: 19bba2e3-bced-4818-9e19-49afcc7da3b6

Additional context

xescugc commented 1 year ago

Ok so apart from the actual error

Error: could not import from aws: error while reading from resource "aws_alb_listener_certificate": ValidationError: This operation does not support Gateway Load Balancer Listeners.
status code: 400, request id: 19bba2e3-bced-4818-9e19-49afcc7da3b6

I'm guessing that you say it does not exclude because you excluded lb and it imported alb? Ok this is a bug and i'll fix it, the issues is that lb and alb are aliases but when excluding we are not checking that, we have the information of some of the aliases so we can remap it :).