This message was deleted.
# general
s
This message was deleted.
l
That won't work, since that code runs at the time Pulumi is generating the declarative state, but the API_URL value isn't available until after the infrastructure is deployed.
Instead, you have to defer running that code until API_URL is available. It is available inside the call to
apply()
.
I don't know Python, can you make something like this work?
Copy code
config_map = ConfigMap(
        'nginx-config',
        metadata=ObjectMetaArgs(labels=labels),
        data={
          'default.conf': api_url.apply(lambda url:
            with open('./nginx.conf', 'r') as file:
              config = file.read()
              config = config.replace("{{API_URL}}", url))
              return config
        })
🙌 1
w
Thanks for the help!
l
Does the explanation / example make since? Is the difference in how apply() is being used understandable? Happy to answer more questions to clarify, this is a core concept that will make everything easier once you grok it.