Skip to content
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

Created sql server bicep module #67

Merged
merged 94 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
ecf082d
first draft
Sep 22, 2021
9c33a06
first end2end traft
Sep 22, 2021
b89c48c
Merge pull request #1 from MrMCake/users/alsehr/readMePipe
AlexanderSehr Sep 22, 2021
eed36cb
Minor update
Sep 22, 2021
dfef29d
Minor update
Sep 22, 2021
824fd68
Minor update
Sep 22, 2021
04a83d5
Minor update
Sep 22, 2021
9cdbbd1
Minor cleanup
Sep 22, 2021
d71a752
Minor cleanup
Sep 22, 2021
4552821
Minor cleanup
Sep 22, 2021
68afd99
Added version output
Sep 22, 2021
e31aa68
Added output
Sep 22, 2021
c8b89f7
Minor cleanup
Sep 22, 2021
5193495
Added output
Sep 22, 2021
061b6bd
Added output
Sep 22, 2021
99fffba
Added output
Sep 22, 2021
a36cf1a
Simplified logic
Sep 22, 2021
f6f6f15
Added output
Sep 23, 2021
549b231
Added output
Sep 23, 2021
1ace41f
Added output + refactoring
Sep 23, 2021
32324f9
Added output
Sep 23, 2021
6237c3c
Added output
Sep 23, 2021
58bd9d3
Added replacement
Sep 23, 2021
f4068f7
Added replacement v2
Sep 23, 2021
17b66c1
Cleanup
Sep 23, 2021
c751783
Reset trigger
Sep 23, 2021
d70c060
Added output
Sep 23, 2021
ddee0df
Fixed typo
Sep 23, 2021
05d6a46
Added todo.
Sep 23, 2021
fee5954
Merge pull request #2 from MrMCake/users/alsehr/readMePipe
AlexanderSehr Sep 23, 2021
f88ad87
Updated docs
Sep 23, 2021
3b14289
Merge branch 'Azure:main' into main
AlexanderSehr Sep 23, 2021
ecb19b4
Replaced login with cred
Sep 23, 2021
8314fc8
Replaced cred ref
Sep 23, 2021
ffe9691
added missing func
Sep 23, 2021
648883c
Minor update
Sep 23, 2021
2bd2d1e
Pretest changes
Sep 23, 2021
56e8c2f
Updated remaining tests + extended api tests to exclude preview and a…
Sep 23, 2021
db04e68
Added template translation to test-deployment
Sep 23, 2021
53c8c4e
Temp add publish condition
Sep 24, 2021
6369c7c
Another try
Sep 24, 2021
fcace61
Another try
Sep 24, 2021
cd69596
Another try
Sep 24, 2021
d493a7a
Another try
Sep 24, 2021
77e912f
Undid temp changes
Sep 24, 2021
79f17f4
Merge branch 'Azure:main' into main
AlexanderSehr Sep 24, 2021
e0ea080
Merge branch 'Azure:main' into main
AlexanderSehr Sep 24, 2021
94d02fd
Merge branch 'main' into users/alsehr/bicepPipeline
Sep 24, 2021
b3425bd
Added workaround to acocunt for bicep compile issue [deployments api …
Sep 24, 2021
305e49a
Merge branch 'Azure:main' into main
AlexanderSehr Sep 24, 2021
09cb61f
Shifted bicep handling to native PS commands with bicep cli support +…
Sep 24, 2021
78dfe9f
Updated remaining pipelines to use creds object
Sep 24, 2021
76e80ae
Fixed schema eval
Sep 24, 2021
63d2804
Updated readme
Sep 24, 2021
734df4b
Temp remove arm templates to ensure it runs without
Sep 24, 2021
cc8311a
Updated removal jobs to bicep + added publish workaround to allow for…
Sep 24, 2021
8bdcc93
Minor updates
Sep 24, 2021
de80bf9
Further updates
Sep 24, 2021
ad84732
Further updates
Sep 24, 2021
a04883d
Restored templates
Sep 24, 2021
eaccb21
Merge latest deploy
Sep 24, 2021
063c7b7
Merge pull request #3 from MrMCake/users/alsehr/bicepPipeline
AlexanderSehr Sep 24, 2021
6e5dd28
Moved lock + rg bicep fix
Sep 24, 2021
29fe51c
Fixed path
Sep 24, 2021
cc7f2f3
Temp disabled template spec publish
Sep 24, 2021
4bb68e4
Undo after test
Sep 24, 2021
94a39b3
Aligned bicep templates rbac
Sep 25, 2021
1bf8013
Reduced roles for gallery
Sep 25, 2021
954dc33
Reduced role ref
Sep 25, 2021
c9c4336
Cleanup
Sep 25, 2021
8ae9a3c
Created vmss template
Sep 25, 2021
6104214
Adjusted api tests
Sep 25, 2021
cef5542
Added output
Sep 25, 2021
809a159
Switched ref for vmss to bicep
Sep 25, 2021
b1b5093
Updated param
Sep 25, 2021
6d35c79
Updated api
Sep 25, 2021
b86ec8f
Merged latest main
Sep 25, 2021
9a141e5
Adjusted output
Sep 25, 2021
95569dd
Updated error handling
Sep 25, 2021
a779c33
Updated output
Sep 25, 2021
8adfef9
Updated function input print
Sep 25, 2021
876a231
Finishing touches
Sep 25, 2021
b7e2c0d
Merge pull request #4 from MrMCake/users/alsehr/vmssTemplate
AlexanderSehr Sep 25, 2021
ae3f54b
Small update
Sep 25, 2021
e2e68ff
Fallback scale set to split PRs
Sep 25, 2021
818cf9a
Updated module name
Sep 25, 2021
d05ecc0
Cleanup
Sep 25, 2021
00d2410
Cleanupo
Sep 25, 2021
52098fe
Added sql server bicep
Sep 26, 2021
4b59b7c
Undo previous changes
Sep 26, 2021
5e7ef3d
Updated rbac
Sep 26, 2021
de2265f
Merge branch 'Azure:main' into main
AlexanderSehr Sep 27, 2021
33d4368
merged with main
Sep 27, 2021
c929ce3
minor update
Sep 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ms.sql.servers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- name: "Test module"
uses: ./.github/actions/templates/validateModuleDeploy
with:
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/parameters/${{ matrix.parameterFilePaths }}'
location: '${{ env.defaultLocation }}'
resourceGroupName: '${{ env.resourceGroupName }}'
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
uses: ./.github/actions/templates/deployModule
with:
moduleName: '${{ env.moduleName }}'
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/parameters/${{ matrix.parameterFilePaths }}'
location: '${{ env.defaultLocation }}'
resourceGroupName: '${{ env.resourceGroupName }}'
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
- name: "Publish module"
uses: ./.github/actions/templates/publishModule
with:
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
componentTemplateSpecRGName: '${{ env.componentTemplateSpecRGName }}'
componentTemplateSpecRGLocation: '${{ env.componentTemplateSpecRGLocation }}'
componentTemplateSpecName: '${{ env.moduleName }}'
Expand Down Expand Up @@ -176,5 +176,5 @@ jobs:
uses: ./.github/actions/templates/removeModule
with:
moduleName: '${{ env.moduleName }}'
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
resourceGroupName: '${{ env.resourceGroupName }}'
Empty file.
12 changes: 12 additions & 0 deletions arm/Microsoft.Sql/servers/.bicep/nested_rbac.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
param roleAssignment object
param builtInRoleNames object
param serverName string

resource nested_rbac 'Microsoft.Web/sites/providers/roleAssignments@2020-04-01-preview' = [for principalId in roleAssignment.principalIds: {
name: '${serverName}/Microsoft.Authorization/${guid(serverName, principalId, roleAssignment.roleDefinitionIdOrName)}'
properties: {
roleDefinitionId: (contains(builtInRoleNames, roleAssignment.roleDefinitionIdOrName) ? builtInRoleNames[roleAssignment.roleDefinitionIdOrName] : roleAssignment.roleDefinitionIdOrName)
principalId: principalId
}
dependsOn: []
}]
110 changes: 110 additions & 0 deletions arm/Microsoft.Sql/servers/deploy.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
@description('Required. Administrator username for the server.')
param administratorLogin string

@description('Required. The administrator login password.')
@secure()
param administratorLoginPassword string

@description('Optional. Location for all resources.')
param location string = resourceGroup().location

@description('Required. The name of the server.')
param serverName string

@description('Optional. Whether or not ADS should be enabled.')
param enableADS bool = false

@description('Required. Whether or not Azure IP\'s are allowed.')
param allowAzureIps bool = false

@description('Optional. Switch to lock Key Vault from deletion.')
param lockForDeletion bool = false

@description('Optional. Array of role assignment objects that contain the \'roleDefinitionIdOrName\' and \'principalId\' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'')
param roleAssignments array = []

@description('Optional. Tags of the resource.')
param tags object = {}

@description('Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered')
param cuaId string = ''

var builtInRoleNames = {
'Owner': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','8e3af657-a8ff-443c-a75c-2fe8c4bcb635')
'Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','b24988ac-6180-42a0-ab88-20f7382dd24c')
'Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','acdd72a7-3385-48ef-bd42-f606fba81ae7')
'Log Analytics Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','92aaf0da-9dab-42b6-94a3-d43ce8d16293')
'Log Analytics Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','73c42c96-874c-492b-b04d-ab87d138a893')
'Managed Application Contributor Role': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','641177b8-a67a-45b9-a033-47bc880bb21e')
'Managed Application Operator Role': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','c7393b34-138c-406f-901b-d8cf2b17e6ae')
'Managed Applications Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','b9331d33-8a36-4f8c-b097-4f54124fdb44')
'Monitoring Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','749f88d5-cbae-40b8-bcfc-e573ddc772fa')
'Monitoring Metrics Publisher': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','3913510d-42f4-4e42-8a64-420c390055eb')
'Monitoring Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','43d0d8ad-25c7-4714-9337-8ba259a9fe05')
'Reservation Purchaser': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','f7b75c60-3036-4b75-91c3-6b41c27c1689')
'Resource Policy Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','36243c78-bf99-498c-9df9-86d9f8d28608')
'SQL DB Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','9b7fa17d-e63e-47b0-bb0a-15c516ac86ec')
'SQL Security Manager': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','056cd41c-7e88-42e1-933e-88ba6a50c9c3')
'SQL Server Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','6d8ee4ec-f05a-4a1d-8b00-a9b17e38b437')
'User Access Administrator': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')
}

