a

    able-thailand-87943

    3 months ago
    Hello fellow Pulumi users, I have a rather weird problem, and probably my lack of experience with working with outputs. I am fetching a KeyVault from another stack using StackReference like this:
    source_stack_name = "foobar"
    stack_ref = pulumi.StackReference(f"{source_stack_name}")
    foobar_resource_group_name = foobar_resource_group.apply(lambda x : x["name"])
    foobar_keyvault = stack_ref.get_output(f"{source_stack_name}-kv")
    foobar_keyvault_name = foobar_keyvault.apply(lambda x : x['name'])
    foobar_keyvault_id = foobar_keyvault.apply(lambda x : x['id'])
    The name and ID are not outputs, and I can easily reference them to other objects which I can create like this:
    """ Create Managed Identity """
    barfoo_api_managed_identity = azure_native.managedidentity.UserAssignedIdentity(
        f"{name}-id",
        resource_group_name=foobar_resource_group_name,
    )
    However, I cannot seem to refer the Keyvault Name into Properties of other resources. such as:
    barfoo_app_settings = azure_native.web.WebAppApplicationSettings(
        f"{name}-app-settings",
        name=barfoo_api_app.name,
        properties={
            "QUICKFOXPASS": f"@Microsoft.KeyVault(VaultName={foobar_keyvault_name};SecretName=QUICKFOX-PASSWORD)"
        },
        resource_group_name=foobar_resource_group_name,
    )
    Any idea how I can fix this? The standard way I have used so far was the apply method, but in this case, it does not seem to help 😞
    Turns out that I need to do an apply on that output to be usable:
    foobar_keyvault_name = stack_ref.require_output(f"{source_stack_name}-kv-name")
    
    barfoo_app_settings = azure_native.web.WebAppApplicationSettings(
        f"{name}-app-settings",
        name=barfoo_api_app.name,
        properties={
            "QUICKFOXPASS": foobar_keyvault_name.apply(lambda x :f"@Microsoft.KeyVault(VaultName={x};SecretName=QUICKFOX-PASSWORD)"
        },
        resource_group_name=foobar_resource_group_name,
    )