Update:
The correct syntax is:
cidrList = [ for j in local.ipList:
length(regexall("/", j)) <= 0 ? "${j}/32" : j ]
but you are using double :
, instead of ?
and ‘:’.
Previous answer
Not sure what exactly are you trying to achieve, it seems to be that you are after something as follows:
cidrList = [ for j in local.ipList:
{"${j}/32" : j } if length(regexall("/", j)) <= 0 ]
which would give:
[
{
"103.77.234.74/32" = "103.77.234.74"
},
]
or
cidrList = [ for j in local.ipList:
"${j}/32" if length(regexall("/", j)) <= 0 ]
which gives:
[
"103.77.234.74/32",
]
CLICK HERE to find out more related problems solutions.