Skip to content

Commit 3baf77f

Browse files
author
Robert Lacher
committed
Added workspace and gateway modules
1 parent 121a33c commit 3baf77f

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
@description('The name of the API Management Workspace. Defaults to "<apimName>-workspace".')
18+
param apimWorkspaceName string = '${apimName}-workspace'
19+
@description('The description of the API Management Workspace. Defaults to "API Management Workspace for <apimName>".')
20+
param apimWorkspaceDescription string = 'API Management Workspace for ${apimName}'
21+
@description('The display name of the API Management Workspace. Defaults to "<apimName> Workspace".')
22+
param apimWorkspaceDisplayName string = '${apimName} Workspace'
23+
24+
// ------------------------------
25+
// VARIABLES
26+
// ------------------------------
27+
var apimWorkspaceGatewayNetworkConfig = 'config'
28+
29+
// ------------------------------
30+
// RESOURCES
31+
// ------------------------------
32+
33+
34+
resource apimService 'Microsoft.ApiManagement/service@2021-08-01' existing = {
35+
name: apimName
36+
}
37+
38+
resource apimWorkspace 'Microsoft.ApiManagement/service/workspaces@2024-06-01-preview' = {
39+
parent: apimService
40+
name: apimWorkspaceName
41+
properties: {
42+
description: apimWorkspaceDescription
43+
displayName: apimWorkspaceDisplayName
44+
}
45+
}
46+
47+
48+
// ------------------------------
49+
// OUTPUTS
50+
// ------------------------------
51+

0 commit comments

Comments
 (0)