@gradientedge/cdk-utils 9.50.0 → 9.52.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.
@@ -43,6 +43,9 @@ class AzureAppConfigurationManager {
43
43
  ...props,
44
44
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.appConfiguration),
45
45
  resourceGroupName: resourceGroup.name,
46
+ identity: {
47
+ type: 'SystemAssigned',
48
+ },
46
49
  tags: props.tags ?? {
47
50
  environment: scope.props.stage,
48
51
  },
@@ -1,6 +1,6 @@
1
1
  import { LinuxFunctionApp } from '@cdktf/provider-azurerm/lib/linux-function-app';
2
2
  import { FunctionAppFunction } from '@cdktf/provider-azurerm/lib/function-app-function';
3
- import { Resource } from '../../.gen/providers/azapi/resource';
3
+ import { FunctionAppFlexConsumption } from '@cdktf/provider-azurerm/lib/function-app-flex-consumption';
4
4
  import { CommonAzureConstruct } from '../../common';
5
5
  import { FunctionAppProps, FunctionProps, FunctionAppFlexConsumptionProps } from './types';
6
6
  /**
@@ -43,5 +43,5 @@ export declare class AzureFunctionManager {
43
43
  * @param scope scope in which this resource is defined
44
44
  * @param props flex consumption function app properties
45
45
  */
46
- createFunctionAppFlexConsumption(id: string, scope: CommonAzureConstruct, props: FunctionAppFlexConsumptionProps): Resource;
46
+ createFunctionAppFlexConsumption(id: string, scope: CommonAzureConstruct, props: FunctionAppFlexConsumptionProps): FunctionAppFlexConsumption;
47
47
  }
@@ -4,7 +4,7 @@ exports.AzureFunctionManager = void 0;
4
4
  const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
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
- const resource_1 = require("../../.gen/providers/azapi/resource");
7
+ const function_app_flex_consumption_1 = require("@cdktf/provider-azurerm/lib/function-app-flex-consumption");
8
8
  const cdktf_local_exec_1 = require("cdktf-local-exec");
9
9
  const utils_1 = require("../../utils");
