Skip to content

Commit

Permalink
remove APIM from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
krbar committed Aug 1, 2024
1 parent d34647b commit 1846a6d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 66 deletions.
24 changes: 6 additions & 18 deletions avm/res/api-management/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
name: 'serviceDeployment'
params: {
// Required parameters
name: 'apismin002'
name: 'apismin001'
publisherEmail: '[email protected]'
publisherName: 'az-amorg-x-001'
// Non-required parameters
Expand All @@ -149,7 +149,7 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
"parameters": {
// Required parameters
"name": {
"value": "apismin002"
"value": "apismin001"
},
"publisherEmail": {
"value": "[email protected]"
Expand Down Expand Up @@ -242,7 +242,7 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
name: 'serviceDeployment'
params: {
// Required parameters
name: 'apismax002'
name: 'apismax001'
publisherEmail: '[email protected]'
publisherName: 'az-amorg-x-001'
// Non-required parameters
Expand Down Expand Up @@ -416,13 +416,11 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
publicIpAddressResourceId: '<publicIpAddressResourceId>'
roleAssignments: [
{
name: '6352c3e3-ac6b-43d5-ac43-1077ff373721'
principalId: '<principalId>'
principalType: 'ServicePrincipal'
roleDefinitionIdOrName: 'Owner'
}
{
name: '<name>'
principalId: '<principalId>'
principalType: 'ServicePrincipal'
roleDefinitionIdOrName: 'b24988ac-6180-42a0-ab88-20f7382dd24c'
Expand Down Expand Up @@ -464,7 +462,7 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
"parameters": {
// Required parameters
"name": {
"value": "apismax002"
"value": "apismax001"
},
"publisherEmail": {
"value": "[email protected]"
Expand Down Expand Up @@ -678,13 +676,11 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
"roleAssignments": {
"value": [
{
"name": "6352c3e3-ac6b-43d5-ac43-1077ff373721",
"principalId": "<principalId>",
"principalType": "ServicePrincipal",
"roleDefinitionIdOrName": "Owner"
},
{
"name": "<name>",
"principalId": "<principalId>",
"principalType": "ServicePrincipal",
"roleDefinitionIdOrName": "b24988ac-6180-42a0-ab88-20f7382dd24c"
Expand Down Expand Up @@ -798,7 +794,7 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
name: 'serviceDeployment'
params: {
// Required parameters
name: 'apiswaf002'
name: 'apiswaf001'
publisherEmail: '[email protected]'
publisherName: 'az-amorg-x-001'
// Non-required parameters
Expand Down Expand Up @@ -998,7 +994,7 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
"parameters": {
// Required parameters
"name": {
"value": "apiswaf002"
"value": "apiswaf001"
},
"publisherEmail": {
"value": "[email protected]"
Expand Down Expand Up @@ -1756,7 +1752,6 @@ Array of role assignments to create.
| [`conditionVersion`](#parameter-roleassignmentsconditionversion) | string | Version of the condition. |
| [`delegatedManagedIdentityResourceId`](#parameter-roleassignmentsdelegatedmanagedidentityresourceid) | string | The Resource Id of the delegated managed identity resource. |
| [`description`](#parameter-roleassignmentsdescription) | string | The description of the role assignment. |
| [`name`](#parameter-roleassignmentsname) | string | The name (as GUID) of the role assignment. If not provided, a GUID will be generated. |
| [`principalType`](#parameter-roleassignmentsprincipaltype) | string | The principal type of the assigned principal ID. |

### Parameter: `roleAssignments.principalId`
Expand Down Expand Up @@ -1807,13 +1802,6 @@ The description of the role assignment.
- Required: No
- Type: string

### Parameter: `roleAssignments.name`

The name (as GUID) of the role assignment. If not provided, a GUID will be generated.

- Required: No
- Type: string

### Parameter: `roleAssignments.principalType`

The principal type of the assigned principal ID.
Expand Down
24 changes: 7 additions & 17 deletions avm/res/api-management/service/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,6 @@ var builtInRoleNames = {
)
}

var formattedRoleAssignments = [
for (roleAssignment, index) in (roleAssignments ?? []): union(roleAssignment, {
roleDefinitionId: builtInRoleNames[?roleAssignment.roleDefinitionIdOrName] ?? (contains(
roleAssignment.roleDefinitionIdOrName,
'/providers/Microsoft.Authorization/roleDefinitions/'
)
? roleAssignment.roleDefinitionIdOrName
: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleAssignment.roleDefinitionIdOrName))
})
]

#disable-next-line no-deployments-resources
resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableTelemetry) {
name: '46d3xbcp.res.apimanagement-service.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name, location), 0, 4)}'
Expand Down Expand Up @@ -564,10 +553,14 @@ resource service_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-
]

resource service_roleAssignments 'Microsoft.Authorization/roleAssignments@2022-04-01' = [
for (roleAssignment, index) in (formattedRoleAssignments ?? []): {
name: roleAssignment.?name ?? guid(service.id, roleAssignment.principalId, roleAssignment.roleDefinitionId)
for (roleAssignment, index) in (roleAssignments ?? []): {
name: guid(service.id, roleAssignment.principalId, roleAssignment.roleDefinitionIdOrName)
properties: {
roleDefinitionId: roleAssignment.roleDefinitionId
roleDefinitionId: contains(builtInRoleNames, roleAssignment.roleDefinitionIdOrName)
? builtInRoleNames[roleAssignment.roleDefinitionIdOrName]
: contains(roleAssignment.roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/')
? roleAssignment.roleDefinitionIdOrName
: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleAssignment.roleDefinitionIdOrName)
principalId: roleAssignment.principalId
description: roleAssignment.?description
principalType: roleAssignment.?principalType
Expand Down Expand Up @@ -615,9 +608,6 @@ type lockType = {
}?

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

Expand Down
34 changes: 10 additions & 24 deletions avm/res/api-management/service/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "17512486952547559585"
"templateHash": "17801704016046413855"
},
"name": "API Management Services",
"description": "This module deploys an API Management Service. The default deployment is set to use a Premium SKU to align with Microsoft WAF-aligned best practices. In most cases, non-prod deployments should use a lower-tier SKU.",
Expand Down Expand Up @@ -66,13 +66,6 @@
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"nullable": true,
"metadata": {
"description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated."
}
},
"roleDefinitionIdOrName": {
"type": "string",
"metadata": {
Expand Down Expand Up @@ -551,13 +544,6 @@
}
},
"variables": {
"copy": [
{
"name": "formattedRoleAssignments",
"count": "[length(coalesce(parameters('roleAssignments'), createArray()))]",
"input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
}
],
"authorizationServerList": "[if(not(empty(parameters('authorizationServers'))), parameters('authorizationServers').secureList, createArray())]",
"formattedUserAssignedIdentities": "[reduce(map(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createArray()), lambda('id', createObject(format('{0}', lambdaVariables('id')), createObject()))), createObject(), lambda('cur', 'next', union(lambdaVariables('cur'), lambdaVariables('next'))))]",
"identity": "[if(not(empty(parameters('managedIdentities'))), createObject('type', if(coalesce(tryGet(parameters('managedIdentities'), 'systemAssigned'), false()), if(not(empty(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createObject()))), 'SystemAssigned,UserAssigned', 'SystemAssigned'), if(not(empty(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createObject()))), 'UserAssigned', 'None')), 'userAssignedIdentities', if(not(empty(variables('formattedUserAssignedIdentities'))), variables('formattedUserAssignedIdentities'), null())), null())]",
Expand Down Expand Up @@ -681,20 +667,20 @@
"service_roleAssignments": {
"copy": {
"name": "service_roleAssignments",
"count": "[length(coalesce(variables('formattedRoleAssignments'), createArray()))]"
"count": "[length(coalesce(parameters('roleAssignments'), createArray()))]"
},
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2022-04-01",
"scope": "[format('Microsoft.ApiManagement/service/{0}', parameters('name'))]",
"name": "[coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'name'), guid(resourceId('Microsoft.ApiManagement/service', parameters('name')), coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId, coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId))]",
"name": "[guid(resourceId('Microsoft.ApiManagement/service', parameters('name')), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId, coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)]",
"properties": {
"roleDefinitionId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId]",
"principalId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId]",
"description": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'description')]",
"principalType": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'principalType')]",
"condition": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition')]",
"conditionVersion": "[if(not(empty(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
"delegatedManagedIdentityResourceId": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
"roleDefinitionId": "[if(contains(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), variables('builtInRoleNames')[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName], if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]",
"principalId": "[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId]",
"description": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'description')]",
"principalType": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'principalType')]",
"condition": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition')]",
"conditionVersion": "[if(not(empty(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
"delegatedManagedIdentityResourceId": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
},
"dependsOn": [
"service"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module testDeployment '../../../main.bicep' = [
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-test-${serviceShort}-${iteration}'
params: {
name: '${namePrefix}${serviceShort}002'
name: '${namePrefix}${serviceShort}001'
location: resourceLocation
publisherEmail: '[email protected]'
publisherName: '${namePrefix}-az-amorg-x-001'
Expand Down
4 changes: 1 addition & 3 deletions avm/res/api-management/service/tests/e2e/max/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module testDeployment '../../../main.bicep' = [
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-test-${serviceShort}-${iteration}'
params: {
name: '${namePrefix}${serviceShort}002'
name: '${namePrefix}${serviceShort}001'
location: resourceLocation
publisherEmail: '[email protected]'
publisherName: '${namePrefix}-az-amorg-x-001'
Expand Down Expand Up @@ -245,13 +245,11 @@ module testDeployment '../../../main.bicep' = [
]
roleAssignments: [
{
name: '6352c3e3-ac6b-43d5-ac43-1077ff373721'
roleDefinitionIdOrName: 'Owner'
principalId: nestedDependencies.outputs.managedIdentityPrincipalId
principalType: 'ServicePrincipal'
}
{
name: guid('Custom seed ${namePrefix}${serviceShort}')
roleDefinitionIdOrName: 'b24988ac-6180-42a0-ab88-20f7382dd24c'
principalId: nestedDependencies.outputs.managedIdentityPrincipalId
principalType: 'ServicePrincipal'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module testDeployment '../../../main.bicep' = [
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-test-${serviceShort}-${iteration}'
params: {
name: '${namePrefix}${serviceShort}002'
name: '${namePrefix}${serviceShort}001'
location: resourceLocation
publisherEmail: '[email protected]'
publisherName: '${namePrefix}-az-amorg-x-001'
Expand Down
4 changes: 2 additions & 2 deletions avm/res/api-management/service/version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#",
"version": "0.3",
"version": "0.2",
"pathFilters": [
"./main.json"
]
}
}

0 comments on commit 1846a6d

Please sign in to comment.