https://pulumi.com logo
Title
l

little-orange-65618

04/28/2021, 7:16 PM
Attempting to use a ManagedIdentity.principalID as the string input for a KeyVault access policy but getting the error
<pulumi.output.Output object> has type Output, but expected one of: bytes, unicode
. I've tried with and without .apply lambda's (
self.principal_id = self.identity.principal_id.apply(lambda v: v or "<preview>")
) but it aways errors.
s

sparse-park-68967

04/28/2021, 10:03 PM
what field in the access policy are you setting? AccessPolicy constructor will take inputs so the direct assignment should work. If the destination needs a string then assigning it an apply won’t work. You will have to enclose the assignment inside the apply. i.e.
self.identity.principal_id.apply(lambda v: AccessPolicy(…: v))
l

little-orange-65618

04/28/2021, 10:49 PM
The line where I'm setting it is (part of creating a list of policies, it's not the only one):
access_policies = [  
...,
azure.keyvault.AccessPolicyEntryArgs(object_id=storage_account_id,tenant_id=tenant_id,permissions=azure.keyvault.PermissionsArgs(
               keys=DEFAULT_SA_KEY_PERMISSIONS)
            )
]

self.akv = azure.keyvault.Vault(resource_name=name,
                                            resource_group_name=resource_group_name,
                                            location=location,
                                            properties=azure.keyvault.VaultPropertiesArgs(                                             ...                                         access_policies=access_policies,...)
The variable in question is "storage_account_id" which is ultimately created (and then passed on) here:
self.identity = azure.managedidentity.UserAssignedIdentity(resource_name=id_name,
                                                                   resource_name_=id_name,
                                                                   location=location,
                                                                   resource_group_name=rg_name,
                                                                   opts=opts,
                                                                   tags=tags)

        self.principal_id = self.identity.principal_id.apply(lambda v: v or "<preview>")
@sparse-park-68967 can you explain how I'd use the .apply inside the definition line for a access_policy definition?