@gradientedge/cdk-utils 9.35.0 → 9.37.0

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.
Files changed (45) hide show
  1. package/dist/src/lib/azure/.gen/providers/azapi/provider/index.d.ts +414 -0
  2. package/dist/src/lib/azure/.gen/providers/azapi/provider/index.js +884 -0
  3. package/dist/src/lib/azure/.gen/providers/azapi/resource/index.d.ts +639 -0
  4. package/dist/src/lib/azure/.gen/providers/azapi/resource/index.js +1177 -0
  5. package/dist/src/lib/azure/common/construct.d.ts +2 -1
  6. package/dist/src/lib/azure/common/construct.js +4 -0
  7. package/dist/src/lib/azure/services/api-management/main.js +14 -13
  8. package/dist/src/lib/azure/services/api-management/types.d.ts +1 -1
  9. package/dist/src/lib/azure/services/cosmosdb/index.d.ts +2 -0
  10. package/dist/src/lib/azure/services/cosmosdb/index.js +18 -0
  11. package/dist/src/lib/azure/services/cosmosdb/main.d.ts +48 -0
  12. package/dist/src/lib/azure/services/cosmosdb/main.js +113 -0
  13. package/dist/src/lib/azure/services/cosmosdb/types.d.ts +12 -0
  14. package/dist/src/lib/azure/services/cosmosdb/types.js +2 -0
  15. package/dist/src/lib/azure/services/function/main.d.ts +10 -2
  16. package/dist/src/lib/azure/services/function/main.js +79 -1
  17. package/dist/src/lib/azure/services/function/types.d.ts +18 -0
  18. package/dist/src/lib/azure/services/index.d.ts +1 -0
  19. package/dist/src/lib/azure/services/index.js +1 -0
  20. package/dist/src/lib/azure/services/storage/main.js +5 -3
  21. package/package.json +1 -1
  22. package/src/lib/azure/.gen/constraints.json +6 -0
  23. package/src/lib/azure/.gen/providers/azapi/data-azapi-client-config/index.ts +257 -0
  24. package/src/lib/azure/.gen/providers/azapi/data-azapi-resource/index.ts +876 -0
  25. package/src/lib/azure/.gen/providers/azapi/data-azapi-resource-action/index.ts +779 -0
  26. package/src/lib/azure/.gen/providers/azapi/data-azapi-resource-id/index.ts +383 -0
  27. package/src/lib/azure/.gen/providers/azapi/data-azapi-resource-list/index.ts +713 -0
  28. package/src/lib/azure/.gen/providers/azapi/data-plane-resource/index.ts +1203 -0
  29. package/src/lib/azure/.gen/providers/azapi/index.ts +11 -0
  30. package/src/lib/azure/.gen/providers/azapi/lazy-index.ts +51 -0
  31. package/src/lib/azure/.gen/providers/azapi/provider/index.ts +1121 -0
  32. package/src/lib/azure/.gen/providers/azapi/resource/index.ts +1516 -0
  33. package/src/lib/azure/.gen/providers/azapi/resource-action/index.ts +935 -0
  34. package/src/lib/azure/.gen/providers/azapi/update-resource/index.ts +1042 -0
  35. package/src/lib/azure/.gen/versions.json +3 -0
  36. package/src/lib/azure/common/construct.ts +5 -0
  37. package/src/lib/azure/services/api-management/main.ts +28 -27
  38. package/src/lib/azure/services/api-management/types.ts +1 -1
  39. package/src/lib/azure/services/cosmosdb/index.ts +2 -0
  40. package/src/lib/azure/services/cosmosdb/main.ts +124 -0
  41. package/src/lib/azure/services/cosmosdb/types.ts +9 -0
  42. package/src/lib/azure/services/function/main.ts +95 -2
  43. package/src/lib/azure/services/function/types.ts +20 -1
  44. package/src/lib/azure/services/index.ts +1 -0
  45. package/src/lib/azure/services/storage/main.ts +5 -3
@@ -1,6 +1,6 @@
1
1
  import { TerraformStack } from 'cdktf';
2
2
  import { Construct } from 'constructs';
