How to pass a list in getevn()

for exmaple

public_ip = get_env(“static_ip”, “[“”]”)

didn’t work ? how can I pass in a list of ip’s

Hi Buamod,

The canonical way to handle this is to use json for the environment variables, and then you can use the jsondecode function to convert the environment variable string to an HCL list.


public_ip = jsondecode(get_env(“static_ip”, “[“”]”))

Best regards,

1 Like

sorry @yoriy but it didn’t work …I tried it when pass a list of security groups but if failed

secGroup = get_env(“security groups”, "[“sg-123121, sg-1231231, sg-12312312]”)

It needs to be valid json for it to work. You’re missing a few quotes there. It should be:

secGroup = get_env("security groups", "[\"sg-123121\", \"sg-1231231\", \"sg-12312312\"]”