0

I want to import an existing key from the keyvault in the following way:

key_import_url = '/subscriptions/{subscription_id}/resourceGroups/{key_vault_rg_name}/providers/Microsoft.KeyVault/vaults/{keyvault_name}/keys/{key_name}'

key_vault_key = keyvault.Key(self.key_name,
    key_name            = self.key_name,
    resource_group_name = self.key_vault_rg_name,
    vault_name          = self.keyvault_name,
    opts                = ResourceOptions(
                            protect=True,
                            import_= key_import_url.format(self.app_subscription_id, self.key_vault_rg_name, self.keyvault_name, self.key_name),
                            ignore_changes=['tags','properties'])
)

I get the following error:

File "/home/vsts/work/r1/a/Source/pulumi/venv/lib/python3.8/site-packages/pulumi_azure_native/keyvault/key.py", line 168, in _internal_init
        raise TypeError("Missing required property 'properties'")
    TypeError: Missing required property 'properties'
    error: an unhandled error occurred: Program exited with non-zero exit code: 1

I don't understand why it says there is missing property when I put it in the ignore list.

Can you please point out why it does not import that way and what should I change to be imported. I don't want to include the existing properties. If I want to import something that means I should only give the url and then pulumi should recognise all of its properties without specifying them. Why it does not work simply with the import string or what do I do wrong?

Sunflame
  • 2,993
  • 4
  • 24
  • 48
  • May I ask why you are ignoring `properties`? Properties seem to be genuinely required based on the doc. – Mikhail Shilkov Apr 26 '22 at 18:08
  • That was just an experiment, i thought if i ignore them then it won't require, but it is. It is not intuitive for me if I want to import something based on an import string why does it require to specify all its components/properties? It exists already, and I don't want to change anything I just need the key itself. – Sunflame Apr 27 '22 at 07:53
  • That's the way how the `import` option works today - it's conservative in order to get you to a working code. It sounds like you may be looking for the `pulumi import` command which is more permissive. – Mikhail Shilkov Apr 27 '22 at 18:45

0 Answers0