Thread
#python
    b

    brainy-window-77332

    7 months ago
    I need to capture the ip address associated with a network interface so I can build a configuration file that is stored in an s3 bucket. However using Pulumi.Output just gives me an Output object, i've tried using apply, concat and from_input methods but can't seem to get the actual ip address.
    Output.all(net_interface.id).apply(lambda l: f"{l[0]}")
    works fine when used on the right hand side of a parameter assignment in the instance creation but not in a function that is called as the right hand side of the content parameter when creating the bucket object.
    p

    prehistoric-activity-61023

    7 months ago
    can you paste a larger code snippet here?
    b

    brainy-window-77332

    7 months ago
    having created the network interfaces I do...
    network_interfaces = {}
    for (group_name, group_config, role_name, role_info) in process_nodes(cfg):
    for index, network_interface in enumerate(role_info["node_list"]):
    network_interfaces[f"{cfg.stack}-{group_name}-{role_name}-{index}"] = network_interface
    config = get_full_config(cfg)
    ghe_ha_config_bucket_object = aws.s3.BucketObject(
    "ghe-ha-config-bucket-object",
    bucket=config_bucket.id,
    content=Output.from_input(network_interfaces).apply(update_config(config, network_interfaces)),
    opts=pulumi.ResourceOptions(depends_on=network_interfaces.values()),
    )
    def update_config(config: str, network_interfaces):
    for name, network_interface in network_interfaces.items():
    value = network_interface.private_ips[0]
    config = config.replace(f"{name}-ipv4_address", value, 1)
    print(f"{get_caller()} - config: {config}")
    To update the configuration data replacing <name>-ipv4_address with the private ip address of the correct network interface