I'm trying to get to this result (two factors are important: exact indentation, as it outputs YAML, and no comma after last IP):
# ... some stuff ...
NotIpAddress:
"aws:SourceIp": [
"100.200.300.400",
"110.200.300.400",
"120.200.300.400"
]
# ... some more stuff ...
With the following ejs code:
NotIpAddress:
"aws:SourceIp": [
"<%- permittedIPAddresses.join('",\n"') %>"
]
But the result is (incorrect indentation of last two IPs):
NotIpAddress:
"aws:SourceIp": [
"100.200.300.400",
"110.200.300.400",
"120.200.300.400"
]
So I tried this:
NotIpAddress:
"aws:SourceIp": [
<%_ for(const i in permittedIPAddresses){ _%>
"<%= permittedIPAddresses[i].trim() %>",
<%_ } _%>
]
But that yielded this (last IP followed by comma):
NotIpAddress:
"aws:SourceIp": [
"100.200.300.400",
"110.200.300.400",
"120.200.300.400",
]
So I'm either giving up on correct indentation, or on correct join..
No way to keep indentation while also making proper join?