且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Terraform:从资源内的数组中过滤对象

更新时间:2023-11-30 22:49:58

根据评论.

问题是由于条件 user.email == "${local.users_with_appId[count.index].userName}@example.com" 不满足造成的.因此,element 由于试图从 empty list in 中提取元素而出错:

The issue was caused by condition user.email == "${local.users_with_appId[count.index].userName}@example.com" not being satisfied. Consequently, element was erroring out due to trying to extract an element form an empty list in:

element([for user in okta_user.users: user if user.email == "${local.users_with_appId[count.index].userName}@example.com"], 0).id

解决方案是使用

element([for user in okta_user.users: user if "${user.email}" == "${local.users_with_app_id[count.index].userName}@example.com"], 0).id