I'm probably too tired to think straight at this p...
# azure
I'm probably too tired to think straight at this point - but now I've gotten to the AKS stage, and I decided that I really wanted to add diskEncryption through a diskEncryptionSet. So.. ugh.. it'll be easier to read the code rather than me explaining it:
Copy code
const diskKey = new azure.keyvault.Key("aks-des-key",{
        keyName: "aks-des-key",
        properties: {
            kty: "RSA"
        resourceGroupName: aksStack.parameters.name,
        vaultName: aksStack.keyVault.parameters.name
    const diskEncryption = new azure.compute.DiskEncryptionSet("aks-des", {
        resourceGroupName: aksStack.parameters.name,
        location: aksStack.parameters.location,
        activeKey: {
            keyUrl: diskKey.keyUriWithVersion
        diskEncryptionSetName: "aks-des",
        encryptionType: "EncryptionAtRestWithCustomerKey",
        identity: {
            type: "SystemAssigned"
So this is all fine - and in my AKS config I have `diskEncryptionSetID: diskEncryption.id,`which is also fine (I guess). But now, almost obviously, I'm getting:
Copy code
Unable to access key vault resource 'https://(mykeyvaulthere).<http://vault.azure.net/keys/aks-des-key/31333607ad2b4cb3adfbcbbdd76a395d|vault.azure.net/keys/aks-des-key/31333607ad2b4cb3adfbcbbdd76a395d>' to enable encryption at rest. Please grant get, wrap and unwrap key permissions to disk encryption set 'aks-des'. Please visit <https://aka.ms/keyvaultaccessssecmk> for more information.
So I decide that I really should set up authorization for diskEncryption to access the diskKey. Note: I created my keyVault with
enableRbacAuthorization: true,
. So here goes:
Copy code
const diskEncryptionRoleAssignment = new azure.authorization.RoleAssignment("des-to-kv", {
        scope: aksStack.keyVault.parameters.id,
        roleDefinitionId: "Reader",
        principalId: diskEncryption.identity // <--- should in not be able to access the principalid from diskEncryption somehow?!
I am absolutely a noob at this - not even sure I'm granting the right thing to the right stuff for any reason really, but I do know that if I want to use RoleAssignement for anything where I use SystemAssigned identity, I need to be able to reference it as expected.. From the Supporting Types of DiskEncryptionSet - EncryptionSetIdentity has the
which I defined, but then EncryptionSetIdentityResponse has `principalId`and `tenantId`in addition - which I want.. but the outputs of DiskEncryptionSet say nothing about those fields! How.. do I access them? Nevermind if I'm even on the right track..
Looking at this blog post (https://www.pulumi.com/blog/get-up-and-running-with-azure-synapse-and-pulumi/) and the spec of synapse.Workspace - it's similar to the output spec of compute.DiskEncryptionSet and a lot of others in that the
field is not listed in the output (as it is an input), but is still accessible (because all inputs are), and has the same *IdentityResponse type - meaning that it should expose principalId and tenantId. The example uses the `workspace.identity.principalId`though as far as I can tell - typescript will go bananas at the thought of using it (as it does with me). Is this an issue with type declarations or something?
Copy code
Property 'principalId' does not exist on type 'Output<EncryptionSetIdentityResponse | undefined>'.
Considering it's sunday and all, and I don't expect Mikhail to be everywhere all at once - I'll open a github issue on this one as that error does seem to indicate a bug for me ūüėČ
Once again Mikhail is sortof debugging this even in his absence - looking through existing issues, there's one related to RoleAssignmentName (https://github.com/pulumi/pulumi-azure-native/issues/625) in which he links to a c# example where he uses random..
in that code - right below - he's using chained `.apply`'s to get the principalId out of the identity https://github.com/pulumi/examples/blob/2e9e18b36a9720dd0e691f2bfe883bbfd46bd512/azure-cs-synapse/MyStack.cs#L79
Yes, you need
. Responded in the issue.
so.. taking that c# and putting it into ts makes that line look like this for me:
principalId: diskEncryption.identity.apply(identity => identity?.principalId).apply(principalId => principalId ?? "<preview>")
Thanks Mikhail - closing issue and finally able to deal with real problems ūüėČ