@gradientedge/cdk-utils 9.41.3 → 9.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  export * from './constants';
2
2
  export * from './construct';
3
+ export * from './resource-name-formatter';
3
4
  export * from './stack';
4
5
  export * from './types';
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants"), exports);
18
18
  __exportStar(require("./construct"), exports);
19
+ __exportStar(require("./resource-name-formatter"), exports);
19
20
  __exportStar(require("./stack"), exports);
20
21
  __exportStar(require("./types"), exports);
@@ -3,8 +3,9 @@ import { ApiManagementBackend } from '@cdktf/provider-azurerm/lib/api-management
3
3
  import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management';
4
4
  import { ApiManagementApi } from '@cdktf/provider-azurerm/lib/api-management-api';
5
5
  import { ApiManagementLoggerApplicationInsights } from '@cdktf/provider-azurerm/lib/api-management-logger';
6
+ import { Resource } from '../../.gen/providers/azapi/resource';
6
7
  import { CommonAzureConstruct } from '../../common';
7
- import { ApiManagementProps, ApiManagementBackendProps, ApiManagementApiProps } from './types';
8
+ import { ApiManagementProps, ApiManagementBackendProps, ApiManagementApiProps, ApiManagementV2Props } from './types';
8
9
  /**
9
10
  * @classdesc Provides operations on Azure Api Management
10
11
  * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
@@ -39,6 +40,14 @@ export declare class AzureApiManagementManager {
39
40
  * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
40
41
  */
41
42
  resolveApiManagement(id: string, scope: CommonAzureConstruct, props: DataAzurermApiManagementConfig): DataAzurermApiManagement;