module pid_cuaId './.bicep/nested_cuaId.bicep' = if (!empty(cuaId)) {
name: 'pid-${cuaId}'
params: {}
}

resource server 'Microsoft.Sql/servers@2020-02-02-preview' = {
location: location
name: serverName
tags: tags
properties: {
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
version: '12.0'
}
}

resource server_lock 'Microsoft.Authorization/locks@2016-09-01' = if (lockForDeletion) {
name: '${serverName}-serverDoNotDelete'
properties: {
level: 'CanNotDelete'
}
scope: server
}

resource server_AllowAllWindowsAzureIps 'Microsoft.Sql/servers/firewallrules@2021-02-01-preview' = if (allowAzureIps) {
parent: server
name: 'AllowAllWindowsAzureIps'
properties: {
endIpAddress: '0.0.0.0'
startIpAddress: '0.0.0.0'
}
}

resource server_Default 'Microsoft.Sql/servers/securityAlertPolicies@2021-02-01-preview' = if (enableADS) {
parent: server
name: 'Default'
properties: {
state: 'Enabled'
disabledAlerts: []
emailAddresses: []
emailAccountAdmins: true
}
}

module server_rbac './.bicep/nested_rbac.bicep' = [for (item, i) in roleAssignments: {
name: 'rbac-${deployment().name}${i}'
params: {
roleAssignment: item
builtInRoleNames: builtInRoleNames
serverName: serverName
}
dependsOn: [
server
]
}]

output serverName string = serverName
output serverResourceId string = server.id
output serverResourceGroup string = resourceGroup().name
Loading