@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.
- package/dist/src/lib/azure/.gen/providers/azapi/provider/index.d.ts +414 -0
- package/dist/src/lib/azure/.gen/providers/azapi/provider/index.js +884 -0
- package/dist/src/lib/azure/.gen/providers/azapi/resource/index.d.ts +639 -0
- package/dist/src/lib/azure/.gen/providers/azapi/resource/index.js +1177 -0
- package/dist/src/lib/azure/common/construct.d.ts +2 -1
- package/dist/src/lib/azure/common/construct.js +4 -0
- package/dist/src/lib/azure/services/api-management/main.js +14 -13
- package/dist/src/lib/azure/services/api-management/types.d.ts +1 -1
- package/dist/src/lib/azure/services/cosmosdb/index.d.ts +2 -0
- package/dist/src/lib/azure/services/cosmosdb/index.js +18 -0
- package/dist/src/lib/azure/services/cosmosdb/main.d.ts +48 -0
- package/dist/src/lib/azure/services/cosmosdb/main.js +113 -0
- package/dist/src/lib/azure/services/cosmosdb/types.d.ts +12 -0
- package/dist/src/lib/azure/services/cosmosdb/types.js +2 -0
- package/dist/src/lib/azure/services/function/main.d.ts +10 -2
- package/dist/src/lib/azure/services/function/main.js +79 -1
- package/dist/src/lib/azure/services/function/types.d.ts +18 -0
- package/dist/src/lib/azure/services/index.d.ts +1 -0
- package/dist/src/lib/azure/services/index.js +1 -0
- package/dist/src/lib/azure/services/storage/main.js +5 -3
- package/package.json +1 -1
- package/src/lib/azure/.gen/constraints.json +6 -0
- package/src/lib/azure/.gen/providers/azapi/data-azapi-client-config/index.ts +257 -0
- package/src/lib/azure/.gen/providers/azapi/data-azapi-resource/index.ts +876 -0
- package/src/lib/azure/.gen/providers/azapi/data-azapi-resource-action/index.ts +779 -0
- package/src/lib/azure/.gen/providers/azapi/data-azapi-resource-id/index.ts +383 -0
- package/src/lib/azure/.gen/providers/azapi/data-azapi-resource-list/index.ts +713 -0
- package/src/lib/azure/.gen/providers/azapi/data-plane-resource/index.ts +1203 -0
- package/src/lib/azure/.gen/providers/azapi/index.ts +11 -0
- package/src/lib/azure/.gen/providers/azapi/lazy-index.ts +51 -0
- package/src/lib/azure/.gen/providers/azapi/provider/index.ts +1121 -0
- package/src/lib/azure/.gen/providers/azapi/resource/index.ts +1516 -0
- package/src/lib/azure/.gen/providers/azapi/resource-action/index.ts +935 -0
- package/src/lib/azure/.gen/providers/azapi/update-resource/index.ts +1042 -0
- package/src/lib/azure/.gen/versions.json +3 -0
- package/src/lib/azure/common/construct.ts +5 -0
- package/src/lib/azure/services/api-management/main.ts +28 -27
- package/src/lib/azure/services/api-management/types.ts +1 -1
- package/src/lib/azure/services/cosmosdb/index.ts +2 -0
- package/src/lib/azure/services/cosmosdb/main.ts +124 -0
- package/src/lib/azure/services/cosmosdb/types.ts +9 -0
- package/src/lib/azure/services/function/main.ts +95 -2
- package/src/lib/azure/services/function/types.ts +20 -1
- package/src/lib/azure/services/index.ts +1 -0
- package/src/lib/azure/services/storage/main.ts +5 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AzurermProvider } from '@cdktf/provider-azurerm/lib/provider'
|
|
2
|
+
import { AzapiProvider } from '../.gen/providers/azapi/provider'
|
|
2
3
|
import { DataAzurermClientConfig } from '@cdktf/provider-azurerm/lib/data-azurerm-client-config'
|
|
3
4
|
import { AzurermBackend, TerraformStack } from 'cdktf'
|
|
4
5
|
import { Construct } from 'constructs'
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
AzureAppServiceManager,
|
|
13
14
|
AzureApplicationInsightsManager,
|
|
14
15
|
AzureAppConfigurationManager,
|
|
16
|
+
AzureCosmosDbManager,
|
|
15
17
|
} from '../services'
|
|
16
18
|
import { CommonAzureStackProps } from './types'
|
|
17
19
|
import { AzureRemoteBackend } from './constants'
|
|
@@ -25,6 +27,7 @@ export class CommonAzureConstruct extends TerraformStack {
|
|
|
25
27
|
appServiceManager: AzureAppServiceManager
|
|
26
28
|
applicationInsightsManager: AzureApplicationInsightsManager
|
|
27
29
|
appConfigurationManager: AzureAppConfigurationManager
|
|
30
|
+
cosmosDbManager: AzureCosmosDbManager
|
|
28
31
|
functiontManager: AzureFunctionManager
|
|
29
32
|
keyVaultManager: AzureKeyVaultManager
|
|
30
33
|
resourceGroupManager: AzureResourceGroupManager
|
|
@@ -39,6 +42,7 @@ export class CommonAzureConstruct extends TerraformStack {
|
|
|
39
42
|
this.appServiceManager = new AzureAppServiceManager()
|
|
40
43
|
this.applicationInsightsManager = new AzureApplicationInsightsManager()
|
|
41
44
|
this.appConfigurationManager = new AzureAppConfigurationManager()
|
|
45
|
+
this.cosmosDbManager = new AzureCosmosDbManager()
|
|
42
46
|
this.functiontManager = new AzureFunctionManager()
|
|
43
47
|
this.keyVaultManager = new AzureKeyVaultManager()
|
|
44
48
|
this.resourceGroupManager = new AzureResourceGroupManager()
|
|
@@ -48,6 +52,7 @@ export class CommonAzureConstruct extends TerraformStack {
|
|
|
48
52
|
this.determineRemoteBackend()
|
|
49
53
|
this.determineTenantId()
|
|
50
54
|
new AzurermProvider(this, `${this.id}-provider`, this.props)
|
|
55
|
+
new AzapiProvider(this, `${this.id}-azapi-provider`, this.props)
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
/**
|
|
@@ -154,9 +154,12 @@ export class AzureApiManagementManager {
|
|
|
154
154
|
displayName: props.displayName || props.name,
|
|
155
155
|
revision: props.revision || '1',
|
|
156
156
|
protocols: props.protocols || ['https'],
|
|
157
|
-
subscriptionRequired: props.subscriptionRequired || true,
|
|
158
157
|
})
|
|
159
158
|
|
|
159
|
+
createAzureTfOutput(`${id}-apiManagementApiName`, scope, apiManagementApi.name)
|
|
160
|
+
createAzureTfOutput(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId)
|
|
161
|
+
createAzureTfOutput(`${id}-apiManagementApiId`, scope, apiManagementApi.id)
|
|
162
|
+
|
|
160
163
|
_.forEach(props.operations, operation => {
|
|
161
164
|
const apimOperation = new ApiManagementApiOperation(
|
|
162
165
|
scope,
|
|
@@ -172,18 +175,6 @@ export class AzureApiManagementManager {
|
|
|
172
175
|
}
|
|
173
176
|
)
|
|
174
177
|
|
|
175
|
-
const apimOperationPolicy = new ApiManagementApiOperationPolicy(
|
|
176
|
-
scope,
|
|
177
|
-
`${id}-apim-api-operation-policy-${operation.path}-${operation.method}`,
|
|
178
|
-
{
|
|
179
|
-
apiManagementName: apiManagementApi.apiManagementName,
|
|
180
|
-
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
181
|
-
apiName: apiManagementApi.name,
|
|
182
|
-
operationId: apimOperation.operationId,
|
|
183
|
-
xmlContent: operation.xmlContent,
|
|
184
|
-
}
|
|
185
|
-
)
|
|
186
|
-
|
|
187
178
|
createAzureTfOutput(
|
|
188
179
|
`${id}-${operation.path}-${operation.method}-apimOperationOperationId`,
|
|
189
180
|
scope,
|
|
@@ -196,22 +187,32 @@ export class AzureApiManagementManager {
|
|
|
196
187
|
)
|
|
197
188
|
createAzureTfOutput(`${id}-${operation.path}-${operation.method}-apimOperationId`, scope, apimOperation.id)
|
|
198
189
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
190
|
+
if (props.policyXmlContent) {
|
|
191
|
+
const apimOperationPolicy = new ApiManagementApiOperationPolicy(
|
|
192
|
+
scope,
|
|
193
|
+
`${id}-apim-api-operation-policy-${operation.path}-${operation.method}`,
|
|
194
|
+
{
|
|
195
|
+
apiManagementName: apiManagementApi.apiManagementName,
|
|
196
|
+
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
197
|
+
apiName: apiManagementApi.name,
|
|
198
|
+
operationId: apimOperation.operationId,
|
|
199
|
+
xmlContent: props.policyXmlContent,
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
createAzureTfOutput(
|
|
204
|
+
`${id}-${operation.path}-${operation.method}-apimOperationPolicyFriendlyUniqueId`,
|
|
205
|
+
scope,
|
|
206
|
+
apimOperationPolicy.friendlyUniqueId
|
|
207
|
+
)
|
|
208
|
+
createAzureTfOutput(
|
|
209
|
+
`${id}-${operation.path}-${operation.method}-apimOperationPolicyId`,
|
|
210
|
+
scope,
|
|
211
|
+
apimOperationPolicy.id
|
|
212
|
+
)
|
|
213
|
+
}
|
|
209
214
|
})
|
|
210
215
|
|
|
211
|
-
createAzureTfOutput(`${id}-apiManagementApiName`, scope, apiManagementApi.name)
|
|
212
|
-
createAzureTfOutput(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId)
|
|
213
|
-
createAzureTfOutput(`${id}-apiManagementApiId`, scope, apiManagementApi.id)
|
|
214
|
-
|
|
215
216
|
return apiManagementApi
|
|
216
217
|
}
|
|
217
218
|
}
|
|
@@ -10,10 +10,10 @@ export interface ApiManagementBackendProps extends ApiManagementBackendConfig {}
|
|
|
10
10
|
|
|
11
11
|
export interface ApiManagementApiProps extends ApiManagementApiConfig {
|
|
12
12
|
operations: OperationsProps[]
|
|
13
|
+
policyXmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent']
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export interface OperationsProps {
|
|
16
17
|
path: ApiManagementApiOperationConfig['urlTemplate']
|
|
17
18
|
method: ApiManagementApiOperationConfig['method']
|
|
18
|
-
xmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent']
|
|
19
19
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
|
|
2
|
+
import { CosmosdbAccount } from '@cdktf/provider-azurerm/lib/cosmosdb-account'
|
|
3
|
+
import { CosmosdbSqlDatabase } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-database'
|
|
4
|
+
import { CosmosdbSqlContainer } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-container'
|
|
5
|
+
import { CosmosdbTable } from '@cdktf/provider-azurerm/lib/cosmosdb-table'
|
|
6
|
+
import { CommonAzureConstruct } from '../../common'
|
|
7
|
+
import { createAzureTfOutput } from '../../utils'
|
|
8
|
+
import { CosmosdbAccountProps, CosmosdbTableProps, CosmosdbSqlContainerProps, CosmosdbSqlDatabaseProps } from './types'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @classdesc Provides operations on Azure CosmosDB
|
|
12
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
13
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
14
|
+
* @example
|
|
15
|
+
* ```
|
|
16
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
17
|
+
*
|
|
18
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
19
|
+
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
20
|
+
* super(parent, id, props)
|
|
21
|
+
* this.props = props
|
|
22
|
+
* this.CosmosDbManager.createCosmosAccount('MyCosmosDb', this, props)
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export class AzureCosmosDbManager {
|
|
28
|
+
/**
|
|
29
|
+
* @summary Method to create a new cosmosdb account
|
|
30
|
+
* @param id scoped id of the resource
|
|
31
|
+
* @param scope scope in which this resource is defined
|
|
32
|
+
* @param props cosmosdb account properties
|
|
33
|
+
* @see [CDKTF CosmosDb Account Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbAccount.typescript.md}
|
|
34
|
+
*/
|
|
35
|
+
public createCosmosDbAccount(id: string, scope: CommonAzureConstruct, props: CosmosdbAccountProps) {
|
|
36
|
+
if (!props) throw `Props undefined for ${id}`
|
|
37
|
+
|
|
38
|
+
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-ca-rg`, {
|
|
39
|
+
name: scope.props.resourceGroupName
|
|
40
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
41
|
+
: `${props.resourceGroupName}`,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
45
|
+
|
|
46
|
+
const cosmosdbAccount = new CosmosdbAccount(scope, `${id}-ca`, {
|
|
47
|
+
...props,
|
|
48
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
49
|
+
location: resourceGroup.location,
|
|
50
|
+
resourceGroupName: resourceGroup.name,
|
|
51
|
+
tags: props.tags ?? {
|
|
52
|
+
environment: scope.props.stage,
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
createAzureTfOutput(`${id}-cosmosdbAccountName`, scope, cosmosdbAccount.name)
|
|
57
|
+
createAzureTfOutput(`${id}-cosmosdbAccountFriendlyUniqueId`, scope, cosmosdbAccount.friendlyUniqueId)
|
|
58
|
+
createAzureTfOutput(`${id}-cosmosdbAccountId`, scope, cosmosdbAccount.id)
|
|
59
|
+
|
|
60
|
+
return cosmosdbAccount
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @summary Method to create a new cosmosdb database
|
|
65
|
+
* @param id scoped id of the resource
|
|
66
|
+
* @param scope scope in which this resource is defined
|
|
67
|
+
* @param props cosmosdb container properties
|
|
68
|
+
* @see [CDKTF CosmosDb Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbSqlContainer.typescript.md}
|
|
69
|
+
*/
|
|
70
|
+
public createCosmosDbDatabase(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlDatabaseProps) {
|
|
71
|
+
if (!props) throw `Props undefined for ${id}`
|
|
72
|
+
|
|
73
|
+
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-cd-rg`, {
|
|
74
|
+
name: scope.props.resourceGroupName
|
|
75
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
76
|
+
: `${props.resourceGroupName}`,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
80
|
+
|
|
81
|
+
const cosmosdbDatatbase = new CosmosdbSqlDatabase(scope, `${id}-cd`, {
|
|
82
|
+
...props,
|
|
83
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
84
|
+
resourceGroupName: resourceGroup.name,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
createAzureTfOutput(`${id}-cosmosdbDatatbasetName`, scope, cosmosdbDatatbase.name)
|
|
88
|
+
createAzureTfOutput(`${id}-cosmosdbDatatbaseFriendlyUniqueId`, scope, cosmosdbDatatbase.friendlyUniqueId)
|
|
89
|
+
createAzureTfOutput(`${id}-cosmosdbDatatbaseId`, scope, cosmosdbDatatbase.id)
|
|
90
|
+
|
|
91
|
+
return cosmosdbDatatbase
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @summary Method to create a new cosmosdb container
|
|
96
|
+
* @param id scoped id of the resource
|
|
97
|
+
* @param scope scope in which this resource is defined
|
|
98
|
+
* @param props cosmosdb container properties
|
|
99
|
+
* @see [CDKTF CosmosDb Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbSqlContainer.typescript.md}
|
|
100
|
+
*/
|
|
101
|
+
public createCosmosDbContainer(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlContainerProps) {
|
|
102
|
+
if (!props) throw `Props undefined for ${id}`
|
|
103
|
+
|
|
104
|
+
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-cc-rg`, {
|
|
105
|
+
name: scope.props.resourceGroupName
|
|
106
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
107
|
+
: `${props.resourceGroupName}`,
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
111
|
+
|
|
112
|
+
const cosmosdbContainer = new CosmosdbSqlContainer(scope, `${id}-cc`, {
|
|
113
|
+
...props,
|
|
114
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
115
|
+
resourceGroupName: resourceGroup.name,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
createAzureTfOutput(`${id}-cosmosdbContainertName`, scope, cosmosdbContainer.name)
|
|
119
|
+
createAzureTfOutput(`${id}-cosmosdbContainerFriendlyUniqueId`, scope, cosmosdbContainer.friendlyUniqueId)
|
|
120
|
+
createAzureTfOutput(`${id}-cosmosdbContainerId`, scope, cosmosdbContainer.id)
|
|
121
|
+
|
|
122
|
+
return cosmosdbContainer
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
|
|
6
|
+
export interface CosmosdbAccountProps extends CosmosdbAccountConfig {}
|
|
7
|
+
export interface CosmosdbSqlDatabaseProps extends CosmosdbSqlDatabaseConfig {}
|
|
8
|
+
export interface CosmosdbSqlContainerProps extends CosmosdbSqlContainerConfig {}
|
|
9
|
+
export interface CosmosdbTableProps extends CosmosdbTableConfig {}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
|
|
2
|
+
import { DataAzurermLinuxFunctionApp } from '@cdktf/provider-azurerm/lib/data-azurerm-linux-function-app'
|
|
2
3
|
import { LinuxFunctionApp } from '@cdktf/provider-azurerm/lib/linux-function-app'
|
|
3
4
|
import { FunctionAppFunction } from '@cdktf/provider-azurerm/lib/function-app-function'
|
|
5
|
+
import { Resource } from '../../.gen/providers/azapi/resource'
|
|
4
6
|
import { CommonAzureConstruct } from '../../common'
|
|
5
7
|
import { createAzureTfOutput } from '../../utils'
|
|
6
|
-
import { FunctionAppProps, FunctionProps } from './types'
|
|
8
|
+
import { FunctionAppProps, FunctionProps, FunctionAppFlexConsumptionProps } from './types'
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* @classdesc Provides operations on Azure Functions
|
|
@@ -16,7 +18,7 @@ import { FunctionAppProps, FunctionProps } from './types'
|
|
|
16
18
|
* class CustomConstruct extends CommonAzureConstruct {
|
|
17
19
|
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
18
20
|
* super(parent, id, props)
|
|
19
|
-
* this.props
|
|
21
|
+
* this.props: props
|
|
20
22
|
* this.functionManager.createFunctionApp('MyFunctionApp', this, props)
|
|
21
23
|
* }
|
|
22
24
|
* }
|
|
@@ -79,4 +81,95 @@ export class AzureFunctionManager {
|
|
|
79
81
|
|
|
80
82
|
return functionAppFunction
|
|
81
83
|
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @summary Method to create a new flex consumption function app
|
|
87
|
+
* @param id scoped id of the resource
|
|
88
|
+
* @param scope scope in which this resource is defined
|
|
89
|
+
* @param props flex consumption function app properties
|
|
90
|
+
*/
|
|
91
|
+
public createFunctionAppFlexConsumption(
|
|
92
|
+
id: string,
|
|
93
|
+
scope: CommonAzureConstruct,
|
|
94
|
+
props: FunctionAppFlexConsumptionProps
|
|
95
|
+
) {
|
|
96
|
+
if (!props) throw `Props undefined for ${id}`
|
|
97
|
+
|
|
98
|
+
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-fa-rg`, {
|
|
99
|
+
name: scope.props.resourceGroupName
|
|
100
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
101
|
+
: `${props.resourceGroupName}`,
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
105
|
+
|
|
106
|
+
const functionApp = new Resource(scope, `${id}-fa`, {
|
|
107
|
+
type: 'Microsoft.Web/sites@2023-12-01',
|
|
108
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
109
|
+
location: resourceGroup.location,
|
|
110
|
+
parentId: resourceGroup.id,
|
|
111
|
+
|
|
112
|
+
body: {
|
|
113
|
+
kind: props.kind || 'functionapp,linux',
|
|
114
|
+
|
|
115
|
+
properties: {
|
|
116
|
+
serverFarmId: props.appServicePlanId,
|
|
117
|
+
httpsOnly: props.httpsOnly || true,
|
|
118
|
+
|
|
119
|
+
functionAppConfig: {
|
|
120
|
+
deployment: {
|
|
121
|
+
storage: {
|
|
122
|
+
type: props.deploymentStorageType || 'blobContainer',
|
|
123
|
+
value: `${props.blobEndpoint}${props.containerName}`,
|
|
124
|
+
authentication: {
|
|
125
|
+
type: props.deploymentAuthenticationType || 'StorageAccountConnectionString',
|
|
126
|
+
storageAccountConnectionStringName:
|
|
127
|
+
props.storageAccountConnectionStringName || 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
runtime: {
|
|
132
|
+
name: props.runtime || 'node',
|
|
133
|
+
version: props.runtimeVersion || '20',
|
|
134
|
+
},
|
|
135
|
+
scaleAndConcurrency: {
|
|
136
|
+
instanceMemoryMB: props.instanceMemory || 2048,
|
|
137
|
+
maximumInstanceCount: props.maximumInstanceCount || 40,
|
|
138
|
+
triggers: {},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
siteConfig: {
|
|
143
|
+
appSettings: props.appSettings.concat([
|
|
144
|
+
{
|
|
145
|
+
name: 'FUNCTIONS_EXTENSION_VERSION',
|
|
146
|
+
value: '~4',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'AzureWebJobsStorage',
|
|
150
|
+
value: props.storageConnectionString,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
|
|
154
|
+
value: props.storageConnectionString,
|
|
155
|
+
},
|
|
156
|
+
]),
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
identity: [{ type: 'SystemAssigned' }],
|
|
162
|
+
|
|
163
|
+
ignoreMissingProperty: true,
|
|
164
|
+
ignoreCasing: true,
|
|
165
|
+
schemaValidationEnabled: false,
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
const functionAppFlexConsumption = new DataAzurermLinuxFunctionApp(scope, `${id}-fa-flex`, {
|
|
169
|
+
name: functionApp.name,
|
|
170
|
+
resourceGroupName: resourceGroup.name,
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
return functionAppFlexConsumption
|
|
174
|
+
}
|
|
82
175
|
}
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { LinuxFunctionAppConfig } from '@cdktf/provider-azurerm/lib/linux-function-app'
|
|
2
2
|
import { FunctionAppFunctionConfig } from '@cdktf/provider-azurerm/lib/function-app-function'
|
|
3
|
-
import {
|
|
3
|
+
import { ResourceConfig } from '../../.gen/providers/azapi/resource'
|
|
4
4
|
|
|
5
5
|
export interface FunctionAppProps extends LinuxFunctionAppConfig {}
|
|
6
6
|
|
|
7
7
|
export interface FunctionProps extends FunctionAppFunctionConfig {}
|
|
8
|
+
|
|
9
|
+
export interface FunctionAppFlexConsumptionProps {
|
|
10
|
+
appServicePlanId: string
|
|
11
|
+
appSettings: any
|
|
12
|
+
blobEndpoint: string
|
|
13
|
+
containerName: string
|
|
14
|
+
deploymentAuthenticationType?: string
|
|
15
|
+
deploymentStorageType?: string
|
|
16
|
+
httpsOnly?: string
|
|
17
|
+
instanceMemory?: number
|
|
18
|
+
kind?: string
|
|
19
|
+
maximumInstanceCount?: number
|
|
20
|
+
name: string
|
|
21
|
+
resourceGroupName: string
|
|
22
|
+
runtime?: string
|
|
23
|
+
runtimeVersion?: string
|
|
24
|
+
storageAccountConnectionStringName?: string
|
|
25
|
+
storageConnectionString: string
|
|
26
|
+
}
|
|
@@ -81,14 +81,15 @@ export class AzureStorageManager {
|
|
|
81
81
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
82
82
|
|
|
83
83
|
const storageAccount = new DataAzurermStorageAccount(scope, `${id}-sa`, {
|
|
84
|
-
name: `${props.storageAccountName}-${scope.props.stage}
|
|
84
|
+
name: `${props.storageAccountName}-${scope.props.stage}`.replace(/\W/g, '').toLowerCase(),
|
|
85
85
|
resourceGroupName: resourceGroup.name,
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
const storageContainer = new StorageContainer(scope, `${id}-sc`, {
|
|
89
89
|
...props,
|
|
90
90
|
name: `${props.name}-${scope.props.stage}`,
|
|
91
|
-
storageAccountName:
|
|
91
|
+
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.
|
|
92
|
+
storageAccountId: storageAccount.id,
|
|
92
93
|
})
|
|
93
94
|
|
|
94
95
|
createAzureTfOutput(`${id}-storageContainerName`, scope, storageContainer.name)
|
|
@@ -123,7 +124,8 @@ export class AzureStorageManager {
|
|
|
123
124
|
|
|
124
125
|
const storageContainer = new DataAzurermStorageContainer(scope, `${id}-sc`, {
|
|
125
126
|
name: `${props.storageContainerName}-${scope.props.stage}`,
|
|
126
|
-
storageAccountName:
|
|
127
|
+
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.
|
|
128
|
+
storageAccountId: storageAccount.id,
|
|
127
129
|
})
|
|
128
130
|
|
|
129
131
|
const storageBlob = new StorageBlob(scope, `${id}-sb`, {
|