Hi all, I am struggling to both use the output val...
# general
f
Hi all, I am struggling to both use the output value, create a resource that uses it and return the resource. Here is what I am trying to do. I have a floating ip resource, I need to use the address of this FIP and add it as a metadata to my compute intance. To achieve that I would use fip.apply() and inside the lambda function I would create the instance. But I also need to return the created resource, and afaiu you can not return the resource from the apply function, as it is converted to the output type. How would one achieve that?
t
Iiirc you can often assign outputs to other properties directly. If you can't can you just create that one value with the apply function instead of the entire resource?
f
you can assign outputs to other inputs but in my case I need to get the output value (fip.address) and assign it to a variable that is not the input (a plain dict/map)
ok, this helped https://www.pulumi.com/docs/iac/concepts/inputs-outputs/apply/#outputs-and-json
Copy code
fip_addr = fip.address.apply(lambda addr: addr)
    ansible_host_vars = pulumi.Output.json_dumps(
        {
            "fip": fip_addr,
        }
    )
t
Oh great
I was just about to start digging
Good luck!