Skip to content

Commit

Permalink
feat: Updated DB-For-My-SQL-Flexible-Server CMK implementation (#3737)
Browse files Browse the repository at this point in the history
## Description

- Updated DB-For-My-SQL-Flexible-Server CMK implementation
- Implemented AVM-Common-Types

Linked to 
- Update CMK implementations as per
#2842 (comment)
- Docs Update: Azure/Azure-Verified-Modules#1683
- UDT update: #3724

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.db-for-my-sql.flexible-server](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.db-for-my-sql.flexible-server.yml/badge.svg?branch=users%2Falsehr%2FcmkUpdateDBForMySQLFlexibleServer&event=workflow_dispatch)](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.db-for-my-sql.flexible-server.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [x] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation
  • Loading branch information
AlexanderSehr authored Dec 9, 2024
1 parent 6be7016 commit f6347ba
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 347 deletions.
47 changes: 28 additions & 19 deletions avm/res/db-for-my-sql/flexible-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This module deploys a DBforMySQL Flexible Server.
- [Usage examples](#Usage-examples)
- [Parameters](#Parameters)
- [Outputs](#Outputs)
- [Cross-referenced modules](#Cross-referenced-modules)
- [Data Collection](#Data-Collection)

## Resource Types
Expand Down Expand Up @@ -933,13 +934,13 @@ The managed identity definition for this resource. Required if 'customerManagedK

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`userAssignedResourceIds`](#parameter-managedidentitiesuserassignedresourceids) | array | The resource ID(s) to assign to the resource. |
| [`userAssignedResourceIds`](#parameter-managedidentitiesuserassignedresourceids) | array | The resource ID(s) to assign to the resource. Required if a user assigned identity is used for encryption. |

### Parameter: `managedIdentities.userAssignedResourceIds`

The resource ID(s) to assign to the resource.
The resource ID(s) to assign to the resource. Required if a user assigned identity is used for encryption.

- Required: Yes
- Required: No
- Type: array

### Parameter: `privateDnsZoneResourceId`
Expand Down Expand Up @@ -1060,13 +1061,13 @@ The customer managed key definition to use for the managed service.
| :-- | :-- | :-- |
| [`keyName`](#parameter-customermanagedkeykeyname) | string | The name of the customer managed key to use for encryption. |
| [`keyVaultResourceId`](#parameter-customermanagedkeykeyvaultresourceid) | string | The resource ID of a key vault to reference a customer managed key for encryption from. |
| [`userAssignedIdentityResourceId`](#parameter-customermanagedkeyuserassignedidentityresourceid) | string | User assigned identity to use when fetching the customer managed key. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`keyVersion`](#parameter-customermanagedkeykeyversion) | string | The version of the customer managed key to reference for encryption. If not provided, using 'latest'. |
| [`keyVersion`](#parameter-customermanagedkeykeyversion) | string | The version of the customer managed key to reference for encryption. If not provided, the deployment will use the latest version available at deployment time. |
| [`userAssignedIdentityResourceId`](#parameter-customermanagedkeyuserassignedidentityresourceid) | string | User assigned identity to use when fetching the customer managed key. Required if no system assigned identity is available for use. |

### Parameter: `customerManagedKey.keyName`

Expand All @@ -1082,16 +1083,16 @@ The resource ID of a key vault to reference a customer managed key for encryptio
- Required: Yes
- Type: string

### Parameter: `customerManagedKey.userAssignedIdentityResourceId`
### Parameter: `customerManagedKey.keyVersion`

User assigned identity to use when fetching the customer managed key.
The version of the customer managed key to reference for encryption. If not provided, the deployment will use the latest version available at deployment time.

- Required: Yes
- Required: No
- Type: string

### Parameter: `customerManagedKey.keyVersion`
### Parameter: `customerManagedKey.userAssignedIdentityResourceId`

The version of the customer managed key to reference for encryption. If not provided, using 'latest'.
User assigned identity to use when fetching the customer managed key. Required if no system assigned identity is available for use.

- Required: No
- Type: string
Expand All @@ -1109,13 +1110,13 @@ The customer managed key definition to use when geoRedundantBackup is "Enabled".
| :-- | :-- | :-- |
| [`keyName`](#parameter-customermanagedkeygeokeyname) | string | The name of the customer managed key to use for encryption. |
| [`keyVaultResourceId`](#parameter-customermanagedkeygeokeyvaultresourceid) | string | The resource ID of a key vault to reference a customer managed key for encryption from. |
| [`userAssignedIdentityResourceId`](#parameter-customermanagedkeygeouserassignedidentityresourceid) | string | User assigned identity to use when fetching the customer managed key. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`keyVersion`](#parameter-customermanagedkeygeokeyversion) | string | The version of the customer managed key to reference for encryption. If not provided, using 'latest'. |
| [`keyVersion`](#parameter-customermanagedkeygeokeyversion) | string | The version of the customer managed key to reference for encryption. If not provided, the deployment will use the latest version available at deployment time. |
| [`userAssignedIdentityResourceId`](#parameter-customermanagedkeygeouserassignedidentityresourceid) | string | User assigned identity to use when fetching the customer managed key. Required if no system assigned identity is available for use. |

### Parameter: `customerManagedKeyGeo.keyName`

Expand All @@ -1131,16 +1132,16 @@ The resource ID of a key vault to reference a customer managed key for encryptio
- Required: Yes
- Type: string

### Parameter: `customerManagedKeyGeo.userAssignedIdentityResourceId`
### Parameter: `customerManagedKeyGeo.keyVersion`

User assigned identity to use when fetching the customer managed key.
The version of the customer managed key to reference for encryption. If not provided, the deployment will use the latest version available at deployment time.

- Required: Yes
- Required: No
- Type: string

### Parameter: `customerManagedKeyGeo.keyVersion`
### Parameter: `customerManagedKeyGeo.userAssignedIdentityResourceId`

The version of the customer managed key to reference for encryption. If not provided, using 'latest'.
User assigned identity to use when fetching the customer managed key. Required if no system assigned identity is available for use.

- Required: No
- Type: string
Expand Down Expand Up @@ -1178,7 +1179,7 @@ The diagnostic settings of the service.
| [`logCategoriesAndGroups`](#parameter-diagnosticsettingslogcategoriesandgroups) | array | The name of logs that will be streamed. "allLogs" includes all possible logs for the resource. Set to `[]` to disable log collection. |
| [`marketplacePartnerResourceId`](#parameter-diagnosticsettingsmarketplacepartnerresourceid) | string | The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs. |
| [`metricCategories`](#parameter-diagnosticsettingsmetriccategories) | array | The name of metrics that will be streamed. "allMetrics" includes all possible metrics for the resource. Set to `[]` to disable metric collection. |
| [`name`](#parameter-diagnosticsettingsname) | string | The name of diagnostic setting. |
| [`name`](#parameter-diagnosticsettingsname) | string | The name of the diagnostic setting. |
| [`storageAccountResourceId`](#parameter-diagnosticsettingsstorageaccountresourceid) | string | Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub. |
| [`workspaceResourceId`](#parameter-diagnosticsettingsworkspaceresourceid) | string | Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub. |

Expand Down Expand Up @@ -1288,7 +1289,7 @@ Enable or disable the category explicitly. Default is `true`.

### Parameter: `diagnosticSettings.name`

The name of diagnostic setting.
The name of the diagnostic setting.

- Required: No
- Type: string
Expand Down Expand Up @@ -1613,6 +1614,14 @@ MySQL Server version.
| `resourceGroupName` | string | The resource group of the deployed MySQL Flexible server. |
| `resourceId` | string | The resource ID of the deployed MySQL Flexible server. |

## Cross-referenced modules

This section gives you an overview of all local-referenced module files (i.e., other modules that are referenced in this module) and all remote-referenced files (i.e., Bicep modules that are referenced from a Bicep Registry or Template Specs).

| Reference | Type |
| :-- | :-- |
| `br/public:avm/utl/types/avm-common-types:0.4.0` | Remote reference |

## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the [repository](https://aka.ms/avm/telemetry). There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
4 changes: 2 additions & 2 deletions avm/res/db-for-my-sql/flexible-server/administrator/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "17380647846007156110"
"version": "0.31.92.45157",
"templateHash": "15901602668303039143"
},
"name": "DBforMySQL Flexible Server Administrators",
"description": "This module deploys a DBforMySQL Flexible Server Administrator.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/db-for-my-sql/flexible-server/database/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "15491679806037869848"
"version": "0.31.92.45157",
"templateHash": "8816099454149448745"
},
"name": "DBforMySQL Flexible Server Databases",
"description": "This module deploys a DBforMySQL Flexible Server Database.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/db-for-my-sql/flexible-server/firewall-rule/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "10498063087675421166"
"version": "0.31.92.45157",
"templateHash": "10309431502079210011"
},
"name": "DBforMySQL Flexible Server Firewall Rules",
"description": "This module deploys a DBforMySQL Flexible Server Firewall Rule.",
Expand Down
118 changes: 11 additions & 107 deletions avm/res/db-for-my-sql/flexible-server/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ metadata owner = 'Azure/module-maintainers'
@description('Required. The name of the MySQL flexible server.')
param name string

import { lockType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
@description('Optional. The lock settings of the service.')
param lock lockType
param lock lockType?

@description('Optional. Location for all resources.')
param location string = resourceGroup().location
Expand Down Expand Up @@ -68,14 +69,16 @@ param geoRedundantBackup string = 'Enabled'
@description('Optional. The mode to create a new MySQL server.')
param createMode string = 'Default'

import { managedIdentityOnlyUserAssignedType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
@description('Conditional. The managed identity definition for this resource. Required if \'customerManagedKey\' is not empty.')
param managedIdentities managedIdentitiesType
param managedIdentities managedIdentityOnlyUserAssignedType?

import { customerManagedKeyType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
@description('Optional. The customer managed key definition to use for the managed service.')
param customerManagedKey customerManagedKeyType
param customerManagedKey customerManagedKeyType?

@description('Optional. The customer managed key definition to use when geoRedundantBackup is "Enabled".')
param customerManagedKeyGeo customerManagedKeyType
param customerManagedKeyGeo customerManagedKeyType?

@allowed([
'Disabled'
Expand Down Expand Up @@ -156,11 +159,13 @@ param databases array = []
@description('Optional. The firewall rules to create in the MySQL flexible server.')
param firewallRules array = []

import { roleAssignmentType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
@description('Optional. Array of role assignments to create.')
param roleAssignments roleAssignmentType
param roleAssignments roleAssignmentType[]?

import { diagnosticSettingFullType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
@description('Optional. The diagnostic settings of the service.')
param diagnosticSettings diagnosticSettingType
param diagnosticSettings diagnosticSettingFullType[]?

@description('Optional. Enable/Disable usage telemetry for module.')
param enableTelemetry bool = true
Expand Down Expand Up @@ -445,104 +450,3 @@ output location string = flexibleServer.location

@description('The FQDN of the MySQL Flexible server.')
output fqdn string = flexibleServer.properties.fullyQualifiedDomainName

// =============== //
// Definitions //
// =============== //

type managedIdentitiesType = {
@description('Optional. The resource ID(s) to assign to the resource.')
userAssignedResourceIds: string[]
}?

type lockType = {
@description('Optional. Specify the name of lock.')
name: string?

@description('Optional. Specify the type of lock.')
kind: ('CanNotDelete' | 'ReadOnly' | 'None')?
}?

type roleAssignmentType = {
@description('Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated.')
name: string?

@description('Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.')
roleDefinitionIdOrName: string

@description('Required. The principal ID of the principal (user/group/identity) to assign the role to.')
principalId: string

@description('Optional. The principal type of the assigned principal ID.')
principalType: ('ServicePrincipal' | 'Group' | 'User' | 'ForeignGroup' | 'Device')?

@description('Optional. The description of the role assignment.')
description: string?

@description('Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase "foo_storage_container".')
condition: string?

@description('Optional. Version of the condition.')
conditionVersion: '2.0'?

@description('Optional. The Resource Id of the delegated managed identity resource.')
delegatedManagedIdentityResourceId: string?
}[]?

type diagnosticSettingType = {
@description('Optional. The name of diagnostic setting.')
name: string?

@description('Optional. The name of logs that will be streamed. "allLogs" includes all possible logs for the resource. Set to `[]` to disable log collection.')
logCategoriesAndGroups: {
@description('Optional. Name of a Diagnostic Log category for a resource type this setting is applied to. Set the specific logs to collect here.')
category: string?

@description('Optional. Name of a Diagnostic Log category group for a resource type this setting is applied to. Set to `allLogs` to collect all logs.')
categoryGroup: string?

@description('Optional. Enable or disable the category explicitly. Default is `true`.')
enabled: bool?
}[]?

@description('Optional. The name of metrics that will be streamed. "allMetrics" includes all possible metrics for the resource. Set to `[]` to disable metric collection.')
metricCategories: {
@description('Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics.')
category: string

@description('Optional. Enable or disable the category explicitly. Default is `true`.')
enabled: bool?
}[]?

@description('Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type.')
logAnalyticsDestinationType: ('Dedicated' | 'AzureDiagnostics')?

@description('Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub.')
workspaceResourceId: string?

@description('Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub.')
storageAccountResourceId: string?

@description('Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to.')
eventHubAuthorizationRuleResourceId: string?

@description('Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub.')
eventHubName: string?

@description('Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs.')
marketplacePartnerResourceId: string?
}[]?

type customerManagedKeyType = {
@description('Required. The resource ID of a key vault to reference a customer managed key for encryption from.')
keyVaultResourceId: string

@description('Required. The name of the customer managed key to use for encryption.')
keyName: string

@description('Optional. The version of the customer managed key to reference for encryption. If not provided, using \'latest\'.')
keyVersion: string?

@description('Required. User assigned identity to use when fetching the customer managed key.')
userAssignedIdentityResourceId: string
}?
Loading

0 comments on commit f6347ba

Please sign in to comment.