Terraform fetches the wrong Dynamic Table definition when Dynamic Tables with the same name exist in multiple databases or schemas #2173
Labels
bug
Used to mark issues with provider's incorrect behavior
Provider Version
0.75.0
Terraform Version
v1.4.4
Describe the bug
Steps to reproduce:
A_TEST
andB_TEST
.A_TEST
, manually create a dynamic table calledTEST_DT
B_TEST
schema also calledTEST_DT
.terraform apply
. This should create a dynamic table inB_TEST
calledTEST_DT
.terraform plan
. Observe that both the schema and query text have changes.Expected behavior
In step 5 above, there should be no change.
Code samples and commands
Anonymized example of the resource definition:
Anonymized example of the Terraform plan:
In the query logs, we can see that Terraform is running the following query during the plan:
This suggests that when there are multiple dynamic tables with the same name in the same account, Terraform will match the first one that shows up, instead of the one in the targeted database/schema.
Additional context
It turns out running
terraform apply
despite the changes is safe, because the update is applied to the correct database and schema. However, there are multiple issues with the incorrect targeting duringterraform plan
:SHOW DYNAMIC TABLES LIKE '<name>'
has poor performance when searching across a large number of databases and schemas. (We are attempting to manage dozens of dynamic tables and eachSHOW
command takes 3-4 minutes (and these queries appear to not use the cache). In contrast,SHOW DYNAMIC TABLES LIKE '<name>' IN <database>.<schema>
takes a few seconds.)The text was updated successfully, but these errors were encountered: