-
Notifications
You must be signed in to change notification settings - Fork 531
feat: Synapase - Added support for HSM #6218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
AlexanderSehr
wants to merge
30
commits into
main
Choose a base branch
from
users/alsehr/synapseHSM
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
948b7f6
Update to latest
AlexanderSehr c8d68e2
Update to latest
AlexanderSehr be3cd81
Update to latest
AlexanderSehr 2afd656
Update to latest
AlexanderSehr cbe5ab8
Update to latest
AlexanderSehr edc6e71
Update to latest
AlexanderSehr cf5bb9b
Update to latest
AlexanderSehr 92fd665
Fixed role assignment
AlexanderSehr 11968d3
Update to latest
AlexanderSehr b3af4b9
Update to latest
AlexanderSehr cbdc626
Updated sys assigned
AlexanderSehr 12600b6
Update to latest
AlexanderSehr 302f391
Merge branch 'main' into users/alsehr/synapseHSM
AlexanderSehr d95ef80
Re-added role assignment + aligned identity format
AlexanderSehr 6b4052e
Update to latest
AlexanderSehr 4cad98c
Update to latest
AlexanderSehr 5814279
Update to latest
AlexanderSehr b8c566d
Update to latest
AlexanderSehr 562cc99
Update to latest
AlexanderSehr 731d8c9
Update to latest
AlexanderSehr f28bc9a
Update to latest
AlexanderSehr 68fe9f4
Update to latest
AlexanderSehr 8ba63f1
Update to latest
AlexanderSehr 2d7f065
Update to latest
AlexanderSehr 4b03c9b
Update to latest
AlexanderSehr 6772bc1
Test with version for hsm
AlexanderSehr 3f7e69b
Update to latest
AlexanderSehr 16da3a0
Update to latest
AlexanderSehr 0e41a38
Changed to crypto user for testing
AlexanderSehr d40362d
Update to latest
AlexanderSehr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| The test is skipped because running the HSM scenario requires a persistent Managed HSM instance to be available and configured at all times, which would incur significant costs for contributors. |
13 changes: 13 additions & 0 deletions
13
avm/res/synapse/workspace/tests/e2e/cmk-hsm-uami/Set-mHMSKeyConfig.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| echo "Checking role assignment for HSM: $1, Key: $2, Principal: $3" | ||
| # Allow key reference via identity | ||
| result=$(az keyvault role assignment list --hsm-name "$1" --scope "/keys/$2" --query "[?principalId == \`$3\` && roleName == \`Managed HSM Crypto Service Encryption User\`]") | ||
|
|
||
| if [[ "$result" != "[]" ]]; then | ||
| echo "Role assignment already exists." | ||
| else | ||
| echo "Role assignment not yet existing. Creating." | ||
| az keyvault role assignment create --hsm-name "$1" --role "Managed HSM Crypto Service Encryption User" --scope "/keys/$2" --assignee $3 | ||
| fi | ||
|
|
||
| # Allow usage via ARM | ||
| az keyvault setting update --hsm-name $1 --name 'AllowKeyManagementOperationsThroughARM' --value 'true' |
79 changes: 79 additions & 0 deletions
79
avm/res/synapse/workspace/tests/e2e/cmk-hsm-uami/dependencies.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| @description('Optional. The location to deploy to.') | ||
| param location string = resourceGroup().location | ||
|
|
||
| @description('Required. The name of the Storage Account to create.') | ||
| param storageAccountName string | ||
|
|
||
| @description('Required. The name of the Managed Identity to create.') | ||
| param managedIdentityName string | ||
|
|
||
| @description('Required. The name of the Deployment Script to configure the HSM Key permissions.') | ||
| param deploymentScriptName string | ||
|
|
||
| @description('Required. The resource ID of the Managed Identity used by the deployment script. This value is tenant-specific and must be stored in the CI Key Vault in a secret named \'CI-deploymentMSIName\'.') | ||
| @secure() | ||
| param deploymentMSIResourceId string | ||
|
|
||
| @description('Required. The resource ID of the managed HSM used for encryption. This value is tenant-specific and must be stored in the CI Key Vault in a secret named \'CI-managedHSMResourceId\'.') | ||
| @secure() | ||
| param managedHSMResourceId string | ||
|
|
||
| @description('Required. The name of the HSMKey Vault Encryption Key.') | ||
| param keyName string | ||
|
|
||
| resource storageAccount 'Microsoft.Storage/storageAccounts@2025-01-01' = { | ||
| name: storageAccountName | ||
| location: location | ||
| sku: { | ||
| name: 'Standard_LRS' | ||
| } | ||
| kind: 'StorageV2' | ||
| properties: { | ||
| isHnsEnabled: true | ||
| } | ||
|
|
||
| resource blobService 'blobServices@2025-01-01' = { | ||
| name: 'default' | ||
|
|
||
| resource container 'containers@2025-01-01' = { | ||
| name: 'synapsews' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = { | ||
| name: managedIdentityName | ||
| location: location | ||
| } | ||
|
|
||
| module allowHsmAccess 'br/public:avm/res/resources/deployment-script:0.5.2' = { | ||
| name: '${uniqueString(deployment().name, location)}-hmsKeyPermissions' | ||
| params: { | ||
| name: deploymentScriptName | ||
| kind: 'AzureCLI' | ||
| azCliVersion: '2.67.0' | ||
| arguments: '"${last(split(managedHSMResourceId, '/'))}" "${keyName}" "${managedIdentity.properties.principalId}"' | ||
| scriptContent: loadTextContent('Set-mHMSKeyConfig.sh') | ||
| retentionInterval: 'P1D' | ||
| managedIdentities: { | ||
| userAssignedResourceIds: [ | ||
| deploymentMSIResourceId | ||
| ] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @description('The resource ID of the created Storage Account.') | ||
| output storageAccountResourceId string = storageAccount.id | ||
|
|
||
| @description('The name of the created container.') | ||
| output storageContainerName string = storageAccount::blobService::container.name | ||
|
|
||
| @description('The principal ID of the created Managed Identity.') | ||
| output managedIdentityPrincipalId string = managedIdentity.properties.principalId | ||
|
|
||
| @description('The name of the created Managed Identity.') | ||
| output managedIdentityName string = managedIdentity.name | ||
|
|
||
| @description('The resource ID of the created Managed Identity.') | ||
| output managedIdentityResourceId string = managedIdentity.id |
30 changes: 30 additions & 0 deletions
30
avm/res/synapse/workspace/tests/e2e/cmk-hsm-uami/dependencies.hsm.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| @description('Required. The name of the key to create in the HSM.') | ||
| param hsmKeyName string | ||
|
|
||
| @description('Required. The name of the managed HSM used for encryption.') | ||
| @secure() | ||
| param managedHSMName string | ||
|
|
||
| resource managedHsm 'Microsoft.KeyVault/managedHSMs@2025-05-01' existing = { | ||
| name: managedHSMName | ||
|
|
||
| resource key 'keys@2025-05-01' existing = { | ||
| name: hsmKeyName | ||
| } | ||
| // resource key 'keys@2025-05-01' = { | ||
| // name: hsmKeyName | ||
| // properties: { | ||
| // keySize: 3072 // Not supporting 4096 | ||
| // kty: 'RSA-HSM' | ||
| // } | ||
| // } | ||
| } | ||
|
|
||
| @description('The resource ID of the HSM Key Vault.') | ||
| output keyVaultResourceId string = managedHsm.id | ||
|
|
||
| @description('The name of the HSMKey Vault Encryption Key.') | ||
| output keyName string = managedHsm::key.name | ||
|
|
||
| @description('The version of the HSMKey Vault Encryption Key.') | ||
| output keyVersion string = last(split(managedHsm::key.properties.keyUriWithVersion, '/')) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.