43
+ /**
44
+ * @summary Method to create a new api management
45
+ * @param id scoped id of the resource
46
+ * @param scope scope in which this resource is defined
47
+ * @param props api management properties
48
+ * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
49
+ */
50
+ createApiManagementv2(id: string, scope: CommonAzureConstruct, props: ApiManagementV2Props, applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey']): Resource;
42
51
  /**
43
52
  * @summary Method to create a new api management backend
44
53
  * @param id scoped id of the resource
@@ -12,6 +12,7 @@ const api_management_api_1 = require("@cdktf/provider-azurerm/lib/api-management
12
12
  const api_management_api_operation_1 = require("@cdktf/provider-azurerm/lib/api-management-api-operation");
13
13
  const api_management_api_operation_policy_1 = require("@cdktf/provider-azurerm/lib/api-management-api-operation-policy");
14
14
  const api_management_logger_1 = require("@cdktf/provider-azurerm/lib/api-management-logger");
15
+ const resource_1 = require("../../.gen/providers/azapi/resource");
15
16
  const utils_1 = require("../../utils");
16
17
  const lodash_1 = __importDefault(require("lodash"));
17
18
  /**
@@ -43,7 +44,9 @@ class AzureApiManagementManager {
43
44
  if (!props)
44
45
  throw `Props undefined for ${id}`;
45
46
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
46
- name: scope.props.resourceGroupName || props.resourceGroupName,
47
+ name: scope.props.resourceGroupName
48
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
49
+ : `${props.resourceGroupName}`,
47
50
  });
48
51
  if (!resourceGroup)
49
52
  throw `Resource group undefined for ${id}`;
@@ -81,7 +84,9 @@ class AzureApiManagementManager {
81
84
  if (!props)
82
85
  throw `Props undefined for ${id}`;
83
86
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
84
- name: scope.props.resourceGroupName || props.resourceGroupName,
87
+ name: scope.props.resourceGroupName
88
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
89
+ : `${props.resourceGroupName}`,
85
90
  });
86
91
  if (!resourceGroup)
87
92
  throw `Resource group undefined for ${id}`;
@@ -94,6 +99,66 @@ class AzureApiManagementManager {
94
99
  });
95
100
  return apiManagement;
96
101
  }
102
+ /**
103
+ * @summary Method to create a new api management
104
+ * @param id scoped id of the resource
105
+ * @param scope scope in which this resource is defined
106
+ * @param props api management properties
107
+ * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
108
+ */
109
+ createApiManagementv2(id, scope, props, applicationInsightsKey) {
110
+ if (!props)
111
+ throw `Props undefined for ${id}`;
112
+ const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
113
+ name: scope.props.resourceGroupName
114
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
115
+ : `${props.resourceGroupName}`,
116
+ });
117
+ if (!resourceGroup)
118
+ throw `Resource group undefined for ${id}`;
119
+ const apiManagement = new resource_1.Resource(scope, `${id}-am`, {
120
+ type: 'Microsoft.ApiManagement/service@2024-05-01',
121
+ name: scope.resourceNameFormatter.format(props.name),
122
+ location: resourceGroup.location,
123
+ parentId: resourceGroup.id,
124
+ body: {
125
+ properties: {
126
+ apiVersionConstraint: {
127
+ minApiVersion: '2019-12-01',
128
+ },
129
+ publisherName: props.publisherName,
130
+ publisherEmail: props.publisherEmail,
131
+ },
132
+ sku: {
133
+ capacity: 1,
134
+ name: props.skuName,
135
+ },
136
+ },
137
+ responseExportValues: ['properties.gatewayUrl'],
138
+ identity: [
139
+ {
140
+ type: 'SystemAssigned',
141
+ },
142
+ ],
143
+ ignoreMissingProperty: true,
144
+ ignoreCasing: true,
145
+ schemaValidationEnabled: false,
146
+ });
147
+ if (applicationInsightsKey) {
148
+ new api_management_logger_1.ApiManagementLogger(scope, `${id}-am-logger`, {
149
+ name: scope.resourceNameFormatter.format(props.name),
150
+ resourceGroupName: resourceGroup.name,
151
+ apiManagementName: apiManagement.name,
152
+ applicationInsights: {
153
+ instrumentationKey: applicationInsightsKey,
154
+ },
155
+ });
156
+ }
157
+ (0, utils_1.createAzureTfOutput)(`${id}-apiManagementName`, scope, apiManagement.name);
158
+ (0, utils_1.createAzureTfOutput)(`${id}-apiManagementFriendlyUniqueId`, scope, apiManagement.friendlyUniqueId);
159
+ (0, utils_1.createAzureTfOutput)(`${id}-apiManagementId`, scope, apiManagement.id);
160
+ return apiManagement;
161
+ }
97
162
  /**
98
163
  * @summary Method to create a new api management backend
99
164
  * @param id scoped id of the resource
@@ -11,3 +11,6 @@ export interface ApiManagementApiProps extends ApiManagementApiConfig {
11
11
  operations: ApiManagementApiOperationConfig[];
12
12
  policyXmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent'];
13
13
  }
14
+ export interface ApiManagementV2Props extends ApiManagementConfig {
15
+ body: any;
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.41.3",
3
+ "version": "9.42.1",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -1,4 +1,5 @@
1
1
  export * from './constants'
2
2
  export * from './construct'
3
+ export * from './resource-name-formatter'
3
4
  export * from './stack'
4
5
  export * from './types'
@@ -3,6 +3,7 @@ import {
3
3
  DataAzurermApiManagement,
4
4
  DataAzurermApiManagementConfig,
5
5
  } from '@cdktf/provider-azurerm/lib/data-azurerm-api-management'
6
+
6
7
  import { ApiManagementBackend } from '@cdktf/provider-azurerm/lib/api-management-backend'
7
8
  import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management'
8
9
  import { ApiManagementApi } from '@cdktf/provider-azurerm/lib/api-management-api'
@@ -12,9 +13,10 @@ import {
12
13
  ApiManagementLogger,
13
14
  ApiManagementLoggerApplicationInsights,
14
15
  } from '@cdktf/provider-azurerm/lib/api-management-logger'
16
+ import { Resource } from '../../.gen/providers/azapi/resource'
15
17
  import { CommonAzureConstruct } from '../../common'
16
18
  import { createAzureTfOutput } from '../../utils'
17
- import { ApiManagementProps, ApiManagementBackendProps, ApiManagementApiProps } from './types'
19
+ import { ApiManagementProps, ApiManagementBackendProps, ApiManagementApiProps, ApiManagementV2Props } from './types'
18
20
  import _ from 'lodash'
19
21
 
20
22
  /**
@@ -51,7 +53,9 @@ export class AzureApiManagementManager {
51
53
  if (!props) throw `Props undefined for ${id}`
52
54
 
53
55
  const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
54
- name: scope.props.resourceGroupName || props.resourceGroupName,
56
+ name: scope.props.resourceGroupName
57
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
58
+ : `${props.resourceGroupName}`,
55
59
  })
56
60
 
57
61
  if (!resourceGroup) throw `Resource group undefined for ${id}`
@@ -94,7 +98,9 @@ export class AzureApiManagementManager {
94
98
  if (!props) throw `Props undefined for ${id}`
95
99
 
96
100
  const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
97
- name: scope.props.resourceGroupName || props.resourceGroupName,
101
+ name: scope.props.resourceGroupName
102
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
103
+ : `${props.resourceGroupName}`,
98
104
  })
99
105
 
100
106
  if (!resourceGroup) throw `Resource group undefined for ${id}`
@@ -110,6 +116,80 @@ export class AzureApiManagementManager {
110
116
  return apiManagement
111
117
  }
112
118
 
119
+ /**
120
+ * @summary Method to create a new api management
121
+ * @param id scoped id of the resource
122
+ * @param scope scope in which this resource is defined
123
+ * @param props api management properties
124
+ * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
125
+ */
126
+ public createApiManagementv2(
127
+ id: string,
128
+ scope: CommonAzureConstruct,
129
+ props: ApiManagementV2Props,
130
+ applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey']
131
+ ) {
132
+ if (!props) throw `Props undefined for ${id}`
133
+
134
+ const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
135
+ name: scope.props.resourceGroupName
136
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
137
+ : `${props.resourceGroupName}`,
138
+ })
139
+
140
+ if (!resourceGroup) throw `Resource group undefined for ${id}`
141
+
142
+ const apiManagement = new Resource(scope, `${id}-am`, {
143
+ type: 'Microsoft.ApiManagement/service@2024-05-01',
144
+ name: scope.resourceNameFormatter.format(props.name),
145
+ location: resourceGroup.location,
146
+ parentId: resourceGroup.id,
147
+
148
+ body: {
149
+ properties: {
150
+ apiVersionConstraint: {
151
+ minApiVersion: '2019-12-01',
152
+ },
153
+ publisherName: props.publisherName,
154
+ publisherEmail: props.publisherEmail,
155
+ },
156
+ sku: {
157
+ capacity: 1,
158
+ name: props.skuName,
159
+ },
160
+ },
161
+
162
+ responseExportValues: ['properties.gatewayUrl'],
163
+
164
+ identity: [
165
+ {
166
+ type: 'SystemAssigned',
167
+ },
168
+ ],
169
+
170
+ ignoreMissingProperty: true,
171
+ ignoreCasing: true,
172
+ schemaValidationEnabled: false,
173
+ })
174
+
175
+ if (applicationInsightsKey) {
176
+ new ApiManagementLogger(scope, `${id}-am-logger`, {
177
+ name: scope.resourceNameFormatter.format(props.name),
178
+ resourceGroupName: resourceGroup.name,
179
+ apiManagementName: apiManagement.name,
180
+ applicationInsights: {
181
+ instrumentationKey: applicationInsightsKey,
182
+ },
183
+ })
184
+ }
185
+
186
+ createAzureTfOutput(`${id}-apiManagementName`, scope, apiManagement.name)
187
+ createAzureTfOutput(`${id}-apiManagementFriendlyUniqueId`, scope, apiManagement.friendlyUniqueId)
188
+ createAzureTfOutput(`${id}-apiManagementId`, scope, apiManagement.id)
189
+
190
+ return apiManagement
191
+ }
192
+
113
193
  /**
114
194
  * @summary Method to create a new api management backend
115
195
  * @param id scoped id of the resource
@@ -12,3 +12,7 @@ export interface ApiManagementApiProps extends ApiManagementApiConfig {
12
12
  operations: ApiManagementApiOperationConfig[]
13
13
  policyXmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent']
14
14
  }
15
+
16
+ export interface ApiManagementV2Props extends ApiManagementConfig {
17
+ body: any
18
+ }