Hi all, I am using the azure.compute.Extension an...
# python
v
Hi all, I am using the azure.compute.Extension and am having an issue referencing another resource. The resource takes a settings parameter that is a string. Within this I am trying to reference another resource, but this is failing:
Copy code
user_assigned_identity = azure.authorization.UserAssignedIdentity(
    f"{stack_name}-identity",
    name=f"{stack_name}-identity",
    location=resource_group.location,
    resource_group_name=resource_group.name,
    tags=tags)


azure.compute.Extension(
    "KeyVaultExtension",
    name="KeyVaultExtension",
    virtual_machine_id=vm.id,
    publisher="Microsoft.Azure.KeyVault",
    type="KeyVaultForLinux",
    type_handler_version="2.0",
    settings=json.dumps(
        {
            "secretsManagementSettings": {
                "pollingIntervalInS": "30",
                "certificateStoreName": "MY",
                "linkOnRenewal": False,
                "certificateStoreLocation": "/var/lib/waagent/Microsoft.Azure.KeyVault",
                "observedCertificates": [
                    f"{kv_uri}/secrets/certificate",
                    f"{kv_uri}/secrets/certificate"
                ]
            },
            "authenticationSettings": {
                "msiEndpoint": "<http://169.254.169.254/metadata/identity>",
                "msiClientId": user_assigned_identity.client_id
            }
        }
    ),
    opts=ResourceOptions(
        depends_on=[vm]
    )
)
It is failing because the the pulumi object is not serializeable. How do I reference the other resource in this case? I can use get_user_assigned_identity but it does not exist yet when I preview.
Is there a way for azure_native.managedidentity.get_user_assigned_identity (or any get call) to return empty if not exists or some work around?
I guess the question is, how do I reference a resource attribute before it has been created?
ChatGPT helped me sort it out. lol.