Terraform plan failing while assigning target_id for Azure traffic manager

Hi, I am trying to create an appservice and traffic manger in the same configuration file by calling independent modules (appservice and atm). We have appservice id outputted from the module as below since we are using for_each for appservice resource

output “appserviceid” {
value = [for i in azurerm_app_service.appservice : i.id]

And my config file looks like

module appservice_test {
source = ./modules/appserver
module trafficmanager {
source = ./modules/traffcimanager
target_resource_id = module.appservice_test.appserviceid.0

When I try to run this locally from my machine, it works just fine but when I run from a CI/CD pipeline, terraform plan fails with an empty tuple error. Only difference between local and CI/CD is CI/CD runs terraform in a docker container which uses 0.12.13 and I am using 0.12.26 on my local. I’ve also tried using 0.12.13 in my local and plan ran with no issues.

module.appservice_test.appservice_id is empty tuple
The given key does not identify an element in this collection value

Has anyone faced a similar issue or think of anything that I am missing here?