3
- import { AzureStorageManager, AzureKeyVaultManager, AzureApiManagementManager, AzureFunctionManager, AzureResourceGroupManager, AzureAppServiceManager, AzureApplicationInsightsManager, AzureAppConfigurationManager } from '../services';
3
+ import { AzureStorageManager, AzureKeyVaultManager, AzureApiManagementManager, AzureFunctionManager, AzureResourceGroupManager, AzureAppServiceManager, AzureApplicationInsightsManager, AzureAppConfigurationManager, AzureCosmosDbManager } from '../services';
4
4
  import { CommonAzureStackProps } from './types';
5
5
  export declare class CommonAzureConstruct extends TerraformStack {
6
6
  props: CommonAzureStackProps;
@@ -11,6 +11,7 @@ export declare class CommonAzureConstruct extends TerraformStack {
11
11
  appServiceManager: AzureAppServiceManager;
12
12
  applicationInsightsManager: AzureApplicationInsightsManager;
13
13
  appConfigurationManager: AzureAppConfigurationManager;
14
+ cosmosDbManager: AzureCosmosDbManager;
14
15
  functiontManager: AzureFunctionManager;
15
16
  keyVaultManager: AzureKeyVaultManager;
16
17
  resourceGroupManager: AzureResourceGroupManager;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommonAzureConstruct = void 0;
4
4
  const provider_1 = require("@cdktf/provider-azurerm/lib/provider");
5
+ const provider_2 = require("../.gen/providers/azapi/provider");
5
6
  const data_azurerm_client_config_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-client-config");
6
7
  const cdktf_1 = require("cdktf");
7
8
  const common_1 = require("../../common");
@@ -15,6 +16,7 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
15
16
  appServiceManager;
16
17
  applicationInsightsManager;
17
18
  appConfigurationManager;
19
+ cosmosDbManager;
18
20
  functiontManager;
19
21
  keyVaultManager;
20
22
  resourceGroupManager;
@@ -27,6 +29,7 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
27
29
  this.appServiceManager = new services_1.AzureAppServiceManager();
28
30
  this.applicationInsightsManager = new services_1.AzureApplicationInsightsManager();
29
31
  this.appConfigurationManager = new services_1.AzureAppConfigurationManager();
32
+ this.cosmosDbManager = new services_1.AzureCosmosDbManager();
30
33
  this.functiontManager = new services_1.AzureFunctionManager();
31
34
  this.keyVaultManager = new services_1.AzureKeyVaultManager();
32
35
  this.resourceGroupManager = new services_1.AzureResourceGroupManager();
@@ -35,6 +38,7 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
35
38
  this.determineRemoteBackend();
36
39
  this.determineTenantId();
37
40
  new provider_1.AzurermProvider(this, `${this.id}-provider`, this.props);
41
+ new provider_2.AzapiProvider(this, `${this.id}-azapi-provider`, this.props);
38
42
  }
39
43
  /**
40
44
  * @summary Determine the fully qualified domain name based on domainName & subDomain
@@ -135,8 +135,10 @@ class AzureApiManagementManager {
135
135
  displayName: props.displayName || props.name,
136
136
  revision: props.revision || '1',
137
137
  protocols: props.protocols || ['https'],
138
- subscriptionRequired: props.subscriptionRequired || true,
139
138
  });
139
+ (0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiName`, scope, apiManagementApi.name);
140
+ (0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId);
141
+ (0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiId`, scope, apiManagementApi.id);
140
142
  lodash_1.default.forEach(props.operations, operation => {
141
143
  const apimOperation = new api_management_api_operation_1.ApiManagementApiOperation(scope, `${id}-apim-api-operation-${operation.path}-${operation.method}`, {
142
144
  operationId: `${operation.path}-${operation.method}`,
@@ -147,22 +149,21 @@ class AzureApiManagementManager {
147
149
  displayName: `/${operation.path}`,
148
150
  urlTemplate: `/${operation.path}`,
149
151
  });
150
- const apimOperationPolicy = new api_management_api_operation_policy_1.ApiManagementApiOperationPolicy(scope, `${id}-apim-api-operation-policy-${operation.path}-${operation.method}`, {
151
- apiManagementName: apiManagementApi.apiManagementName,
152
- resourceGroupName: apiManagementApi.resourceGroupName,
153
- apiName: apiManagementApi.name,
154
- operationId: apimOperation.operationId,
155
- xmlContent: operation.xmlContent,
156
- });
157
152
  (0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationOperationId`, scope, apimOperation.operationId);
158
153
  (0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationFriendlyUniqueId`, scope, apimOperation.friendlyUniqueId);
159
154
  (0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationId`, scope, apimOperation.id);
160
- (0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationPolicyFriendlyUniqueId`, scope, apimOperationPolicy.friendlyUniqueId);
161
- (0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationPolicyId`, scope, apimOperationPolicy.id);
155
+ if (props.policyXmlContent) {
156
+ const apimOperationPolicy = new api_management_api_operation_policy_1.ApiManagementApiOperationPolicy(scope, `${id}-apim-api-operation-policy-${operation.path}-${operation.method}`, {
157
+ apiManagementName: apiManagementApi.apiManagementName,
158
+ resourceGroupName: apiManagementApi.resourceGroupName,
159
+ apiName: apiManagementApi.name,
160
+ operationId: apimOperation.operationId,
161
+ xmlContent: props.policyXmlContent,
162
+ });
163
+ (0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationPolicyFriendlyUniqueId`, scope, apimOperationPolicy.friendlyUniqueId);
164
+ (0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationPolicyId`, scope, apimOperationPolicy.id);
165
+ }
162
166
  });
163
- (0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiName`, scope, apiManagementApi.name);
164
- (0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId);
165
- (0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiId`, scope, apiManagementApi.id);
166
167
  return apiManagementApi;
167
168
  }
168
169
  }
@@ -9,9 +9,9 @@ export interface ApiManagementBackendProps extends ApiManagementBackendConfig {
9
9
  }
10
10
  export interface ApiManagementApiProps extends ApiManagementApiConfig {
11
11
  operations: OperationsProps[];
12
+ policyXmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent'];
12
13
  }
13
14
  export interface OperationsProps {
14
15
  path: ApiManagementApiOperationConfig['urlTemplate'];
15
16
  method: ApiManagementApiOperationConfig['method'];
16
- xmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent'];
17
17
  }
@@ -0,0 +1,2 @@
1
+ export * from './main';
2
+ export * from './types';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./main"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,48 @@
1
+ import { CosmosdbAccount } from '@cdktf/provider-azurerm/lib/cosmosdb-account';
2
+ import { CosmosdbSqlDatabase } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-database';
3
+ import { CosmosdbSqlContainer } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-container';
4
+ import { CommonAzureConstruct } from '../../common';
5
+ import { CosmosdbAccountProps, CosmosdbSqlContainerProps, CosmosdbSqlDatabaseProps } from './types';
6
+ /**
7
+ * @classdesc Provides operations on Azure CosmosDB
8
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
9
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
10
+ * @example
11
+ * ```
12
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
13
+ *
14
+ * class CustomConstruct extends CommonAzureConstruct {
15
+ * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
16
+ * super(parent, id, props)
17
+ * this.props = props
18
+ * this.CosmosDbManager.createCosmosAccount('MyCosmosDb', this, props)
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ export declare class AzureCosmosDbManager {
24
+ /**
25
+ * @summary Method to create a new cosmosdb account
26
+ * @param id scoped id of the resource
27
+ * @param scope scope in which this resource is defined
28
+ * @param props cosmosdb account properties
29
+ * @see [CDKTF CosmosDb Account Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbAccount.typescript.md}
30
+ */
31
+ createCosmosDbAccount(id: string, scope: CommonAzureConstruct, props: CosmosdbAccountProps): CosmosdbAccount;
32
+ /**
33
+ * @summary Method to create a new cosmosdb database
34
+ * @param id scoped id of the resource
35
+ * @param scope scope in which this resource is defined
36
+ * @param props cosmosdb container properties
37
+ * @see [CDKTF CosmosDb Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbSqlContainer.typescript.md}
38
+ */
39
+ createCosmosDbDatabase(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlDatabaseProps): CosmosdbSqlDatabase;
40
+ /**
41
+ * @summary Method to create a new cosmosdb container
42
+ * @param id scoped id of the resource
43
+ * @param scope scope in which this resource is defined
44
+ * @param props cosmosdb container properties
45
+ * @see [CDKTF CosmosDb Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbSqlContainer.typescript.md}
46
+ */
47
+ createCosmosDbContainer(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlContainerProps): CosmosdbSqlContainer;
48
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AzureCosmosDbManager = void 0;
4
+ const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
5
+ const cosmosdb_account_1 = require("@cdktf/provider-azurerm/lib/cosmosdb-account");
6
+ const cosmosdb_sql_database_1 = require("@cdktf/provider-azurerm/lib/cosmosdb-sql-database");
7
+ const cosmosdb_sql_container_1 = require("@cdktf/provider-azurerm/lib/cosmosdb-sql-container");
8
+ const utils_1 = require("../../utils");
9
+ /**
10
+ * @classdesc Provides operations on Azure CosmosDB
11
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
12
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
13
+ * @example
14
+ * ```
15
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
16
+ *
17
+ * class CustomConstruct extends CommonAzureConstruct {
18
+ * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
19
+ * super(parent, id, props)
20
+ * this.props = props
21
+ * this.CosmosDbManager.createCosmosAccount('MyCosmosDb', this, props)
22
+ * }
23
+ * }
24
+ * ```
25
+ */
26
+ class AzureCosmosDbManager {
27
+ /**
28
+ * @summary Method to create a new cosmosdb account
29
+ * @param id scoped id of the resource
30
+ * @param scope scope in which this resource is defined
31
+ * @param props cosmosdb account properties
32
+ * @see [CDKTF CosmosDb Account Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbAccount.typescript.md}
33
+ */
34
+ createCosmosDbAccount(id, scope, props) {
35
+ if (!props)
36
+ throw `Props undefined for ${id}`;
37
+ const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-ca-rg`, {
38
+ name: scope.props.resourceGroupName
39
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
40
+ : `${props.resourceGroupName}`,
41
+ });
42
+ if (!resourceGroup)
43
+ throw `Resource group undefined for ${id}`;
44
+ const cosmosdbAccount = new cosmosdb_account_1.CosmosdbAccount(scope, `${id}-ca`, {
45
+ ...props,
46
+ name: `${props.name}-${scope.props.stage}`,
47
+ location: resourceGroup.location,
48
+ resourceGroupName: resourceGroup.name,
49
+ tags: props.tags ?? {
50
+ environment: scope.props.stage,
51
+ },
52
+ });
53
+ (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbAccountName`, scope, cosmosdbAccount.name);
54
+ (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbAccountFriendlyUniqueId`, scope, cosmosdbAccount.friendlyUniqueId);
55
+ (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbAccountId`, scope, cosmosdbAccount.id);
56
+ return cosmosdbAccount;
57
+ }
58
+ /**
59
+ * @summary Method to create a new cosmosdb database
60
+ * @param id scoped id of the resource
61
+ * @param scope scope in which this resource is defined
62
+ * @param props cosmosdb container properties
63
+ * @see [CDKTF CosmosDb Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbSqlContainer.typescript.md}
64
+ */
65
+ createCosmosDbDatabase(id, scope, props) {
66
+ if (!props)
67
+ throw `Props undefined for ${id}`;
68
+ const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-cd-rg`, {
69
+ name: scope.props.resourceGroupName
70
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
71
+ : `${props.resourceGroupName}`,
72
+ });
73
+ if (!resourceGroup)
74
+ throw `Resource group undefined for ${id}`;
75
+ const cosmosdbDatatbase = new cosmosdb_sql_database_1.CosmosdbSqlDatabase(scope, `${id}-cd`, {
76
+ ...props,
77
+ name: `${props.name}-${scope.props.stage}`,
78
+ resourceGroupName: resourceGroup.name,
79
+ });
80
+ (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbDatatbasetName`, scope, cosmosdbDatatbase.name);
81
+ (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbDatatbaseFriendlyUniqueId`, scope, cosmosdbDatatbase.friendlyUniqueId);
82
+ (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbDatatbaseId`, scope, cosmosdbDatatbase.id);
83
+ return cosmosdbDatatbase;
84
+ }
85
+ /**
86
+ * @summary Method to create a new cosmosdb container
87
+ * @param id scoped id of the resource
88
+ * @param scope scope in which this resource is defined
89
+ * @param props cosmosdb container properties
90
+ * @see [CDKTF CosmosDb Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbSqlContainer.typescript.md}
91
+ */
92
+ createCosmosDbContainer(id, scope, props) {
93
+ if (!props)
94
+ throw `Props undefined for ${id}`;
95
+ const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-cc-rg`, {
96
+ name: scope.props.resourceGroupName
97
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
98
+ : `${props.resourceGroupName}`,
99
+ });
100
+ if (!resourceGroup)
101
+ throw `Resource group undefined for ${id}`;
102
+ const cosmosdbContainer = new cosmosdb_sql_container_1.CosmosdbSqlContainer(scope, `${id}-cc`, {
103
+ ...props,
104
+ name: `${props.name}-${scope.props.stage}`,
105
+ resourceGroupName: resourceGroup.name,
106
+ });
107
+ (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbContainertName`, scope, cosmosdbContainer.name);
108
+ (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbContainerFriendlyUniqueId`, scope, cosmosdbContainer.friendlyUniqueId);
109
+ (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbContainerId`, scope, cosmosdbContainer.id);
110
+ return cosmosdbContainer;
111
+ }
112
+ }
113
+ exports.AzureCosmosDbManager = AzureCosmosDbManager;
@@ -0,0 +1,12 @@
1
+ import { CosmosdbAccountConfig } from '@cdktf/provider-azurerm/lib/cosmosdb-account';
2
+ import { CosmosdbSqlDatabaseConfig } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-database';
3
+ import { CosmosdbSqlContainerConfig } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-container';
4
+ import { CosmosdbTableConfig } from '@cdktf/provider-azurerm/lib/cosmosdb-table';
5
+ export interface CosmosdbAccountProps extends CosmosdbAccountConfig {
6
+ }
7
+ export interface CosmosdbSqlDatabaseProps extends CosmosdbSqlDatabaseConfig {
8
+ }
9
+ export interface CosmosdbSqlContainerProps extends CosmosdbSqlContainerConfig {
10
+ }
11
+ export interface CosmosdbTableProps extends CosmosdbTableConfig {
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,8 @@
1
+ import { DataAzurermLinuxFunctionApp } from '@cdktf/provider-azurerm/lib/data-azurerm-linux-function-app';
1
2
  import { LinuxFunctionApp } from '@cdktf/provider-azurerm/lib/linux-function-app';
2
3
  import { FunctionAppFunction } from '@cdktf/provider-azurerm/lib/function-app-function';
3
4
  import { CommonAzureConstruct } from '../../common';
4
- import { FunctionAppProps, FunctionProps } from './types';
5
+ import { FunctionAppProps, FunctionProps, FunctionAppFlexConsumptionProps } from './types';
5
6
  /**
6
7
  * @classdesc Provides operations on Azure Functions
7
8
  * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
@@ -13,7 +14,7 @@ import { FunctionAppProps, FunctionProps } from './types';
13
14
  * class CustomConstruct extends CommonAzureConstruct {
14
15
  * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
15
16
  * super(parent, id, props)
16
- * this.props = props
17
+ * this.props: props
17
18
  * this.functionManager.createFunctionApp('MyFunctionApp', this, props)
18
19
  * }
19
20
  * }
@@ -36,4 +37,11 @@ export declare class AzureFunctionManager {
36
37
  * @see [CDKTF Function Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/functionAppFunction.typescript.md}
37
38
  */
38
39
  createFunction(id: string, scope: CommonAzureConstruct, props: FunctionProps): FunctionAppFunction;
40
+ /**
41
+ * @summary Method to create a new flex consumption function app
42
+ * @param id scoped id of the resource
43
+ * @param scope scope in which this resource is defined
44
+ * @param props flex consumption function app properties
45
+ */
46
+ createFunctionAppFlexConsumption(id: string, scope: CommonAzureConstruct, props: FunctionAppFlexConsumptionProps): DataAzurermLinuxFunctionApp;
39
47
  }
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AzureFunctionManager = void 0;
4
4
  const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
