Json loaded Dashboard does not show data in panel until edit each panel and apply changes

Dear Community,
Hope you all are doing good.
Currently I am facing some strange issue. we are moving towards Dashboard as code with the help of grafanalib (python) and Terraform.
As a poc, I am replicating the existing dashboard to see the results of this move towards Dashboard as Code.

I am having a dashboard with three variables and these variables should pass-on towards targets of each panel.

for example:

template1 = Template(name="datasource", query='cloudwatch', default=None, dataSource=None,
                     label='Datasource', allValue=None, refresh=1, type='datasource', hide=0)
template2 = Template(name="region", query='regions()', default="eu-central-1", dataSource={
                     "uid": "$datasource"}, label='Region', allValue=None, refresh=1, type='query', hide=0)
template3 = Template(name="dbinstanceidentifier", query='dimension_values($region, AWS/RDS, CPUUtilization, DBInstanceIdentifier)',
                     default=None, dataSource={"uid": "$datasource"}, label='DBInstanceIdentifier', allValue=None, refresh=1, type='query', hide=0)

I have three panels, each of type Graph (old) with cloudwatchmetrics as a target to monitor different metrics like CPU utilisation, database connections, freeable mem, etc…

I see dashboard json is properly generated by the grafanalib and deployed properly by using Terraform in required Grafana folder.

When I open the dashboard I see all panels are empty/not showing any data until I click on edit each panel and then immediately click on apply.

I am not what could be the issue here, I see for every new deployment of Terraform changes these panels are getting the same and need to edit and apply again. I see this will be a blocker going forward if we add more and more panels and dashboards.

please share your exp, if any of you faced such situation already.

We are seeing the same issue - need to disable / enable a dashboard panel for the data to be rendered - I’m wondering if there is a way to do this automatically as we currently load the dashboard from a json file in an automated deployment.

Update - on further investigation this was caused by the datasource naming. By making this a variable which all panels used the panels are now populated as expected