@gradientedge/cdk-utils 9.64.0 → 9.66.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/common/construct.js +2 -0
- package/dist/src/lib/azure/services/api-management/main.d.ts +1 -2
- package/dist/src/lib/azure/services/api-management/main.js +27 -5
- package/dist/src/lib/azure/services/api-management/types.d.ts +2 -0
- package/dist/src/lib/azure/services/function/main.js +0 -24
- package/package.json +1 -1
- package/src/lib/azure/common/construct.ts +2 -0
- package/src/lib/azure/services/api-management/main.ts +31 -3
- package/src/lib/azure/services/api-management/types.ts +2 -0
- package/src/lib/azure/services/function/main.ts +0 -25
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CommonAzureConstruct = void 0;
|
|
4
4
|
const provider_1 = require("@cdktf/provider-azurerm/lib/provider");
|
|
5
5
|
const provider_2 = require("../.gen/providers/azapi/provider");
|
|
6
|
+
const cdktf_local_exec_1 = require("cdktf-local-exec");
|
|
6
7
|
const data_azurerm_client_config_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-client-config");
|
|
7
8
|
const cdktf_1 = require("cdktf");
|
|
8
9
|
const common_1 = require("../../common");
|
|
@@ -52,6 +53,7 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
|
|
|
52
53
|
this.determineTenantId();
|
|
53
54
|
new provider_2.AzapiProvider(this, `${this.id}-azapi-provider`, this.props);
|
|
54
55
|
new provider_1.AzurermProvider(this, `${this.id}-provider`, this.props);
|
|
56
|
+
new cdktf_local_exec_1.Provider(this, `${this.id}-local-exec-provider`);
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
59
|
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DataAzurermApiManagement, DataAzurermApiManagementConfig } from '@cdktf/provider-azurerm/lib/data-azurerm-api-management';
|
|
2
2
|
import { ApiManagementCustomDomain } from '@cdktf/provider-azurerm/lib/api-management-custom-domain';
|
|
3
|
-
import { ApiManagementBackend } from '@cdktf/provider-azurerm/lib/api-management-backend';
|
|
4
3
|
import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management';
|
|
5
4
|
import { ApiManagementApi } from '@cdktf/provider-azurerm/lib/api-management-api';
|
|
6
5
|
import { ApiManagementLoggerApplicationInsights } from '@cdktf/provider-azurerm/lib/api-management-logger';
|
|
@@ -56,7 +55,7 @@ export declare class AzureApiManagementManager {
|
|
|
56
55
|
* @param props api management backend properties
|
|
57
56
|
* @see [CDKTF Api management Backend Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementBackend.typescript.md}
|
|
58
57
|
*/
|
|
59
|
-
createApiManagementBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps):
|
|
58
|
+
createApiManagementBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps): Resource;
|
|
60
59
|
/**
|
|
61
60
|
* @summary Method to create a new api management api
|
|
62
61
|
* @param id scoped id of the resource
|
|
@@ -7,7 +7,6 @@ exports.AzureApiManagementManager = void 0;
|
|
|
7
7
|
const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
|
|
8
8
|
const data_azurerm_api_management_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-api-management");
|
|
9
9
|
const api_management_custom_domain_1 = require("@cdktf/provider-azurerm/lib/api-management-custom-domain");
|
|
10
|
-
const api_management_backend_1 = require("@cdktf/provider-azurerm/lib/api-management-backend");
|
|
11
10
|
const api_management_1 = require("@cdktf/provider-azurerm/lib/api-management");
|
|
12
11
|
const api_management_api_1 = require("@cdktf/provider-azurerm/lib/api-management-api");
|
|
13
12
|
const api_management_api_operation_1 = require("@cdktf/provider-azurerm/lib/api-management-api-operation");
|
|
@@ -171,11 +170,34 @@ class AzureApiManagementManager {
|
|
|
171
170
|
createApiManagementBackend(id, scope, props) {
|
|
172
171
|
if (!props)
|
|
173
172
|
throw `Props undefined for ${id}`;
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
// Commenting as circuit breaker config is currently not supported
|
|
174
|
+
/*
|
|
175
|
+
const apiManagementBackend = new ApiManagementBackend(scope, `${id}-am-be`, {
|
|
176
|
+
...props,
|
|
177
|
+
name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementBackend),
|
|
178
|
+
description: props.description ?? `Backend for ${props.name}-${scope.props.stage}`,
|
|
179
|
+
protocol: props.protocol ?? 'http',
|
|
180
|
+
})
|
|
181
|
+
*/
|
|
182
|
+
const apiManagementBackend = new resource_1.Resource(scope, `${id}-am-be`, {
|
|
183
|
+
type: 'Microsoft.ApiManagement/service/backends@2024-06-01-preview',
|
|
176
184
|
name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementBackend),
|
|
177
|
-
|
|
178
|
-
|
|
185
|
+
parentId: props.apiManagementId,
|
|
186
|
+
body: {
|
|
187
|
+
properties: {
|
|
188
|
+
circuitBreaker: props.circuitBreaker,
|
|
189
|
+
credentials: props.credentials,
|
|
190
|
+
description: props.description ?? `Backend for ${props.name}-${scope.props.stage}`,
|
|
191
|
+
url: props.url,
|
|
192
|
+
resourceId: props.resourceId,
|
|
193
|
+
protocol: props.protocol ?? 'http',
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
responseExportValues: ['*'],
|
|
197
|
+
ignoreMissingProperty: true,
|
|
198
|
+
ignoreCasing: true,
|
|
199
|
+
schemaValidationEnabled: false,
|
|
200
|
+
lifecycle: props.lifecycle,
|
|
179
201
|
});
|
|
180
202
|
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementBackendName`, scope, apiManagementBackend.name);
|
|
181
203
|
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementBackendFriendlyUniqueId`, scope, apiManagementBackend.friendlyUniqueId);
|
|
@@ -7,6 +7,8 @@ export interface ApiManagementProps extends ApiManagementConfig {
|
|
|
7
7
|
}
|
|
8
8
|
export interface ApiManagementBackendProps extends ApiManagementBackendConfig {
|
|
9
9
|
backendUrlPath?: string;
|
|
10
|
+
apiManagementId: string;
|
|
11
|
+
circuitBreaker: any;
|
|
10
12
|
}
|
|
11
13
|
export interface ApiManagementCustomDomainProps extends ApiManagementCustomDomainConfig {
|
|
12
14
|
}
|
|
@@ -5,7 +5,6 @@ const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-
|
|
|
5
5
|
const linux_function_app_1 = require("@cdktf/provider-azurerm/lib/linux-function-app");
|
|
6
6
|
const function_app_function_1 = require("@cdktf/provider-azurerm/lib/function-app-function");
|
|
7
7
|
const function_app_flex_consumption_1 = require("@cdktf/provider-azurerm/lib/function-app-flex-consumption");
|
|
8
|
-
const cdktf_local_exec_1 = require("cdktf-local-exec");
|
|
9
8
|
const utils_1 = require("../../utils");
|
|
10
9
|
/**
|
|
11
10
|
* @classdesc Provides operations on Azure Functions
|
|
@@ -113,29 +112,6 @@ class AzureFunctionManager {
|
|
|
113
112
|
environment: scope.props.stage,
|
|
114
113
|
},
|
|
115
114
|
});
|
|
116
|
-
new cdktf_local_exec_1.Provider(scope, `${id}-local-exec-provider`);
|
|
117
|
-
// Deploy function app zip package with up to 3 retry attempts.
|
|
118
|
-
// This handles transient issues like HTTP 503s returned from the Azure Kudu deployment endpoint.
|
|
119
|
-
new cdktf_local_exec_1.LocalExec(scope, `${id}-function-app-deploy`, {
|
|
120
|
-
triggers: {
|
|
121
|
-
hash: props.sourceCodeHash,
|
|
122
|
-
},
|
|
123
|
-
command: `
|
|
124
|
-
set -e
|
|
125
|
-
MAX_RETRIES=3
|
|
126
|
-
RETRY_COUNT=0
|
|
127
|
-
until az functionapp deployment source config-zip --resource-group "${resourceGroup.name}" --name "${functionApp.name}" --src "${props.deploySource}"; do
|
|
128
|
-
RETRY_COUNT=$((RETRY_COUNT+1))
|
|
129
|
-
echo "Deployment attempt $RETRY_COUNT failed. Retrying in 10 seconds..."
|
|
130
|
-
if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
|
|
131
|
-
echo "Deployment failed after $MAX_RETRIES attempts."
|
|
132
|
-
exit 1
|
|
133
|
-
fi
|
|
134
|
-
sleep 10
|
|
135
|
-
done
|
|
136
|
-
echo "Deployment succeeded."
|
|
137
|
-
`,
|
|
138
|
-
});
|
|
139
115
|
return functionApp;
|
|
140
116
|
}
|
|
141
117
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AzurermProvider } from '@cdktf/provider-azurerm/lib/provider'
|
|
2
2
|
import { AzapiProvider } from '../.gen/providers/azapi/provider'
|
|
3
|
+
import { Provider } from 'cdktf-local-exec'
|
|
3
4
|
import { DataAzurermClientConfig } from '@cdktf/provider-azurerm/lib/data-azurerm-client-config'
|
|
4
5
|
import { AzurermBackend, TerraformStack } from 'cdktf'
|
|
5
6
|
import { Construct } from 'constructs'
|
|
@@ -72,6 +73,7 @@ export class CommonAzureConstruct extends TerraformStack {
|
|
|
72
73
|
|
|
73
74
|
new AzapiProvider(this, `${this.id}-azapi-provider`, this.props)
|
|
74
75
|
new AzurermProvider(this, `${this.id}-provider`, this.props)
|
|
76
|
+
new Provider(this, `${this.id}-local-exec-provider`)
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
/**
|
|
@@ -208,11 +208,39 @@ export class AzureApiManagementManager {
|
|
|
208
208
|
public createApiManagementBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps) {
|
|
209
209
|
if (!props) throw `Props undefined for ${id}`
|
|
210
210
|
|
|
211
|
+
// Commenting as circuit breaker config is currently not supported
|
|
212
|
+
/*
|
|
211
213
|
const apiManagementBackend = new ApiManagementBackend(scope, `${id}-am-be`, {
|
|
212
|
-
|
|
214
|
+
...props,
|
|
215
|
+
name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementBackend),
|
|
216
|
+
description: props.description ?? `Backend for ${props.name}-${scope.props.stage}`,
|
|
217
|
+
protocol: props.protocol ?? 'http',
|
|
218
|
+
})
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
const apiManagementBackend = new Resource(scope, `${id}-am-be`, {
|
|
222
|
+
type: 'Microsoft.ApiManagement/service/backends@2024-06-01-preview',
|
|
213
223
|
name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementBackend),
|
|
214
|
-
|
|
215
|
-
|
|
224
|
+
parentId: props.apiManagementId,
|
|
225
|
+
|
|
226
|
+
body: {
|
|
227
|
+
properties: {
|
|
228
|
+
circuitBreaker: props.circuitBreaker,
|
|
229
|
+
credentials: props.credentials,
|
|
230
|
+
description: props.description ?? `Backend for ${props.name}-${scope.props.stage}`,
|
|
231
|
+
url: props.url,
|
|
232
|
+
resourceId: props.resourceId,
|
|
233
|
+
protocol: props.protocol ?? 'http',
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
responseExportValues: ['*'],
|
|
238
|
+
|
|
239
|
+
ignoreMissingProperty: true,
|
|
240
|
+
ignoreCasing: true,
|
|
241
|
+
schemaValidationEnabled: false,
|
|
242
|
+
|
|
243
|
+
lifecycle: props.lifecycle,
|
|
216
244
|
})
|
|
217
245
|
|
|
218
246
|
createAzureTfOutput(`${id}-apiManagementBackendName`, scope, apiManagementBackend.name)
|
|
@@ -8,6 +8,8 @@ export interface ApiManagementProps extends ApiManagementConfig {}
|
|
|
8
8
|
|
|
9
9
|
export interface ApiManagementBackendProps extends ApiManagementBackendConfig {
|
|
10
10
|
backendUrlPath?: string
|
|
11
|
+
apiManagementId: string
|
|
12
|
+
circuitBreaker: any
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export interface ApiManagementCustomDomainProps extends ApiManagementCustomDomainConfig {}
|
|
@@ -2,7 +2,6 @@ import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azure
|
|
|
2
2
|
import { LinuxFunctionApp } from '@cdktf/provider-azurerm/lib/linux-function-app'
|
|
3
3
|
import { FunctionAppFunction } from '@cdktf/provider-azurerm/lib/function-app-function'
|
|
4
4
|
import { FunctionAppFlexConsumption } from '@cdktf/provider-azurerm/lib/function-app-flex-consumption'
|
|
5
|
-
import { LocalExec, Provider } from 'cdktf-local-exec'
|
|
6
5
|
import { CommonAzureConstruct } from '../../common'
|
|
7
6
|
import { createAzureTfOutput } from '../../utils'
|
|
8
7
|
import { FunctionAppProps, FunctionProps, FunctionAppFlexConsumptionProps } from './types'
|
|
@@ -126,30 +125,6 @@ export class AzureFunctionManager {
|
|
|
126
125
|
},
|
|
127
126
|
})
|
|
128
127
|
|
|
129
|
-
new Provider(scope, `${id}-local-exec-provider`)
|
|
130
|
-
// Deploy function app zip package with up to 3 retry attempts.
|
|
131
|
-
// This handles transient issues like HTTP 503s returned from the Azure Kudu deployment endpoint.
|
|
132
|
-
new LocalExec(scope, `${id}-function-app-deploy`, {
|
|
133
|
-
triggers: {
|
|
134
|
-
hash: props.sourceCodeHash,
|
|
135
|
-
},
|
|
136
|
-
command: `
|
|
137
|
-
set -e
|
|
138
|
-
MAX_RETRIES=3
|
|
139
|
-
RETRY_COUNT=0
|
|
140
|
-
until az functionapp deployment source config-zip --resource-group "${resourceGroup.name}" --name "${functionApp.name}" --src "${props.deploySource}"; do
|
|
141
|
-
RETRY_COUNT=$((RETRY_COUNT+1))
|
|
142
|
-
echo "Deployment attempt $RETRY_COUNT failed. Retrying in 10 seconds..."
|
|
143
|
-
if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
|
|
144
|
-
echo "Deployment failed after $MAX_RETRIES attempts."
|
|
145
|
-
exit 1
|
|
146
|
-
fi
|
|
147
|
-
sleep 10
|
|
148
|
-
done
|
|
149
|
-
echo "Deployment succeeded."
|
|
150
|
-
`,
|
|
151
|
-
})
|
|
152
|
-
|
|
153
128
|
return functionApp
|
|
154
129
|
}
|
|
155
130
|
}
|