5
+ const data_azurerm_linux_function_app_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-linux-function-app");
5
6
  const linux_function_app_1 = require("@cdktf/provider-azurerm/lib/linux-function-app");
6
7
  const function_app_function_1 = require("@cdktf/provider-azurerm/lib/function-app-function");
8
+ const resource_1 = require("../../.gen/providers/azapi/resource");
7
9
  const utils_1 = require("../../utils");
8
10
  /**
9
11
  * @classdesc Provides operations on Azure Functions
@@ -16,7 +18,7 @@ const utils_1 = require("../../utils");
16
18
  * class CustomConstruct extends CommonAzureConstruct {
17
19
  * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
18
20
  * super(parent, id, props)
19
- * this.props = props
21
+ * this.props: props
20
22
  * this.functionManager.createFunctionApp('MyFunctionApp', this, props)
21
23
  * }
22
24
  * }
@@ -73,5 +75,81 @@ class AzureFunctionManager {
73
75
  (0, utils_1.createAzureTfOutput)(`${id}-functionId`, scope, functionAppFunction.id);
74
76
  return functionAppFunction;
75
77
  }
78
+ /**
79
+ * @summary Method to create a new flex consumption function app
80
+ * @param id scoped id of the resource
81
+ * @param scope scope in which this resource is defined
82
+ * @param props flex consumption function app properties
83
+ */
84
+ createFunctionAppFlexConsumption(id, scope, props) {
85
+ if (!props)
86
+ throw `Props undefined for ${id}`;
87
+ const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-fa-rg`, {
88
+ name: scope.props.resourceGroupName
89
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
90
+ : `${props.resourceGroupName}`,
91
+ });
92
+ if (!resourceGroup)
93
+ throw `Resource group undefined for ${id}`;
94
+ const functionApp = new resource_1.Resource(scope, `${id}-fa`, {
95
+ type: 'Microsoft.Web/sites@2023-12-01',
96
+ name: `${props.name}-${scope.props.stage}`,
97
+ location: resourceGroup.location,
98
+ parentId: resourceGroup.id,
99
+ body: {
100
+ kind: props.kind || 'functionapp,linux',
101
+ properties: {
102
+ serverFarmId: props.appServicePlanId,
103
+ httpsOnly: props.httpsOnly || true,
104
+ functionAppConfig: {
105
+ deployment: {
106
+ storage: {
107
+ type: props.deploymentStorageType || 'blobContainer',
108
+ value: `${props.blobEndpoint}${props.containerName}`,
109
+ authentication: {
110
+ type: props.deploymentAuthenticationType || 'StorageAccountConnectionString',
111
+ storageAccountConnectionStringName: props.storageAccountConnectionStringName || 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
112
+ },
113
+ },
114
+ },
115
+ runtime: {
116
+ name: props.runtime || 'node',
117
+ version: props.runtimeVersion || '20',
118
+ },
119
+ scaleAndConcurrency: {
120
+ instanceMemoryMB: props.instanceMemory || 2048,
121
+ maximumInstanceCount: props.maximumInstanceCount || 40,
122
+ triggers: {},
123
+ },
124
+ },
125
+ siteConfig: {
126
+ appSettings: props.appSettings.concat([
127
+ {
128
+ name: 'FUNCTIONS_EXTENSION_VERSION',
129
+ value: '~4',
130
+ },
131
+ {
132
+ name: 'AzureWebJobsStorage',
133
+ value: props.storageConnectionString,
134
+ },
135
+ {
136
+ name: 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
137
+ value: props.storageConnectionString,
138
+ },
139
+ ]),
140
+ },
141
+ },
142
+ },
143
+ identity: [{ type: 'SystemAssigned' }],
144
+ ignoreMissingProperty: true,
145
+ ignoreCasing: true,
146
+ schemaValidationEnabled: false,
147
+ });
148
+ const functionAppFlexConsumption = new data_azurerm_linux_function_app_1.DataAzurermLinuxFunctionApp(scope, `${id}-fa-flex`, {
149
+ name: functionApp.name,
150
+ resourceGroupName: resourceGroup.name,
151
+ });
152
+ return functionAppFlexConsumption;
153
+ }
76
154
  }
77
155
  exports.AzureFunctionManager = AzureFunctionManager;
@@ -4,3 +4,21 @@ export interface FunctionAppProps extends LinuxFunctionAppConfig {
4
4
  }
5
5
  export interface FunctionProps extends FunctionAppFunctionConfig {
6
6
  }
7
+ export interface FunctionAppFlexConsumptionProps {
8
+ appServicePlanId: string;
9
+ appSettings: any;
10
+ blobEndpoint: string;
11
+ containerName: string;
12
+ deploymentAuthenticationType?: string;
13
+ deploymentStorageType?: string;
14
+ httpsOnly?: string;
15
+ instanceMemory?: number;
16
+ kind?: string;
17
+ maximumInstanceCount?: number;
18
+ name: string;
19
+ resourceGroupName: string;
20
+ runtime?: string;
21
+ runtimeVersion?: string;
22
+ storageAccountConnectionStringName?: string;
23
+ storageConnectionString: string;
24
+ }
@@ -2,6 +2,7 @@ export * from './api-management';
2
2
  export * from './app-configuration';
3
3
  export * from './app-service';
4
4
  export * from './application-insights';
5
+ export * from './cosmosdb';
5
6
  export * from './function';
6
7
  export * from './key-vault';
7
8
  export * from './resource-group';
@@ -18,6 +18,7 @@ __exportStar(require("./api-management"), exports);
18
18
  __exportStar(require("./app-configuration"), exports);
19
19
  __exportStar(require("./app-service"), exports);
20
20
  __exportStar(require("./application-insights"), exports);
21
+ __exportStar(require("./cosmosdb"), exports);
21
22
  __exportStar(require("./function"), exports);
22
23
  __exportStar(require("./key-vault"), exports);
23
24
  __exportStar(require("./resource-group"), exports);
@@ -76,13 +76,14 @@ class AzureStorageManager {
76
76
  if (!resourceGroup)
77
77
  throw `Resource group undefined for ${id}`;
78
78
  const storageAccount = new data_azurerm_storage_account_1.DataAzurermStorageAccount(scope, `${id}-sa`, {
79
- name: `${props.storageAccountName}-${scope.props.stage}`,
79
+ name: `${props.storageAccountName}-${scope.props.stage}`.replace(/\W/g, '').toLowerCase(),
80
80
  resourceGroupName: resourceGroup.name,
81
81
  });
82
82
  const storageContainer = new storage_container_1.StorageContainer(scope, `${id}-sc`, {
83
83
  ...props,
84
84
  name: `${props.name}-${scope.props.stage}`,
85
- storageAccountName: storageAccount.name,
85
+ storageAccountName: undefined, // the `storage_account_name` property has been deprecated in favour of `storage_account_id` and will be removed in version 5.0 of the Provider.
86
+ storageAccountId: storageAccount.id,
86
87
  });
87
88
  (0, utils_1.createAzureTfOutput)(`${id}-storageContainerName`, scope, storageContainer.name);
88
89
  (0, utils_1.createAzureTfOutput)(`${id}-storageContainerFriendlyUniqueId`, scope, storageContainer.friendlyUniqueId);
@@ -112,7 +113,8 @@ class AzureStorageManager {
112
113
  });
113
114
  const storageContainer = new data_azurerm_storage_container_1.DataAzurermStorageContainer(scope, `${id}-sc`, {
114
115
  name: `${props.storageContainerName}-${scope.props.stage}`,
115
- storageAccountName: storageAccount.name,
116
+ storageAccountName: undefined, // the `storage_account_name` property has been deprecated in favour of `storage_account_id` and will be removed in version 5.0 of the Provider.
117
+ storageAccountId: storageAccount.id,
116
118
  });
117
119
  const storageBlob = new storage_blob_1.StorageBlob(scope, `${id}-sb`, {
118
120
  ...props,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.35.0",
3
+ "version": "9.37.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -0,0 +1,6 @@
1
+ {
2
+ "cdktf": "0.20.11",
3
+ "providers": {
4
+ "azapi": "~> 2.2"
5
+ }
6
+ }