@gradientedge/cdk-utils 9.36.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 (28) 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.js +2 -0
  6. package/dist/src/lib/azure/services/function/main.d.ts +10 -2
  7. package/dist/src/lib/azure/services/function/main.js +79 -1
  8. package/dist/src/lib/azure/services/function/types.d.ts +18 -0
  9. package/dist/src/lib/azure/services/storage/main.js +5 -3
  10. package/package.json +1 -1
  11. package/src/lib/azure/.gen/constraints.json +6 -0
  12. package/src/lib/azure/.gen/providers/azapi/data-azapi-client-config/index.ts +257 -0
  13. package/src/lib/azure/.gen/providers/azapi/data-azapi-resource/index.ts +876 -0
  14. package/src/lib/azure/.gen/providers/azapi/data-azapi-resource-action/index.ts +779 -0
  15. package/src/lib/azure/.gen/providers/azapi/data-azapi-resource-id/index.ts +383 -0
  16. package/src/lib/azure/.gen/providers/azapi/data-azapi-resource-list/index.ts +713 -0
  17. package/src/lib/azure/.gen/providers/azapi/data-plane-resource/index.ts +1203 -0
  18. package/src/lib/azure/.gen/providers/azapi/index.ts +11 -0
  19. package/src/lib/azure/.gen/providers/azapi/lazy-index.ts +51 -0
  20. package/src/lib/azure/.gen/providers/azapi/provider/index.ts +1121 -0
  21. package/src/lib/azure/.gen/providers/azapi/resource/index.ts +1516 -0
  22. package/src/lib/azure/.gen/providers/azapi/resource-action/index.ts +935 -0
  23. package/src/lib/azure/.gen/providers/azapi/update-resource/index.ts +1042 -0
  24. package/src/lib/azure/.gen/versions.json +3 -0
  25. package/src/lib/azure/common/construct.ts +2 -0
  26. package/src/lib/azure/services/function/main.ts +95 -2
  27. package/src/lib/azure/services/function/types.ts +20 -1
  28. package/src/lib/azure/services/storage/main.ts +5 -3
@@ -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");
@@ -37,6 +38,7 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
37
38
  this.determineRemoteBackend();
38
39
  this.determineTenantId();
39
40
  new provider_1.AzurermProvider(this, `${this.id}-provider`, this.props);
41
+ new provider_2.AzapiProvider(this, `${this.id}-azapi-provider`, this.props);
40
42
  }