10
10
  /**
@@ -91,62 +91,27 @@ class AzureFunctionManager {
91
91
  });
92
92
  if (!resourceGroup)
93
93
  throw `Resource group undefined for ${id}`;
94
- const functionApp = new resource_1.Resource(scope, `${id}-fa`, {
95
- type: 'Microsoft.Web/sites@2024-04-01',
94
+ const functionApp = new function_app_flex_consumption_1.FunctionAppFlexConsumption(scope, `${id}-fc`, {
95
+ ...props,
96
96
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.functionApp),
97
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
- alwaysReady: props.alwaysReady,
121
- instanceMemoryMB: props.instanceMemory ?? 2048,
122
- maximumInstanceCount: props.maximumInstanceCount ?? 40,
123
- triggers: {},
124
- },
125
- },
126
- siteConfig: {
127
- appSettings: props.appSettings.concat([
128
- {
129
- name: 'FUNCTIONS_EXTENSION_VERSION',
130
- value: '~4',
131
- },
132
- {
133
- name: 'AzureWebJobsStorage',
134
- value: props.storageConnectionString,
135
- },
136
- {
137
- name: 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
138
- value: props.storageConnectionString,
139
- },
140
- ]),
141
- connectionStrings: props.connectionStrings,
142
- minTlsVersion: props.minTlsVersion ?? '1.3',
143
- },
144
- },
98
+ resourceGroupName: resourceGroup.name,
99
+ runtimeName: props.runtimeName ?? 'node',
100
+ runtimeVersion: props.runtimeVersion ?? '20',
101
+ storageAuthenticationType: props.storageAuthenticationType ?? 'StorageAccountConnectionString',
102
+ storageContainerType: props.storageContainerType ?? 'blobContainer',
103
+ maximumInstanceCount: props.maximumInstanceCount ?? 40,
104
+ instanceMemoryInMb: props.instanceMemoryInMb ?? 2048,
105
+ siteConfig: {
106
+ http2Enabled: props.siteConfig.http2Enabled ?? true,
107
+ ...props.siteConfig,
108
+ },
109
+ identity: props.identity ?? {
110
+ type: 'SystemAssigned',
111
+ },
112
+ tags: props.tags ?? {
113
+ environment: scope.props.stage,
145
114
  },
146
- identity: [{ type: 'SystemAssigned' }],
147
- ignoreMissingProperty: true,
148
- ignoreCasing: true,
149
- schemaValidationEnabled: false,
150
115
  });
151
116
  new cdktf_local_exec_1.Provider(scope, `${id}-local-exec-provider`);
152
117
  new cdktf_local_exec_1.LocalExec(scope, `${id}-function-app-deploy`, {
@@ -1,29 +1,11 @@
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 { FunctionAppFlexConsumptionConfig } from '@cdktf/provider-azurerm/lib/function-app-flex-consumption';
3
4
  export interface FunctionAppProps extends LinuxFunctionAppConfig {
4
5
  }
5
6
  export interface FunctionProps extends FunctionAppFunctionConfig {
6
7
  }
7
- export interface FunctionAppFlexConsumptionProps {
8
- alwaysReady?: any;
9
- appServicePlanId: string;
10
- appSettings: any;
11
- blobEndpoint: string;
12
- connectionStrings: any;
13
- containerName: string;
14
- deploymentAuthenticationType?: string;
15
- deploymentStorageType?: string;
16
- deploySource: string;
17
- httpsOnly?: string;
18
- instanceMemory?: number;
19
- kind?: string;
20
- maximumInstanceCount?: number;
21
- name: string;
22
- resourceGroupName: string;
23
- runtime?: string;
24
- runtimeVersion?: string;
25
- storageAccountConnectionStringName?: string;
26
- storageConnectionString: string;
8
+ export interface FunctionAppFlexConsumptionProps extends FunctionAppFlexConsumptionConfig {
27
9
  sourceCodeHash: string;
28
- minTlsVersion?: string;
10
+ deploySource: string;
29
11
  }
@@ -44,6 +44,8 @@ class AzureLogAnalyticsWorkspaceManager {
44
44
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.logAnalyticsWorkspace),
45
45
  location: resourceGroup.location,
46
46
  resourceGroupName: resourceGroup.name,
47
+ sku: props.sku ?? 'PerGB2018',
48
+ retentionInDays: props.retentionInDays ?? 30,
47
49
  tags: props.tags ?? {
48
50
  environment: scope.props.stage,
49
51
  },
@@ -64,6 +64,15 @@ export declare class CloudflarePagesStaticSite extends CommonCloudflareConstruct
64
64
  * @returns the secret value
65
65
  */
66
66
  protected resolveSecretFromAWS(secretName: string, secretKey: string): any;
67
+ /**
68
+ * @summary Resolve secrets from Azure Key Vault
69
+ *
70
+ * @param resourceGroupName the resource group name where the key vault is located
71
+ * @param keyVaultName the key vault name
72
+ * @param secretKey the secret key
73
+ * @returns the secret value
74
+ */
75
+ protected resolveSecretFromAzure(resourceGroupName: string, keyVaultName: string, secretKey: string): string;
67
76
  /**
68
77
  * @summary Create the pages project
69
78
  */
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CloudflarePagesStaticSite = void 0;
4
4
  const data_aws_secretsmanager_secret_1 = require("@cdktf/provider-aws/lib/data-aws-secretsmanager-secret");
5
5
  const data_aws_secretsmanager_secret_version_1 = require("@cdktf/provider-aws/lib/data-aws-secretsmanager-secret-version");
6
+ const data_azurerm_key_vault_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-key-vault");
7
+ const data_azurerm_key_vault_secret_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-key-vault-secret");
6
8
  const cdktf_1 = require("cdktf");
7
9
  const common_1 = require("../../common");
