@gradientedge/cdk-utils-azure 2.12.0 → 2.13.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/construct/rest-api-with-cache/main.d.ts +2 -2
- package/dist/src/construct/rest-api-with-cache/main.js +28 -12
- package/dist/src/construct/rest-api-with-cache/types.d.ts +6 -4
- package/dist/src/construct/site-with-webapp/main.js +1 -1
- package/dist/src/services/api-management/main.d.ts +8 -4
- package/dist/src/services/api-management/main.js +16 -6
- package/dist/src/services/redis/main.d.ts +8 -7
- package/dist/src/services/redis/main.js +24 -18
- package/dist/src/services/redis/types.d.ts +10 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AzureRestApi } from '../rest-api/main.js';
|
|
2
2
|
import { AzureApiWithCache, AzureRestApiWithCacheProps } from './types.js';
|
|
3
3
|
/**
|
|
4
|
-
* Provides a construct to create and deploy an Azure API Management service with Redis cache integration
|
|
4
|
+
* Provides a construct to create and deploy an Azure API Management service with Azure Managed Redis (Enterprise) cache integration
|
|
5
5
|
* @example
|
|
6
6
|
* import { AzureRestApiWithCache, AzureRestApiWithCacheProps } from '@gradientedge/cdk-utils'
|
|
7
7
|
*
|
|
@@ -24,7 +24,7 @@ export declare class AzureRestApiWithCache extends AzureRestApi {
|
|
|
24
24
|
*/
|
|
25
25
|
initResources(): void;
|
|
26
26
|
/**
|
|
27
|
-
* @summary Method to create the
|
|
27
|
+
* @summary Method to create the Azure Managed Redis (Enterprise) cluster and database
|
|
28
28
|
*/
|
|
29
29
|
protected createRedisCache(): void;
|
|
30
30
|
/**
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { listDatabaseKeysOutput } from '@pulumi/azure-native/redisenterprise/index.js';
|
|
2
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
1
3
|
import { AzureRestApi } from '../rest-api/main.js';
|
|
2
4
|
/**
|
|
3
|
-
* Provides a construct to create and deploy an Azure API Management service with Redis cache integration
|
|
5
|
+
* Provides a construct to create and deploy an Azure API Management service with Azure Managed Redis (Enterprise) cache integration
|
|
4
6
|
* @example
|
|
5
7
|
* import { AzureRestApiWithCache, AzureRestApiWithCacheProps } from '@gradientedge/cdk-utils'
|
|
6
8
|
*
|
|
@@ -32,38 +34,52 @@ export class AzureRestApiWithCache extends AzureRestApi {
|
|
|
32
34
|
this.createRedisCacheApiManagement();
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
|
-
* @summary Method to create the
|
|
37
|
+
* @summary Method to create the Azure Managed Redis (Enterprise) cluster and database
|
|
36
38
|
*/
|
|
37
39
|
createRedisCache() {
|
|
38
|
-
|
|
40
|
+
const result = this.redisManager.createManagedRedis(this.id, this, {
|
|
39
41
|
...this.props.apiManagementManagedRedis,
|
|
40
|
-
|
|
42
|
+
clusterName: this.id,
|
|
41
43
|
location: this.resourceGroup.location,
|
|
42
44
|
resourceGroupName: this.resourceGroup.name,
|
|
43
|
-
}, { ignoreChanges: ['location'] });
|
|
45
|
+
}, this.props.apiManagementManagedRedisDatabase, { ignoreChanges: ['location'] });
|
|
46
|
+
this.api.redisCluster = result.cluster;
|
|
47
|
+
this.api.redisDatabase = result.database;
|
|
44
48
|
}
|
|
45
49
|
/**
|
|
46
50
|
* @summary Method to create the Redis cache connection string secret in Key Vault
|
|
47
51
|
*/
|
|
48
52
|
createRedisCacheSecret() {
|
|
53
|
+
const connectionString = pulumi
|
|
54
|
+
.all([
|
|
55
|
+
this.api.redisCluster.hostName,
|
|
56
|
+
this.api.redisCluster.name,
|
|
57
|
+
this.api.redisDatabase.name,
|
|
58
|
+
this.resourceGroup.name,
|
|
59
|
+
])
|
|
60
|
+
.apply(([hostName, clusterName, databaseName, resourceGroupName]) => listDatabaseKeysOutput({
|
|
61
|
+
clusterName,
|
|
62
|
+
databaseName,
|
|
63
|
+
resourceGroupName,
|
|
64
|
+
}).apply(keys => `${hostName}:10000,password=${keys.primaryKey},ssl=True,abortConnect=False`));
|
|
49
65
|
this.api.redisNamedValueSecret = this.keyVaultManager.createKeyVaultSecret(`${this.id}-key-vault-redis-namespace-secret`, this, {
|
|
50
66
|
vaultName: this.api.authKeyVault.name,
|
|
51
|
-
secretName: `${this.api.
|
|
67
|
+
secretName: `${this.api.redisCluster.name}key`,
|
|
52
68
|
resourceGroupName: this.resourceGroup.name,
|
|
53
69
|
properties: {
|
|
54
|
-
value:
|
|
70
|
+
value: connectionString,
|
|
55
71
|
},
|
|
56
|
-
}, { dependsOn: [this.api.
|
|
72
|
+
}, { dependsOn: [this.api.redisCluster, this.api.redisDatabase, this.api.namedValueRoleAssignment] });
|
|
57
73
|
}
|
|
58
74
|
/**
|
|
59
75
|
* @summary Method to create the API Management named value for the Redis cache secret
|
|
60
76
|
*/
|
|
61
77
|
createRedisCacheNamespace() {
|
|
62
78
|
this.api.redisNamedValue = this.apiManagementManager.createNamedValue(`${this.id}-redis-nv`, this, {
|
|
63
|
-
displayName: `${this.api.
|
|
79
|
+
displayName: `${this.api.redisCluster.name}key`,
|
|
64
80
|
resourceGroupName: this.resourceGroup.name,
|
|
65
81
|
serviceName: this.api.apim.name,
|
|
66
|
-
namedValueId: `${this.api.
|
|
82
|
+
namedValueId: `${this.api.redisCluster.name}key`,
|
|
67
83
|
secret: true,
|
|
68
84
|
keyVault: {
|
|
69
85
|
secretIdentifier: this.api.redisNamedValueSecret.id,
|
|
@@ -77,9 +93,9 @@ export class AzureRestApiWithCache extends AzureRestApi {
|
|
|
77
93
|
this.apiManagementManager.createCache(`${this.id}-am-redis-cache`, this, {
|
|
78
94
|
serviceName: this.api.apim.name,
|
|
79
95
|
connectionString: `{{${this.api.redisNamedValue.name}}}`,
|
|
80
|
-
cacheId: this.api.
|
|
96
|
+
cacheId: this.api.redisCluster.id,
|
|
81
97
|
resourceGroupName: this.resourceGroup.name,
|
|
82
|
-
useFromLocation: this.api.
|
|
98
|
+
useFromLocation: this.api.redisCluster.location,
|
|
83
99
|
description: `Redis cache for ${this.api.apim.name}`,
|
|
84
100
|
});
|
|
85
101
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { NamedValue } from '@pulumi/azure-native/apimanagement/index.js';
|
|
2
2
|
import { Secret } from '@pulumi/azure-native/keyvault/index.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Database, RedisEnterprise } from '@pulumi/azure-native/redisenterprise/index.js';
|
|
4
|
+
import { RedisDatabaseProps, RedisEnterpriseClusterProps } from '../../index.js';
|
|
5
5
|
import { AzureApi, AzureRestApiProps } from '../index.js';
|
|
6
6
|
/** @category Interface */
|
|
7
7
|
export interface AzureRestApiWithCacheProps extends AzureRestApiProps {
|
|
8
|
-
apiManagementManagedRedis:
|
|
8
|
+
apiManagementManagedRedis: RedisEnterpriseClusterProps;
|
|
9
|
+
apiManagementManagedRedisDatabase?: Partial<RedisDatabaseProps>;
|
|
9
10
|
}
|
|
10
11
|
/** @category Interface */
|
|
11
12
|
export interface AzureApiWithCache extends AzureApi {
|
|
12
|
-
|
|
13
|
+
redisCluster: RedisEnterprise;
|
|
14
|
+
redisDatabase: Database;
|
|
13
15
|
redisNamedValueSecret: Secret;
|
|
14
16
|
redisNamedValue: NamedValue;
|
|
15
17
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Database, RedisEnterprise } from '@pulumi/azure-native/redisenterprise/index.js';
|
|
2
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
2
3
|
import { ResourceOptions } from '@pulumi/pulumi';
|
|
3
4
|
import { CommonAzureConstruct } from '../../common/index.js';
|
|
4
5
|
import { ApiDiagnosticProps, ApiManagementApiProps, ApiManagementBackendProps, ApiManagementProps, ApiOperationPolicyProps, ApiOperationProps, ApiPolicyProps, ApiSubscriptionProps, CacheProps, LoggerProps, NamedValueProps, ResolveApiManagementProps } from './types.js';
|
|
@@ -27,11 +28,14 @@ export declare class AzureApiManagementManager {
|
|
|
27
28
|
* @param scope scope in which this resource is defined
|
|
28
29
|
* @param props API Management properties
|
|
29
30
|
* @param applicationInsightsKey Optional Application Insights instrumentation key for logging
|
|
30
|
-
* @param externalRedisCache Optional external Redis
|
|
31
|
+
* @param externalRedisCache Optional external Azure Managed Redis (Enterprise) cluster and database for API Management caching
|
|
31
32
|
* @param resourceOptions Optional settings to control resource behaviour
|
|
32
33
|
* @see [Pulumi Azure Native API Management]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
|
|
33
34
|
*/
|
|
34
|
-
createApiManagementService(id: string, scope: CommonAzureConstruct, props: ApiManagementProps, applicationInsightsKey?: string, externalRedisCache?:
|
|
35
|
+
createApiManagementService(id: string, scope: CommonAzureConstruct, props: ApiManagementProps, applicationInsightsKey?: string, externalRedisCache?: {
|
|
36
|
+
cluster: RedisEnterprise;
|
|
37
|
+
database: Database;
|
|
38
|
+
}, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/apiManagementService.js").ApiManagementService;
|
|
35
39
|
/**
|
|
36
40
|
* @summary Method to resolve an existing API Management service
|
|
37
41
|
* @param id scoped id of the resource
|
|
@@ -40,7 +44,7 @@ export declare class AzureApiManagementManager {
|
|
|
40
44
|
* @param resourceOptions Optional settings to control resource behaviour
|
|
41
45
|
* @see [Pulumi Azure Native API Management Lookup]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
|
|
42
46
|
*/
|
|
43
|
-
resolveApiManagementService(id: string, scope: CommonAzureConstruct, props: ResolveApiManagementProps, resourceOptions?: ResourceOptions):
|
|
47
|
+
resolveApiManagementService(id: string, scope: CommonAzureConstruct, props: ResolveApiManagementProps, resourceOptions?: ResourceOptions): pulumi.Output<import("@pulumi/azure-native/apimanagement/getApiManagementService.js").GetApiManagementServiceResult>;
|
|
44
48
|
/**
|
|
45
49
|
* @summary Method to create a new API Management backend
|
|
46
50
|
* @param id scoped id of the resource
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Api, ApiDiagnostic, ApiManagementService, ApiOperation, ApiOperationPolicy, ApiPolicy, Backend, BackendProtocol, Cache, getApiManagementServiceOutput, Logger, LoggerType, NamedValue, Protocol, Subscription, } from '@pulumi/azure-native/apimanagement/index.js';
|
|
2
|
+
import { listDatabaseKeysOutput } from '@pulumi/azure-native/redisenterprise/index.js';
|
|
3
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
2
4
|
/**
|
|
3
5
|
* Provides operations on Azure API Management using Pulumi
|
|
4
6
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -24,7 +26,7 @@ export class AzureApiManagementManager {
|
|
|
24
26
|
* @param scope scope in which this resource is defined
|
|
25
27
|
* @param props API Management properties
|
|
26
28
|
* @param applicationInsightsKey Optional Application Insights instrumentation key for logging
|
|
27
|
-
* @param externalRedisCache Optional external Redis
|
|
29
|
+
* @param externalRedisCache Optional external Azure Managed Redis (Enterprise) cluster and database for API Management caching
|
|
28
30
|
* @param resourceOptions Optional settings to control resource behaviour
|
|
29
31
|
* @see [Pulumi Azure Native API Management]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
|
|
30
32
|
*/
|
|
@@ -60,16 +62,24 @@ export class AzureApiManagementManager {
|
|
|
60
62
|
},
|
|
61
63
|
}, { parent: scope, dependsOn: [apiManagementService] });
|
|
62
64
|
}
|
|
63
|
-
// Create Redis cache connection if external Redis is provided
|
|
65
|
+
// Create Redis cache connection if external Azure Managed Redis (Enterprise) is provided
|
|
64
66
|
if (externalRedisCache) {
|
|
67
|
+
const { cluster, database } = externalRedisCache;
|
|
68
|
+
const connectionString = pulumi
|
|
69
|
+
.all([cluster.hostName, cluster.name, database.name])
|
|
70
|
+
.apply(([hostName, clusterName, databaseName]) => listDatabaseKeysOutput({
|
|
71
|
+
clusterName,
|
|
72
|
+
databaseName,
|
|
73
|
+
resourceGroupName,
|
|
74
|
+
}).apply(keys => `${hostName}:10000,password=${keys.primaryKey},ssl=True,abortConnect=False`));
|
|
65
75
|
new Cache(`${id}-am-redis-cache`, {
|
|
66
76
|
cacheId: scope.resourceNameFormatter.format(props.serviceName?.toString(), scope.props.resourceNameOptions?.apiManagementRedisCache),
|
|
67
77
|
serviceName: apiManagementService.name,
|
|
68
78
|
resourceGroupName: resourceGroupName,
|
|
69
|
-
connectionString:
|
|
70
|
-
useFromLocation:
|
|
71
|
-
resourceId:
|
|
72
|
-
}, { parent: scope, dependsOn: apiManagementService });
|
|
79
|
+
connectionString: connectionString,
|
|
80
|
+
useFromLocation: cluster.location,
|
|
81
|
+
resourceId: cluster.id,
|
|
82
|
+
}, { parent: scope, dependsOn: [apiManagementService, cluster, database] });
|
|
73
83
|
}
|
|
74
84
|
return apiManagementService;
|
|
75
85
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ResourceOptions } from '@pulumi/pulumi';
|
|
2
2
|
import { CommonAzureConstruct } from '../../common/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ManagedRedisResult, RedisDatabaseProps, RedisEnterpriseClusterProps } from './types.js';
|
|
4
4
|
/**
|
|
5
|
-
* Provides operations on Azure Redis using Pulumi
|
|
5
|
+
* Provides operations on Azure Managed Redis (Enterprise) using Pulumi
|
|
6
6
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
7
7
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
8
8
|
* @example
|
|
@@ -13,7 +13,7 @@ import { RedisProps } from './types.js';
|
|
|
13
13
|
* constructor(name: string, props: CommonAzureStackProps) {
|
|
14
14
|
* super(name, props)
|
|
15
15
|
* this.props = props
|
|
16
|
-
* this.redisManager.createManagedRedis('MyManagedRedis', this,
|
|
16
|
+
* this.redisManager.createManagedRedis('MyManagedRedis', this, { cluster: clusterProps, database: databaseProps })
|
|
17
17
|
* }
|
|
18
18
|
* }
|
|
19
19
|
* ```
|
|
@@ -21,12 +21,13 @@ import { RedisProps } from './types.js';
|
|
|
21
21
|
*/
|
|
22
22
|
export declare class AzureRedisManager {
|
|
23
23
|
/**
|
|
24
|
-
* @summary Method to create a new
|
|
24
|
+
* @summary Method to create a new Azure Managed Redis (Enterprise) cluster with a database
|
|
25
25
|
* @param id scoped id of the resource
|
|
26
26
|
* @param scope scope in which this resource is defined
|
|
27
|
-
* @param
|
|
27
|
+
* @param clusterProps redis enterprise cluster properties
|
|
28
|
+
* @param databaseProps optional redis database properties (created with defaults if omitted)
|
|
28
29
|
* @param resourceOptions Optional settings to control resource behaviour
|
|
29
|
-
* @see [Pulumi Azure Native Redis]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/
|
|
30
|
+
* @see [Pulumi Azure Native Redis Enterprise]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/redisenterprise/redisenterprise/}
|
|
30
31
|
*/
|
|
31
|
-
createManagedRedis(id: string, scope: CommonAzureConstruct,
|
|
32
|
+
createManagedRedis(id: string, scope: CommonAzureConstruct, clusterProps: RedisEnterpriseClusterProps, databaseProps?: Partial<RedisDatabaseProps>, resourceOptions?: ResourceOptions): ManagedRedisResult;
|
|
32
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Database, RedisEnterprise, SkuName } from '@pulumi/azure-native/redisenterprise/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Provides operations on Azure Redis using Pulumi
|
|
3
|
+
* Provides operations on Azure Managed Redis (Enterprise) using Pulumi
|
|
4
4
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
5
5
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
6
6
|
* @example
|
|
@@ -11,7 +11,7 @@ import { Redis, SkuFamily, SkuName } from '@pulumi/azure-native/redis/index.js';
|
|
|
11
11
|
* constructor(name: string, props: CommonAzureStackProps) {
|
|
12
12
|
* super(name, props)
|
|
13
13
|
* this.props = props
|
|
14
|
-
* this.redisManager.createManagedRedis('MyManagedRedis', this,
|
|
14
|
+
* this.redisManager.createManagedRedis('MyManagedRedis', this, { cluster: clusterProps, database: databaseProps })
|
|
15
15
|
* }
|
|
16
16
|
* }
|
|
17
17
|
* ```
|
|
@@ -19,35 +19,41 @@ import { Redis, SkuFamily, SkuName } from '@pulumi/azure-native/redis/index.js';
|
|
|
19
19
|
*/
|
|
20
20
|
export class AzureRedisManager {
|
|
21
21
|
/**
|
|
22
|
-
* @summary Method to create a new
|
|
22
|
+
* @summary Method to create a new Azure Managed Redis (Enterprise) cluster with a database
|
|
23
23
|
* @param id scoped id of the resource
|
|
24
24
|
* @param scope scope in which this resource is defined
|
|
25
|
-
* @param
|
|
25
|
+
* @param clusterProps redis enterprise cluster properties
|
|
26
|
+
* @param databaseProps optional redis database properties (created with defaults if omitted)
|
|
26
27
|
* @param resourceOptions Optional settings to control resource behaviour
|
|
27
|
-
* @see [Pulumi Azure Native Redis]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/
|
|
28
|
+
* @see [Pulumi Azure Native Redis Enterprise]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/redisenterprise/redisenterprise/}
|
|
28
29
|
*/
|
|
29
|
-
createManagedRedis(id, scope,
|
|
30
|
-
if (!
|
|
30
|
+
createManagedRedis(id, scope, clusterProps, databaseProps, resourceOptions) {
|
|
31
|
+
if (!clusterProps)
|
|
31
32
|
throw new Error(`Props undefined for ${id}`);
|
|
32
33
|
// Get resource group name
|
|
33
34
|
const resourceGroupName = scope.props.resourceGroupName
|
|
34
35
|
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
35
|
-
:
|
|
36
|
+
: clusterProps.resourceGroupName;
|
|
36
37
|
if (!resourceGroupName)
|
|
37
38
|
throw new Error(`Resource group name undefined for ${id}`);
|
|
38
|
-
|
|
39
|
-
...
|
|
40
|
-
|
|
41
|
-
location:
|
|
39
|
+
const cluster = new RedisEnterprise(`${id}-rc`, {
|
|
40
|
+
...clusterProps,
|
|
41
|
+
clusterName: scope.resourceNameFormatter.format(clusterProps.clusterName?.toString(), scope.props.resourceNameOptions?.managedRedis),
|
|
42
|
+
location: clusterProps.location ?? scope.props.location,
|
|
42
43
|
resourceGroupName: resourceGroupName,
|
|
43
|
-
sku:
|
|
44
|
-
name: SkuName.
|
|
45
|
-
family: SkuFamily.C,
|
|
46
|
-
capacity: 0,
|
|
44
|
+
sku: clusterProps.sku ?? {
|
|
45
|
+
name: SkuName.Balanced_B0,
|
|
47
46
|
},
|
|
48
|
-
tags:
|
|
47
|
+
tags: clusterProps.tags ?? {
|
|
49
48
|
environment: scope.props.stage,
|
|
50
49
|
},
|
|
51
50
|
}, { parent: scope, ...resourceOptions });
|
|
51
|
+
const database = new Database(`${id}-db`, {
|
|
52
|
+
...databaseProps,
|
|
53
|
+
clusterName: cluster.name,
|
|
54
|
+
resourceGroupName: resourceGroupName,
|
|
55
|
+
databaseName: databaseProps?.databaseName ?? 'default',
|
|
56
|
+
}, { parent: scope, dependsOn: [cluster], ...resourceOptions });
|
|
57
|
+
return { cluster, database };
|
|
52
58
|
}
|
|
53
59
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabaseArgs, RedisEnterpriseArgs } from '@pulumi/azure-native/redisenterprise/index.js';
|
|
2
2
|
/** @category Interface */
|
|
3
|
-
export interface
|
|
3
|
+
export interface RedisEnterpriseClusterProps extends RedisEnterpriseArgs {
|
|
4
|
+
}
|
|
5
|
+
/** @category Interface */
|
|
6
|
+
export interface RedisDatabaseProps extends DatabaseArgs {
|
|
7
|
+
}
|
|
8
|
+
/** @category Interface */
|
|
9
|
+
export interface ManagedRedisResult {
|
|
10
|
+
cluster: import('@pulumi/azure-native/redisenterprise/index.js').RedisEnterprise;
|
|
11
|
+
database: import('@pulumi/azure-native/redisenterprise/index.js').Database;
|
|
4
12
|
}
|