# Unable to call/pass the value from list(objects) in the resource block

**URL:** <https://discuss.hashicorp.com/t/unable-to-call-pass-the-value-from-list-objects-in-the-resource-block/61148>\
**Category:** Terraform\
**Created:** [December 23, 2023, 11:00am UTC](https://discuss.hashicorp.com/t/unable-to-call-pass-the-value-from-list-objects-in-the-resource-block/61148 "2023-12-23T11:00:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjkishore1](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jjkishore1](https://discuss.hashicorp.com/u/jjkishore1)\
**Post date:** [December 23, 2023, 11:00am UTC](https://discuss.hashicorp.com/t/unable-to-call-pass-the-value-from-list-objects-in-the-resource-block/61148/1 "2023-12-23T11:00:48Z")

</div>

## Am trying to call the value from list(objects), am unable to do so, am assigning count.index when am using var.service\_account\_id, but am not sure if this is the problem, could some one please help.

## CSV data as below

```auto
name,example
test-0, one
test-1, two

```

* * *

## MODULE

```auto
resource "confluent_api_key" "schema_reg_api_key" {
  display_name = var.display_name
  description = "Kafka API Key that is owned by 'app-manager' service account"
  owner {
    **id = var.service_account_id[count.index]**
    api_version = var.api_version
    kind = var.kind
  }

  managed_resource {
    id = var.schema_registry_cluster_id
    api_version = var.schema_registry_api_version
    kind = var.schema_registry_kind

    environment {
      id = var.environment_id
    }
  }

  lifecycle {
    prevent_destroy = true
  }
}

variable "service_account_id" {
  description = "The Service Account ID of the owner that the API Key belongs to"
  type = list(object({
    name = string
    example = string
  }))
}

```

* * *

## MAIN.tf

```auto
locals {
  sa-test = csvdecode(file(".//projects/project-1/test.csv"))
  displayname = { for test in local.sa-test : test.name => test }
}

module "confluent_service_account" {
  for_each = { for test in local.sa-test : test.name => test }
  source = ".//modules/confluent_service_account"
  display_name = each.key.name
}

module "api_key" {
  for_each = { for test in local.sa-test : test.name => test }
  source = ".//modules/confluent_api_key"
  depends_on = [module.confluent_service_account]
  display_name = each.key.name
  **service_account_id = module.confluent_service_account.id**
}

```

* * *

## OUTPUT

```auto
│ Error: Invalid value for module argument
│ 
│ on main.tf line 25, in module "api_key":
│ 25: service_account_id = module.confluent_service_account.id
│ 
│ The given value is not suitable for child module variable
│ "service_account_id" defined at
│ modules/confluent_api_key/variables.tf:6,1-30: list of string required.
╵
╷
│ Error: Invalid value for module argument
│ 
│ on main.tf line 33, in module "schema_reg_api_key":
│ 33: service_account_id = module.confluent_service_account.id
│ 
│ The given value is not suitable for child module variable
│ "service_account_id" defined at modules/
│ confluent_schema_registry_api_key/variables.tf:6,1-30: list of string
│ required.

```