41
43
  /**
42
44
  * @summary Determine the fully qualified domain name based on domainName & subDomain
@@ -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
+ }
@@ -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.36.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
+ }
@@ -0,0 +1,257 @@
1
+ // https://registry.terraform.io/providers/azure/azapi/2.2.0/docs/data-sources/client_config
2
+ // generated from terraform resource schema
3
+
4
+ import { Construct } from 'constructs'
5
+ import * as cdktf from 'cdktf'
6
+
7
+ // Configuration
8
+
9
+ export interface DataAzapiClientConfigConfig extends cdktf.TerraformMetaArguments {
10
+ /**
11
+ * timeouts block
12
+ *
13
+ * Docs at Terraform Registry: {@link https://registry.terraform.io/providers/azure/azapi/2.2.0/docs/data-sources/client_config#timeouts DataAzapiClientConfig#timeouts}
14
+ */
15
+ readonly timeouts?: DataAzapiClientConfigTimeouts
16
+ }
17
+ export interface DataAzapiClientConfigTimeouts {
18
+ /**
19
+ * A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled.
20
+ *
21
+ * Docs at Terraform Registry: {@link https://registry.terraform.io/providers/azure/azapi/2.2.0/docs/data-sources/client_config#read DataAzapiClientConfig#read}
22
+ */
23
+ readonly read?: string
24
+ }
25
+
26
+ export function dataAzapiClientConfigTimeoutsToTerraform(
27
+ struct?: DataAzapiClientConfigTimeouts | cdktf.IResolvable
28
+ ): any {
29
+ if (!cdktf.canInspect(struct) || cdktf.Tokenization.isResolvable(struct)) {
30
+ return struct
31
+ }
32
+ if (cdktf.isComplexElement(struct)) {
33
+ throw new Error(
34
+ 'A complex element was used as configuration, this is not supported: https://cdk.tf/complex-object-as-configuration'
35
+ )
36
+ }
37
+ return {
38
+ read: cdktf.stringToTerraform(struct!.read),
39
+ }
40
+ }
41
+
42
+ export function dataAzapiClientConfigTimeoutsToHclTerraform(
43
+ struct?: DataAzapiClientConfigTimeouts | cdktf.IResolvable
44
+ ): any {
45
+ if (!cdktf.canInspect(struct) || cdktf.Tokenization.isResolvable(struct)) {
46
+ return struct
47
+ }
48
+ if (cdktf.isComplexElement(struct)) {
49
+ throw new Error(
50
+ 'A complex element was used as configuration, this is not supported: https://cdk.tf/complex-object-as-configuration'
51
+ )
52
+ }
53
+ const attrs = {
54
+ read: {
55
+ value: cdktf.stringToHclTerraform(struct!.read),
56
+ isBlock: false,
57
+ type: 'simple',
58
+ storageClassType: 'string',
59
+ },
60
+ }
61
+
62
+ // remove undefined attributes
63
+ return Object.fromEntries(
64
+ Object.entries(attrs).filter(([_, value]) => value !== undefined && value.value !== undefined)
65
+ )
66
+ }
67
+
68
+ export class DataAzapiClientConfigTimeoutsOutputReference extends cdktf.ComplexObject {
69
+ private isEmptyObject = false
70
+ private resolvableValue?: cdktf.IResolvable
71
+
72
+ /**
73
+ * @param terraformResource The parent resource
74
+ * @param terraformAttribute The attribute on the parent resource this class is referencing
75
+ */
76
+ public constructor(terraformResource: cdktf.IInterpolatingParent, terraformAttribute: string) {
77
+ super(terraformResource, terraformAttribute, false)
78
+ }
79
+
80
+ public get internalValue(): DataAzapiClientConfigTimeouts | cdktf.IResolvable | undefined {
81
+ if (this.resolvableValue) {
82
+ return this.resolvableValue
83
+ }
84
+ let hasAnyValues = this.isEmptyObject
85
+ const internalValueResult: any = {}
86
+ if (this._read !== undefined) {
87
+ hasAnyValues = true
88
+ internalValueResult.read = this._read
89
+ }
90
+ return hasAnyValues ? internalValueResult : undefined
91
+ }
92
+
93
+ public set internalValue(value: DataAzapiClientConfigTimeouts | cdktf.IResolvable | undefined) {
94
+ if (value === undefined) {
95
+ this.isEmptyObject = false
96
+ this.resolvableValue = undefined
97
+ this._read = undefined
98
+ } else if (cdktf.Tokenization.isResolvable(value)) {
99
+ this.isEmptyObject = false
100
+ this.resolvableValue = value
101
+ } else {
102
+ this.isEmptyObject = Object.keys(value).length === 0
103
+ this.resolvableValue = undefined
104
+ this._read = value.read
105
+ }
106
+ }
107
+
108
+ // read - computed: false, optional: true, required: false
109
+ private _read?: string
110
+ public get read() {
111
+ return this.getStringAttribute('read')
112
+ }
113
+ public set read(value: string) {
114
+ this._read = value
115
+ }
116
+ public resetRead() {
117
+ this._read = undefined
118
+ }
119
+ // Temporarily expose input value. Use with caution.
120
+ public get readInput() {
121
+ return this._read
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Represents a {@link https://registry.terraform.io/providers/azure/azapi/2.2.0/docs/data-sources/client_config azapi_client_config}
127
+ */
128
+ export class DataAzapiClientConfig extends cdktf.TerraformDataSource {
129
+ // =================
130
+ // STATIC PROPERTIES
131
+ // =================
132
+ public static readonly tfResourceType = 'azapi_client_config'
133
+
134
+ // ==============
135
+ // STATIC Methods
136
+ // ==============
137
+ /**
138
+ * Generates CDKTF code for importing a DataAzapiClientConfig resource upon running "cdktf plan <stack-name>"
139
+ * @param scope The scope in which to define this construct
140
+ * @param importToId The construct id used in the generated config for the DataAzapiClientConfig to import
141
+ * @param importFromId The id of the existing DataAzapiClientConfig that should be imported. Refer to the {@link https://registry.terraform.io/providers/azure/azapi/2.2.0/docs/data-sources/client_config#import import section} in the documentation of this resource for the id to use
142
+ * @param provider? Optional instance of the provider where the DataAzapiClientConfig to import is found
143
+ */
144
+ public static generateConfigForImport(
145
+ scope: Construct,
146
+ importToId: string,
147
+ importFromId: string,
148
+ provider?: cdktf.TerraformProvider
149
+ ) {
150
+ return new cdktf.ImportableResource(scope, importToId, {
151
+ terraformResourceType: 'azapi_client_config',
152
+ importId: importFromId,
153
+ provider,
154
+ })
155
+ }
156
+
157
+ // ===========
158
+ // INITIALIZER
159
+ // ===========
160
+
161
+ /**
162
+ * Create a new {@link https://registry.terraform.io/providers/azure/azapi/2.2.0/docs/data-sources/client_config azapi_client_config} Data Source
163
+ *
164
+ * @param scope The scope in which to define this construct
165
+ * @param id The scoped construct ID. Must be unique amongst siblings in the same scope
166
+ * @param options DataAzapiClientConfigConfig = {}
167
+ */
168
+ public constructor(scope: Construct, id: string, config: DataAzapiClientConfigConfig = {}) {
169
+ super(scope, id, {
170
+ terraformResourceType: 'azapi_client_config',
171
+ terraformGeneratorMetadata: {
172
+ providerName: 'azapi',
173
+ providerVersion: '2.2.0',
174
+ providerVersionConstraint: '~> 2.2',
175
+ },
176
+ provider: config.provider,
177
+ dependsOn: config.dependsOn,
178
+ count: config.count,
179
+ lifecycle: config.lifecycle,
180
+ provisioners: config.provisioners,
181
+ connection: config.connection,
182
+ forEach: config.forEach,
183
+ })
184
+ this._timeouts.internalValue = config.timeouts
185
+ }
186
+
187
+ // ==========
188
+ // ATTRIBUTES
189
+ // ==========
190
+
191
+ // id - computed: true, optional: false, required: false
192
+ public get id() {
193
+ return this.getStringAttribute('id')
194
+ }
195
+
196
+ // object_id - computed: true, optional: false, required: false
197
+ public get objectId() {
198
+ return this.getStringAttribute('object_id')
199
+ }
200
+
201
+ // subscription_id - computed: true, optional: false, required: false
202
+ public get subscriptionId() {
203
+ return this.getStringAttribute('subscription_id')
204
+ }
205
+
206
+ // subscription_resource_id - computed: true, optional: false, required: false
207
+ public get subscriptionResourceId() {
208
+ return this.getStringAttribute('subscription_resource_id')
209
+ }
210
+
211
+ // tenant_id - computed: true, optional: false, required: false
212
+ public get tenantId() {
213
+ return this.getStringAttribute('tenant_id')
214
+ }
215
+
216
+ // timeouts - computed: false, optional: true, required: false
217
+ private _timeouts = new DataAzapiClientConfigTimeoutsOutputReference(this, 'timeouts')
218
+ public get timeouts() {
219
+ return this._timeouts
220
+ }
221
+ public putTimeouts(value: DataAzapiClientConfigTimeouts) {
222
+ this._timeouts.internalValue = value
223
+ }
224
+ public resetTimeouts() {
225
+ this._timeouts.internalValue = undefined
226
+ }
227
+ // Temporarily expose input value. Use with caution.
228
+ public get timeoutsInput() {
229
+ return this._timeouts.internalValue
230
+ }
231
+
232
+ // =========
233
+ // SYNTHESIS
234
+ // =========
235
+
236
+ protected synthesizeAttributes(): { [name: string]: any } {
237
+ return {
238
+ timeouts: dataAzapiClientConfigTimeoutsToTerraform(this._timeouts.internalValue),
239
+ }
240
+ }
241
+
242
+ protected synthesizeHclAttributes(): { [name: string]: any } {
243
+ const attrs = {
244
+ timeouts: {
245
+ value: dataAzapiClientConfigTimeoutsToHclTerraform(this._timeouts.internalValue),
246
+ isBlock: true,
247
+ type: 'struct',
248
+ storageClassType: 'DataAzapiClientConfigTimeouts',
249
+ },
250
+ }
251
+
252
+ // remove undefined attributes
253
+ return Object.fromEntries(
254
+ Object.entries(attrs).filter(([_, value]) => value !== undefined && value.value !== undefined)
255
+ )
256
+ }
257
+ }