I upgraded from 0.7.0 to 0.9.4 and my python escape hatch for some Azure array references (lbfe_id in snippet below) is no longer working. I’ve searched the existing issues and tried the Fn lookup from #1108], but get an unresolved-token error with that approach. Not sure if I just missed something in the docs about the changes between 0.7.0 and 0.9.4.
Appreciate any guidance. Thank you.
...
from imports.azurerm import Lb, LbFrontendIpConfiguration, PrivateLinkService
lbfe = LbFrontendIpConfiguration(name=_mkname(ns,"lbfe-001"),
private_ip_address_allocation="Dynamic", subnet_id=bsnet.id)
lb = Lb(self, "lb-001", name=_mkname(ns,"lb-001"), location=region_name,
resource_group_name=rg, frontend_ip_configuration=[lbfe], sku="Standard")
""" this worked in 0.7.0, errors with following with 0.9.4
"${${azurerm_lb.lb-001}.frontend_ip_configuration.0.id}"
│
│ Expected the start of an expression, but found an invalid expression token.
"""
lbfe_id =f"${{{lb.fqn}.frontend_ip_configuration.0.id}}"
""" from issue #1108, errors with:
jsii.errors.JSIIError: Expected array type, got "<unresolved-token>"
"""
lbfe_id = Fn.lookup(Fn.element(lb.frontend_ip_configuration, 0), "id")
pls = PrivateLinkService(self, "pls-001", location=region_name,
load_balancer_frontend_ip_configuration_ids=[lbfe_id],...
I think your first approach (using string interpolation) was pretty close. If rather than putting lbfe_id into a list you instead use Token.as_list(lbfe_id) when passing to pls, it may work correctly. May also be able to do something similar when using the override.
Thanks @jsteinich , the as_list is accepted but I get the same invalid expression error. Appears the string interpolation for fqn post 0.9.0 changed where when you append resources you get this “double interpolation”.