How to ignore resources dynamically created by Elastic Beanstalk (i.e. outside of the Terraform workflow)?

AWS Elastic Beanstalk creates and destroys many resources automatically, outside of the Terraform workflow (not by humans), such as:

  • aws_autoscaling_group
  • aws_alb_target_group
  • aws_alb_listener

How can Terraform be told to ignore these resources completely?

Note: The lifecycle directive inside a resource body can ignore specific properties of a resource, but it doesn’t seem able to ignore entire resources.

Terraform doesn’t interact with resources which are not managed by the configuration, so there should be no reason for these resources to affect the config. In other words, if there is was never a corresponding resource block in the configuration, as far as Terraform is concerned that resource does not exist, so there is no other way to ignore such a resource.

If these extra resources are somehow affecting other resources which you do manage through the configuration, then that is something specific to the provider and service you are using, and avoiding the issue will be case dependent.