|
| 1 | +/** |
| 2 | + * @module api-v1 |
| 3 | + * @description This module defines the API resources using Bicep. |
| 4 | + * It includes configurations for creating and managing APIs, products, and policies. |
| 5 | + */ |
| 6 | + |
| 7 | + |
| 8 | +// ------------------------------ |
| 9 | +// PARAMETERS |
| 10 | +// ------------------------------ |
| 11 | + |
| 12 | +@description('The unique suffix to append. Defaults to a unique string based on subscription and resource group IDs.') |
| 13 | +param resourceSuffix string = uniqueString(subscription().id, resourceGroup().id) |
| 14 | + |
| 15 | +@description('The name of the API Management instance. Defaults to "apim-<resourceSuffix>".') |
| 16 | +param apimName string = 'apim-${resourceSuffix}' |
| 17 | + |
| 18 | +@description('The capacity for the Workspace Gateway. Defaults to 1.') |
| 19 | +param apimWorkspaceGatewayCapacity int = 1 |
| 20 | +@description('The SKU for the Workspace Gateway. Defaults to "WorkspaceGatewayPremium".') |
| 21 | +@allowed(['WorkspaceGatewayPremium', 'WorkspaceGatewayStandard', 'Standard']) |
| 22 | +param apimWorkspaceGatewaySku string = 'WorkspaceGatewayPremium' |
| 23 | +@description('The resource id of the subnet for the Workspace Gateway.') |
| 24 | +param apimWorkspaceGatewaySubnetId string |
| 25 | +@description('The type of network for the Workspace Gateway. Defaults to "External".') |
| 26 | +@allowed(['External', 'Internal', 'None']) |
| 27 | +param apimWorkspaceGatewayNetworkType string |
| 28 | +@description('The name of the Workspace Gateway. Defaults to "<apimName>-gateway".') |
| 29 | +param apimWorkspaceGatewayName string = '${apimName}-gateway' |
| 30 | +@description('The name of the API Management Workspace. Defaults to "<apimName>-workspace".') |
| 31 | +param apimWorkspaceName string |
| 32 | + |
| 33 | +// ------------------------------ |
| 34 | +// VARIABLES |
| 35 | +// ------------------------------ |
| 36 | +var apimWorkspaceGatewayNetworkConfig = 'config' |
| 37 | + |
| 38 | +// ------------------------------ |
| 39 | +// RESOURCES |
| 40 | +// ------------------------------ |
| 41 | + |
| 42 | +resource workspaceGateway 'Microsoft.ApiManagement/gateways@2024-06-01-preview' = { |
| 43 | + name: apimWorkspaceGatewayName |
| 44 | + location: resourceGroup().location |
| 45 | + sku: { |
| 46 | + name: apimWorkspaceGatewaySku |
| 47 | + capacity: apimWorkspaceGatewayCapacity |
| 48 | + } |
| 49 | + properties: { |
| 50 | + backend: apimWorkspaceGatewayNetworkType != 'None' ? { |
| 51 | + subnet: { |
| 52 | + id: apimWorkspaceGatewaySubnetId |
| 53 | + } |
| 54 | + } : null |
| 55 | + configurationApi: {} |
| 56 | + frontend: {} |
| 57 | + virtualNetworkType: apimWorkspaceGatewayNetworkType |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +resource workspaceGatewayConfigConnection 'Microsoft.ApiManagement/gateways/configConnections@2024-06-01-preview' = { |
| 62 | + parent: workspaceGateway |
| 63 | + name: apimWorkspaceGatewayNetworkConfig |
| 64 | + properties: { |
| 65 | + sourceId: '${resourceId('Microsoft.ApiManagement/service', apimName)}/workspaces/${apimWorkspaceName}' |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +// ------------------------------ |
| 70 | +// OUTPUTS |
| 71 | +// ------------------------------ |
| 72 | + |
0 commit comments