8
10
  /**
@@ -109,6 +111,29 @@ class CloudflarePagesStaticSite extends common_1.CommonCloudflareConstruct {
109
111
  throw new Error(`Unable to resolve secret:${secretName}`);
110
112
  return cdktf_1.Fn.lookup(cdktf_1.Fn.jsondecode(secretVersion.secretString), secretKey);
111
113
  }
114
+ /**
115
+ * @summary Resolve secrets from Azure Key Vault
116
+ *
117
+ * @param resourceGroupName the resource group name where the key vault is located
118
+ * @param keyVaultName the key vault name
119
+ * @param secretKey the secret key
120
+ * @returns the secret value
121
+ */
122
+ resolveSecretFromAzure(resourceGroupName, keyVaultName, secretKey) {
123
+ const keyVaultData = new data_azurerm_key_vault_1.DataAzurermKeyVault(this, `${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-vault`, {
124
+ resourceGroupName: resourceGroupName,
125
+ name: keyVaultName,
126
+ provider: this.azurermProvider,
127
+ });
128
+ const secretValueData = new data_azurerm_key_vault_secret_1.DataAzurermKeyVaultSecret(this, `${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-secret`, {
129
+ name: secretKey,
130
+ keyVaultId: keyVaultData.id,
131
+ provider: this.azurermProvider,
132
+ });
133
+ if (!secretValueData)
134
+ throw new Error(`Unable to resolve secret:${secretKey}`);
135
+ return secretValueData.value;
136
+ }
112
137
  /**
113
138
  * @summary Create the pages project
114
139
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.50.0",
3
+ "version": "9.52.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -44,6 +44,9 @@ export class AzureAppConfigurationManager {
44
44
  ...props,
45
45
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.appConfiguration),
46
46
  resourceGroupName: resourceGroup.name,
47
+ identity: {
48
+ type: 'SystemAssigned',
49
+ },
47
50
  tags: props.tags ?? {
48
51
  environment: scope.props.stage,
49
52
  },
@@ -1,7 +1,7 @@
1
1
  import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
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
- import { Resource } from '../../.gen/providers/azapi/resource'
4
+ import { FunctionAppFlexConsumption } from '@cdktf/provider-azurerm/lib/function-app-flex-consumption'
5
5
  import { LocalExec, Provider } from 'cdktf-local-exec'
6
6
  import { CommonAzureConstruct } from '../../common'
7
7
  import { createAzureTfOutput } from '../../utils'
@@ -103,69 +103,27 @@ export class AzureFunctionManager {
103
103
 
104
104
  if (!resourceGroup) throw `Resource group undefined for ${id}`
105
105
 
106
- const functionApp = new Resource(scope, `${id}-fa`, {
107
- type: 'Microsoft.Web/sites@2024-04-01',
106
+ const functionApp = new FunctionAppFlexConsumption(scope, `${id}-fc`, {
107
+ ...props,
108
108
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.functionApp),
109
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
- alwaysReady: props.alwaysReady,
137
- instanceMemoryMB: props.instanceMemory ?? 2048,
138
- maximumInstanceCount: props.maximumInstanceCount ?? 40,
139
- triggers: {},
140
- },
141
- },
142
-
143
- siteConfig: {
144
- appSettings: props.appSettings.concat([
145
- {
146
- name: 'FUNCTIONS_EXTENSION_VERSION',
147
- value: '~4',
148
- },
149
- {
150
- name: 'AzureWebJobsStorage',
151
- value: props.storageConnectionString,
152
- },
153
- {
154
- name: 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
155
- value: props.storageConnectionString,
156
- },
157
- ]),
158
- connectionStrings: props.connectionStrings,
159
- minTlsVersion: props.minTlsVersion ?? '1.3',
160
- },
161
- },
110
+ resourceGroupName: resourceGroup.name,
111
+ runtimeName: props.runtimeName ?? 'node',
112
+ runtimeVersion: props.runtimeVersion ?? '20',
113
+ storageAuthenticationType: props.storageAuthenticationType ?? 'StorageAccountConnectionString',
114
+ storageContainerType: props.storageContainerType ?? 'blobContainer',
115
+ maximumInstanceCount: props.maximumInstanceCount ?? 40,
116
+ instanceMemoryInMb: props.instanceMemoryInMb ?? 2048,
117
+ siteConfig: {
118
+ http2Enabled: props.siteConfig.http2Enabled ?? true,
119
+ ...props.siteConfig,
120
+ },
121
+ identity: props.identity ?? {
122
+ type: 'SystemAssigned',
123
+ },
124
+ tags: props.tags ?? {
125
+ environment: scope.props.stage,
162
126
  },
163
-
164
- identity: [{ type: 'SystemAssigned' }],
165
-
166
- ignoreMissingProperty: true,
167
- ignoreCasing: true,
168
- schemaValidationEnabled: false,
169
127
  })
170
128
 
171
129
  new Provider(scope, `${id}-local-exec-provider`)
@@ -1,31 +1,12 @@
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 { ResourceConfig } from '../../.gen/providers/azapi/resource'
3
+ import { FunctionAppFlexConsumptionConfig } from '@cdktf/provider-azurerm/lib/function-app-flex-consumption'
4
4
 
5
5
  export interface FunctionAppProps extends LinuxFunctionAppConfig {}
6
6
 
7
7
  export interface FunctionProps extends FunctionAppFunctionConfig {}
8
8
 
9
- export interface FunctionAppFlexConsumptionProps {
10
- alwaysReady?: any
11
- appServicePlanId: string
12
- appSettings: any
13
- blobEndpoint: string
14
- connectionStrings: any
15
- containerName: string
16
- deploymentAuthenticationType?: string
17
- deploymentStorageType?: string
18
- deploySource: string
19
- httpsOnly?: string
20
- instanceMemory?: number
21
- kind?: string
22
- maximumInstanceCount?: number
23
- name: string
24
- resourceGroupName: string
25
- runtime?: string
26
- runtimeVersion?: string
27
- storageAccountConnectionStringName?: string
28
- storageConnectionString: string
9
+ export interface FunctionAppFlexConsumptionProps extends FunctionAppFlexConsumptionConfig {
29
10
  sourceCodeHash: string
30
- minTlsVersion?: string
11
+ deploySource: string
31
12
  }
@@ -45,6 +45,8 @@ export class AzureLogAnalyticsWorkspaceManager {
45
45
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.logAnalyticsWorkspace),
46
46
  location: resourceGroup.location,
47
47
  resourceGroupName: resourceGroup.name,
48
+ sku: props.sku ?? 'PerGB2018',
49
+ retentionInDays: props.retentionInDays ?? 30,
48
50
  tags: props.tags ?? {
49
51
  environment: scope.props.stage,
50
52
  },
@@ -1,5 +1,7 @@
1
1
  import { DataAwsSecretsmanagerSecret } from '@cdktf/provider-aws/lib/data-aws-secretsmanager-secret'
2
2
  import { DataAwsSecretsmanagerSecretVersion } from '@cdktf/provider-aws/lib/data-aws-secretsmanager-secret-version'
3
+ import { DataAzurermKeyVault } from '@cdktf/provider-azurerm/lib/data-azurerm-key-vault'
4
+ import { DataAzurermKeyVaultSecret } from '@cdktf/provider-azurerm/lib/data-azurerm-key-vault-secret'
3
5
  import { DataCloudflareZone } from '@cdktf/provider-cloudflare/lib/data-cloudflare-zone'
4
6
  import { PagesDomain } from '@cdktf/provider-cloudflare/lib/pages-domain'
5
7
  import { PagesProject } from '@cdktf/provider-cloudflare/lib/pages-project'
@@ -120,6 +122,37 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
120
122
  return Fn.lookup(Fn.jsondecode(secretVersion.secretString), secretKey)
121
123
  }
122
124
 
125
+ /**
126
+ * @summary Resolve secrets from Azure Key Vault
127
+ *
128
+ * @param resourceGroupName the resource group name where the key vault is located
129
+ * @param keyVaultName the key vault name
130
+ * @param secretKey the secret key
131
+ * @returns the secret value
132
+ */
133
+ protected resolveSecretFromAzure(resourceGroupName: string, keyVaultName: string, secretKey: string) {
134
+ const keyVaultData = new DataAzurermKeyVault(
135
+ this,
136
+ `${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-vault`,
137
+ {
138
+ resourceGroupName: resourceGroupName,
139
+ name: keyVaultName,
140
+ provider: this.azurermProvider,
141
+ }
142
+ )
143
+ const secretValueData = new DataAzurermKeyVaultSecret(
144
+ this,
145
+ `${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-secret`,
146
+ {
147
+ name: secretKey,
148
+ keyVaultId: keyVaultData.id,
149
+ provider: this.azurermProvider,
150
+ }
151
+ )
152
+ if (!secretValueData) throw new Error(`Unable to resolve secret:${secretKey}`)
153
+ return secretValueData.value
154
+ }
155
+
123
156
  /**
124
157
  * @summary Create the pages project
125
158
  */