-
Notifications
You must be signed in to change notification settings - Fork 437
[Modules] Update SQL MI to new dependencies approach #2316
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
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
867658f
dep only
eriqua 0c7630a
disable pester
eriqua 49a83da
remove param
eriqua 07f4937
subnet boundary
eriqua af56ce7
min resource
eriqua b57e5f8
min and common dep
eriqua c47d96d
clean up param
eriqua 3a45f34
disable min resource
eriqua 112d13a
enable com resource
eriqua 840ffb9
min resource readme and cleanup
eriqua 2cdd3a6
enable pester
eriqua 30e3939
sqlmi removal
eriqua 7afc9f9
Update deploy.test.bicep
eriqua 589d74c
Update dependencies.bicep
eriqua 76d2724
Update dependencies.bicep
eriqua 6a7413c
Merge branch 'main' into users/erikag/1964-sqlmi-newdep
eriqua 812c038
readme
eriqua a750580
no main resource
eriqua dc1128f
formatting
eriqua 577c626
temp serviceshort
eriqua cda396e
serviceshort
eriqua 8ef7ec0
test main resource
eriqua f136df5
no encr prot and key
eriqua 719c33a
test dep name
eriqua 082bc4e
enc obj with kv crypto user
eriqua abcc73b
Key Vault Crypto Service Encryption User
eriqua 604b7b7
update sqlmi dep
eriqua b18010d
update sqlmi dep no token
eriqua 97976e6
merge latest
eriqua c756c98
serverKeyName
eriqua f9efc32
Merge branch 'main' into users/erikag/1964-sqlmi-newdep
eriqua 96fe685
readme
eriqua 03ff53e
keys
eriqua 01f2639
Merge branch 'main' into users/erikag/1964-sqlmi-newdep
eriqua 50c19e1
test nsg dep
eriqua 4c5b888
disable min
eriqua d1d73e1
rt and vnet
eriqua 04db8a1
change rg
eriqua 7d8583b
rt set
eriqua b993d0b
change rg
eriqua 857c955
enable all resources
eriqua 72f0e08
encr obj
eriqua c9a7002
min
eriqua 4f77050
min dep update
eriqua 2625836
Merge branch 'main' into users/erikag/1964-sqlmi-newdep
eriqua d6640a2
encr obj depending on keys
eriqua 3a246fc
pester back
eriqua 6794f9e
readme
eriqua 01f96a6
common dep cleanup
eriqua a95faf6
key rbac
eriqua 5a5f90c
cleanup
eriqua 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
350 changes: 350 additions & 0 deletions
350
modules/Microsoft.Sql/managedInstances/.test/common/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,350 @@ | ||
| @description('Required. The name of the Virtual Network to create.') | ||
| param virtualNetworkName string | ||
|
|
||
| @description('Required. The name of the Network Security Group to create.') | ||
| param networkSecurityGroupName string | ||
|
|
||
| @description('Required. The name of the Route Table to create.') | ||
| param routeTableName string | ||
|
|
||
| @description('Required. The name of the Managed Identity to create.') | ||
| param managedIdentityName string | ||
|
|
||
| @description('Required. The name of the Key Vault to create.') | ||
| param keyVaultName string | ||
|
|
||
| @description('Optional. The location to deploy resources to.') | ||
| param location string = resourceGroup().location | ||
|
|
||
| var sqlMiVnetAddressPrefix = '10.0.0.0/16' | ||
| var sqlMiSubnetAddressPrefix = '10.0.0.0/24' | ||
| var sqlMiSubnetAddressPrefixString = replace(replace(sqlMiSubnetAddressPrefix, '.', '-'), '/', '-') | ||
|
|
||
| resource networkSecurityGroup 'Microsoft.Network/networkSecurityGroups@2021-08-01' = { | ||
| name: networkSecurityGroupName | ||
| location: location | ||
| properties: { | ||
| securityRules: [ | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-sqlmgmt-in-${sqlMiSubnetAddressPrefixString}-v10' | ||
| properties: { | ||
| description: 'Allow MI provisioning Control Plane Deployment and Authentication Service' | ||
| protocol: 'Tcp' | ||
| sourcePortRange: '*' | ||
| sourceAddressPrefix: 'SqlManagement' | ||
| destinationAddressPrefix: sqlMiSubnetAddressPrefix | ||
| access: 'Allow' | ||
| priority: 100 | ||
| direction: 'Inbound' | ||
| destinationPortRanges: [ | ||
| '9000' | ||
| '9003' | ||
| '1438' | ||
| '1440' | ||
| '1452' | ||
| ] | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-corpsaw-in-${sqlMiSubnetAddressPrefixString}-v10' | ||
| properties: { | ||
| description: 'Allow MI Supportability' | ||
| protocol: 'Tcp' | ||
| sourcePortRange: '*' | ||
| sourceAddressPrefix: 'CorpNetSaw' | ||
| destinationAddressPrefix: sqlMiSubnetAddressPrefix | ||
| access: 'Allow' | ||
| priority: 101 | ||
| direction: 'Inbound' | ||
| destinationPortRanges: [ | ||
| '9000' | ||
| '9003' | ||
| '1440' | ||
| ] | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-corppublic-in-${sqlMiSubnetAddressPrefixString}-v10' | ||
| properties: { | ||
| description: 'Allow MI Supportability through Corpnet ranges' | ||
| protocol: 'Tcp' | ||
| sourcePortRange: '*' | ||
| sourceAddressPrefix: 'CorpNetPublic' | ||
| destinationAddressPrefix: sqlMiSubnetAddressPrefix | ||
| access: 'Allow' | ||
| priority: 102 | ||
| direction: 'Inbound' | ||
| destinationPortRanges: [ | ||
| '9000' | ||
| '9003' | ||
| ] | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-healthprobe-in-${sqlMiSubnetAddressPrefixString}-v10' | ||
| properties: { | ||
| description: 'Allow Azure Load Balancer inbound traffic' | ||
| protocol: '*' | ||
| sourcePortRange: '*' | ||
| destinationPortRange: '*' | ||
| sourceAddressPrefix: 'AzureLoadBalancer' | ||
| destinationAddressPrefix: sqlMiSubnetAddressPrefix | ||
| access: 'Allow' | ||
| priority: 103 | ||
| direction: 'Inbound' | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-internal-in-${sqlMiSubnetAddressPrefixString}-v10' | ||
| properties: { | ||
| description: 'Allow MI internal inbound traffic' | ||
| protocol: '*' | ||
| sourcePortRange: '*' | ||
| destinationPortRange: '*' | ||
| sourceAddressPrefix: sqlMiSubnetAddressPrefix | ||
| destinationAddressPrefix: sqlMiSubnetAddressPrefix | ||
| access: 'Allow' | ||
| priority: 104 | ||
| direction: 'Inbound' | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-services-out-${sqlMiSubnetAddressPrefixString}-v10' | ||
| properties: { | ||
| description: 'Allow MI services outbound traffic over https' | ||
| protocol: 'Tcp' | ||
| sourcePortRange: '*' | ||
| sourceAddressPrefix: sqlMiSubnetAddressPrefix | ||
| destinationAddressPrefix: 'AzureCloud' | ||
| access: 'Allow' | ||
| priority: 100 | ||
| direction: 'Outbound' | ||
| destinationPortRanges: [ | ||
| '443' | ||
| '12000' | ||
| ] | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-internal-out-${sqlMiSubnetAddressPrefixString}-v10' | ||
| properties: { | ||
| description: 'Allow MI internal outbound traffic' | ||
| protocol: '*' | ||
| sourcePortRange: '*' | ||
| destinationPortRange: '*' | ||
| sourceAddressPrefix: sqlMiSubnetAddressPrefix | ||
| destinationAddressPrefix: sqlMiSubnetAddressPrefix | ||
| access: 'Allow' | ||
| priority: 101 | ||
| direction: 'Outbound' | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| resource routeTable 'Microsoft.Network/routeTables@2021-08-01' = { | ||
| name: routeTableName | ||
| location: location | ||
| properties: { | ||
| disableBgpRoutePropagation: false | ||
| routes: [ | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_subnet-${sqlMiSubnetAddressPrefixString}-to-vnetlocal' | ||
| properties: { | ||
| addressPrefix: sqlMiSubnetAddressPrefix | ||
| nextHopType: 'VnetLocal' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-Storage' | ||
| properties: { | ||
| addressPrefix: 'Storage' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-SqlManagement' | ||
| properties: { | ||
| addressPrefix: 'SqlManagement' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-AzureMonitor' | ||
| properties: { | ||
| addressPrefix: 'AzureMonitor' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-CorpNetSaw' | ||
| properties: { | ||
| addressPrefix: 'CorpNetSaw' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-CorpNetPublic' | ||
| properties: { | ||
| addressPrefix: 'CorpNetPublic' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-AzureActiveDirectory' | ||
| properties: { | ||
| addressPrefix: 'AzureActiveDirectory' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-AzureCloud.westeurope' | ||
| properties: { | ||
| addressPrefix: 'AzureCloud.westeurope' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-AzureCloud.northeurope' | ||
| properties: { | ||
| addressPrefix: 'AzureCloud.northeurope' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-Storage.westeurope' | ||
| properties: { | ||
| addressPrefix: 'Storage.westeurope' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-Storage.northeurope' | ||
| properties: { | ||
| addressPrefix: 'Storage.northeurope' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-EventHub.westeurope' | ||
| properties: { | ||
| addressPrefix: 'EventHub.westeurope' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| { | ||
| name: 'Microsoft.Sql-managedInstances_UseOnly_mi-EventHub.northeurope' | ||
| properties: { | ||
| addressPrefix: 'EventHub.northeurope' | ||
| nextHopType: 'Internet' | ||
| hasBgpOverride: false | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-01-01' = { | ||
| name: virtualNetworkName | ||
| location: location | ||
| properties: { | ||
| addressSpace: { | ||
| addressPrefixes: [ | ||
| sqlMiVnetAddressPrefix | ||
| ] | ||
| } | ||
| subnets: [ | ||
| { | ||
| name: 'ManagedInstance' | ||
| properties: { | ||
| addressPrefix: sqlMiSubnetAddressPrefix | ||
| routeTable: { | ||
| id: routeTable.id | ||
| } | ||
| networkSecurityGroup: { | ||
| id: networkSecurityGroup.id | ||
| } | ||
| delegations: [ | ||
| { | ||
| name: 'managedInstanceDelegation' | ||
| properties: { | ||
| serviceName: 'Microsoft.Sql/managedInstances' | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { | ||
| name: managedIdentityName | ||
| location: location | ||
| } | ||
|
|
||
| resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = { | ||
| name: keyVaultName | ||
| location: location | ||
| properties: { | ||
| sku: { | ||
| family: 'A' | ||
| name: 'standard' | ||
| } | ||
| tenantId: tenant().tenantId | ||
| enablePurgeProtection: null | ||
| enabledForTemplateDeployment: true | ||
| enabledForDiskEncryption: true | ||
| enabledForDeployment: true | ||
| enableRbacAuthorization: true | ||
| accessPolicies: [] | ||
| } | ||
|
|
||
| resource key 'keys@2022-07-01' = { | ||
| name: 'keyEncryptionKey' | ||
| properties: { | ||
| kty: 'RSA' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource keyPermissions 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| name: guid('msi-${keyVault::key.id}-${location}-${managedIdentity.id}-Key-Reader-RoleAssignment') | ||
| scope: keyVault::key | ||
| properties: { | ||
| principalId: managedIdentity.properties.principalId | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'e147488a-f6f5-4113-8e2d-b22465e65bf6') // Key Vault Crypto Service Encryption User | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| } | ||
|
|
||
| @description('The resource ID of the created Virtual Network Subnet.') | ||
| output subnetResourceId string = virtualNetwork.properties.subnets[0].id | ||
|
|
||
| @description('The principal ID of the created Managed Identity.') | ||
| output managedIdentityPrincipalId string = managedIdentity.properties.principalId | ||
|
|
||
| @description('The resource ID of the created Managed Identity.') | ||
| output managedIdentityResourceId string = managedIdentity.id | ||
|
|
||
| @description('The URL of the created Key Vault Encryption Key.') | ||
| output keyVaultEncryptionKeyUrl string = keyVault::key.properties.keyUriWithVersion | ||
|
|
||
| @description('The name of the created Key Vault Encryption Key.') | ||
| output keyVaultKeyName string = keyVault::key.name | ||
|
|
||
| @description('The name of the created Key Vault.') | ||
| output keyVaultName string = keyVault.name | ||
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.
Uh oh!
There was an error while loading. Please reload this page.