Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #3368 - Sanitise regex group name to only allow alpha-numeric characters. - Map back to original name. - Tidy test cases with nesting. This will currently result in an additional input being generated during the import. This then appears during the next up as a property deletion, though it actually has no effect. ## Demonstration Using the `examples/keyvault-accesspolicies/` example: 1. Perform `up` gives the state (inputs and outputs): ``` "policy": { "objectId": "xxxx", "permissions": { "keys": [ "get", "create", "delete", "list" ], "secrets": [ "get", "list", "set", "delete" ] }, "tenantId": "xxxx" }, "resourceGroupName": "rgxxxx", "vaultName": "vaultxxxx" ``` 2. Delete the resource from the state: `pulumi state delete urn:pulumi:dev::scratch::azure-native:keyvault:AccessPolicy::ap1` 3. Import the resource: `pulumi import resource ap1 "/subscriptions/xxxx/resourceGroups/rgxxxx/providers/Microsoft.KeyVault/vaults/vaultxxxx/accessPolicy/xxxx"` 4. Check the state with `pulumi stack export`, the inputs now include `object.Id`: ``` "policy": { ... }, "policy.objectId": "xxxx", "resourceGroupName": "rgxxxx", "vaultName": "vaultxxxx" ``` 5. Perform another up (`pulumi up`). Preview shows removal of policy => ObjectId: <img width="529" alt="image" src="https://github.com/pulumi/pulumi-azure-native/assets/331676/77a8605a-518d-43fb-929e-86ed6195aaf8"> State inputs revert to remove `policy.objectId`: ``` "policy": { ... }, "resourceGroupName": "rgxxxx", "vaultName": "vaultxxxx" ``` ## Tracing usage of ParseResourceID The result from this function is used here: https://github.com/pulumi/pulumi-azure-native/blob/e8feca2c41d0e5d904eee9cc13eeea774d51ec1d/provider/pkg/provider/provider.go#L1080-L1087 The `pathItems` are passed into `ResponseToSdkInputs` where they are used if they match one of the parameters in the metadata: https://github.com/pulumi/pulumi-azure-native/blob/e8feca2c41d0e5d904eee9cc13eeea774d51ec1d/provider/pkg/convert/responseToSdkInputs.go#L18-L24 This will match: https://github.com/pulumi/pulumi-azure-native/blob/e8feca2c41d0e5d904eee9cc13eeea774d51ec1d/provider/pkg/resources/customresources/custom_keyvault_accesspolicy.go#L67
- Loading branch information