Remote state outputs used as variables for a module make terraform not seeing the resources created?


I’m currently using aws provider and using AWS Glue Catalog Database resources.

I’m trying to use the outputs of my resource link created to have some precondition validation.

In this specific case, i would like to avoid two resources link to have different name but pointing the exact same database/table/account_id.

Thus i used a data block terraform remote state to retrieve a list of the resources link created. I pass this list to my module to check this precondition validation.

However, when i do that, terraform doesn’t seem to understand and try to reapply the resource that i already created, and finally being blocked by my condition. (no two same resources link).

Am i doing something wrong ? The only part of the documentation that i found related to my problem seems this one :