@gradientedge/cdk-utils 10.1.0 → 10.3.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/constants.d.ts +3 -2
- package/dist/src/lib/azure/common/constants.js +2 -1
- package/dist/src/lib/azure/common/construct.d.ts +26 -12
- package/dist/src/lib/azure/common/construct.js +31 -45
- package/dist/src/lib/azure/common/resource-name-formatter.d.ts +9 -4
- package/dist/src/lib/azure/common/resource-name-formatter.js +9 -5
- package/dist/src/lib/azure/common/stack.d.ts +18 -32
- package/dist/src/lib/azure/common/stack.js +77 -74
- package/dist/src/lib/azure/common/tagging.d.ts +29 -8
- package/dist/src/lib/azure/common/tagging.js +72 -26
- package/dist/src/lib/azure/common/types.d.ts +19 -4
- package/dist/src/lib/azure/services/api-management/main.d.ts +29 -32
- package/dist/src/lib/azure/services/api-management/main.js +100 -121
- package/dist/src/lib/azure/services/api-management/types.d.ts +33 -18
- package/dist/src/lib/azure/services/app-configuration/main.d.ts +6 -7
- package/dist/src/lib/azure/services/app-configuration/main.js +23 -26
- package/dist/src/lib/azure/services/app-configuration/types.d.ts +2 -2
- package/dist/src/lib/azure/services/app-service/main.d.ts +10 -12
- package/dist/src/lib/azure/services/app-service/main.js +37 -49
- package/dist/src/lib/azure/services/app-service/types.d.ts +4 -4
- package/dist/src/lib/azure/services/application-insights/main.d.ts +7 -8
- package/dist/src/lib/azure/services/application-insights/main.js +20 -26
- package/dist/src/lib/azure/services/application-insights/types.d.ts +2 -4
- package/dist/src/lib/azure/services/cosmosdb/main.d.ts +12 -15
- package/dist/src/lib/azure/services/cosmosdb/main.js +42 -61
- package/dist/src/lib/azure/services/cosmosdb/types.d.ts +4 -6
- package/dist/src/lib/azure/services/dns/main.d.ts +13 -17
- package/dist/src/lib/azure/services/dns/main.js +33 -51
- package/dist/src/lib/azure/services/dns/types.d.ts +5 -8
- package/dist/src/lib/azure/services/eventgrid/main.d.ts +20 -22
- package/dist/src/lib/azure/services/eventgrid/main.js +61 -89
- package/dist/src/lib/azure/services/eventgrid/types.d.ts +7 -8
- package/dist/src/lib/azure/services/function/main.d.ts +15 -15
- package/dist/src/lib/azure/services/function/main.js +54 -59
- package/dist/src/lib/azure/services/function/types.d.ts +18 -6
- package/dist/src/lib/azure/services/index.d.ts +1 -1
- package/dist/src/lib/azure/services/index.js +1 -1
- package/dist/src/lib/azure/services/key-vault/main.d.ts +6 -7
- package/dist/src/lib/azure/services/key-vault/main.js +29 -28
- package/dist/src/lib/azure/services/key-vault/types.d.ts +3 -2
- package/dist/src/lib/azure/services/monitor/main.d.ts +7 -8
- package/dist/src/lib/azure/services/monitor/main.js +10 -15
- package/dist/src/lib/azure/services/monitor/types.d.ts +2 -2
- package/dist/src/lib/azure/services/operational-insights/main.d.ts +29 -0
- package/dist/src/lib/azure/services/operational-insights/main.js +50 -0
- package/dist/src/lib/azure/services/operational-insights/types.d.ts +3 -0
- package/dist/src/lib/azure/services/redis/main.d.ts +8 -9
- package/dist/src/lib/azure/services/redis/main.js +24 -26
- package/dist/src/lib/azure/services/redis/types.d.ts +2 -2
- package/dist/src/lib/azure/services/resource-group/main.d.ts +6 -7
- package/dist/src/lib/azure/services/resource-group/main.js +9 -14
- package/dist/src/lib/azure/services/resource-group/types.d.ts +2 -2
- package/dist/src/lib/azure/services/servicebus/main.d.ts +17 -22
- package/dist/src/lib/azure/services/servicebus/main.js +47 -70
- package/dist/src/lib/azure/services/servicebus/types.d.ts +6 -10
- package/dist/src/lib/azure/services/storage/main.d.ts +24 -27
- package/dist/src/lib/azure/services/storage/main.js +70 -88
- package/dist/src/lib/azure/services/storage/types.d.ts +10 -8
- package/dist/src/lib/azure/types/index.d.ts +2 -1
- package/dist/src/lib/azure/utils/index.d.ts +19 -3
- package/dist/src/lib/azure/utils/index.js +19 -13
- package/dist/src/lib/cloudflare/common/stack.js +1 -1
- package/dist/src/lib/cloudflare/services/access/main.js +23 -23
- package/dist/src/lib/cloudflare/services/api-shield/main.js +11 -11
- package/dist/src/lib/cloudflare/services/argo/main.js +5 -5
- package/dist/src/lib/cloudflare/services/filter/main.js +3 -3
- package/dist/src/lib/cloudflare/services/firewall/main.js +3 -3
- package/dist/src/lib/cloudflare/services/page/main.js +7 -7
- package/dist/src/lib/cloudflare/services/record/main.js +3 -3
- package/dist/src/lib/cloudflare/services/rule-set/main.d.ts +1 -1
- package/dist/src/lib/cloudflare/services/rule-set/main.js +4 -5
- package/dist/src/lib/cloudflare/services/worker/main.js +13 -13
- package/dist/src/lib/cloudflare/services/zone/main.js +18 -18
- package/package.json +2 -1
- package/src/lib/azure/common/constants.ts +2 -1
- package/src/lib/azure/common/construct.ts +32 -48
- package/src/lib/azure/common/resource-name-formatter.ts +10 -6
- package/src/lib/azure/common/stack.ts +78 -78
- package/src/lib/azure/common/tagging.ts +78 -29
- package/src/lib/azure/common/types.ts +21 -4
- package/src/lib/azure/services/api-management/main.ts +172 -169
- package/src/lib/azure/services/api-management/types.ts +39 -16
- package/src/lib/azure/services/app-configuration/main.ts +33 -31
- package/src/lib/azure/services/app-configuration/types.ts +2 -2
- package/src/lib/azure/services/app-service/main.ts +61 -62
- package/src/lib/azure/services/app-service/types.ts +4 -4
- package/src/lib/azure/services/application-insights/main.ts +29 -30
- package/src/lib/azure/services/application-insights/types.ts +2 -5
- package/src/lib/azure/services/cosmosdb/main.ts +78 -77
- package/src/lib/azure/services/cosmosdb/types.ts +10 -6
- package/src/lib/azure/services/dns/main.ts +65 -72
- package/src/lib/azure/services/dns/types.ts +9 -9
- package/src/lib/azure/services/eventgrid/main.ts +120 -122
- package/src/lib/azure/services/eventgrid/types.ts +13 -8
- package/src/lib/azure/services/function/main.ts +75 -72
- package/src/lib/azure/services/function/types.ts +21 -6
- package/src/lib/azure/services/index.ts +1 -1
- package/src/lib/azure/services/key-vault/main.ts +38 -32
- package/src/lib/azure/services/key-vault/types.ts +4 -2
- package/src/lib/azure/services/monitor/main.ts +17 -21
- package/src/lib/azure/services/monitor/types.ts +2 -2
- package/src/lib/azure/services/operational-insights/main.ts +61 -0
- package/src/lib/azure/services/operational-insights/types.ts +3 -0
- package/src/lib/azure/services/redis/main.ts +30 -30
- package/src/lib/azure/services/redis/types.ts +2 -2
- package/src/lib/azure/services/resource-group/main.ts +20 -20
- package/src/lib/azure/services/resource-group/types.ts +2 -2
- package/src/lib/azure/services/servicebus/main.ts +103 -94
- package/src/lib/azure/services/servicebus/types.ts +17 -11
- package/src/lib/azure/services/storage/main.ts +113 -114
- package/src/lib/azure/services/storage/types.ts +16 -8
- package/src/lib/azure/types/index.ts +2 -1
- package/src/lib/azure/utils/index.ts +20 -22
- package/src/lib/cloudflare/common/stack.ts +1 -1
- package/src/lib/cloudflare/services/access/main.ts +114 -58
- package/src/lib/cloudflare/services/api-shield/main.ts +48 -22
- package/src/lib/cloudflare/services/argo/main.ts +17 -9
- package/src/lib/cloudflare/services/filter/main.ts +9 -5
- package/src/lib/cloudflare/services/firewall/main.ts +9 -5
- package/src/lib/cloudflare/services/page/main.ts +27 -15
- package/src/lib/cloudflare/services/record/main.ts +9 -5
- package/src/lib/cloudflare/services/rule-set/main.ts +10 -8
- package/src/lib/cloudflare/services/worker/main.ts +60 -29
- package/src/lib/cloudflare/services/zone/main.ts +75 -35
- package/dist/src/lib/azure/services/log-analytics-workspace/main.d.ts +0 -30
- package/dist/src/lib/azure/services/log-analytics-workspace/main.js +0 -55
- package/dist/src/lib/azure/services/log-analytics-workspace/types.d.ts +0 -3
- package/src/lib/azure/services/log-analytics-workspace/main.ts +0 -61
- package/src/lib/azure/services/log-analytics-workspace/types.ts +0 -3
- /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.d.ts +0 -0
- /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.js +0 -0
- /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/types.js +0 -0
- /package/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.ts +0 -0
|
@@ -1,32 +1,78 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
2
2
|
import { RESOURCES_TO_EXCLUDE_TAGS } from './constants.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @summary Check if a resource type is taggable
|
|
5
|
+
* @param resourceType The Pulumi resource type (e.g., 'azure-native:resources:ResourceGroup')
|
|
6
|
+
* @returns True if the resource supports tags, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export function isTaggableResource(resourceType) {
|
|
9
|
+
// Extract the resource name from the type (e.g., 'ResourceGroup' from 'azure-native:resources:ResourceGroup')
|
|
10
|
+
const resourceName = resourceType.split(':').pop() || '';
|
|
11
|
+
// Check if this resource is in the exclusion list
|
|
12
|
+
if (RESOURCES_TO_EXCLUDE_TAGS.has(resourceName)) {
|
|
13
|
+
return false;
|
|
12
14
|
}
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
// Most Azure resources support tags, but we can add more specific checks here if needed
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @summary Register a stack transformation to automatically apply tags to Azure resources
|
|
20
|
+
* @param defaultTags The default tags to apply to all resources
|
|
21
|
+
* @param tagsToIgnore Optional list of tag keys to ignore in lifecycle management
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* registerTagTransformation({ environment: 'production', team: 'platform' })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function registerTagTransformation(defaultTags, tagsToIgnore = []) {
|
|
28
|
+
pulumi.runtime.registerStackTransformation((args) => {
|
|
29
|
+
// Only process taggable resources
|
|
30
|
+
if (!isTaggableResource(args.type)) {
|
|
31
|
+
return undefined;
|
|
18
32
|
}
|
|
19
|
-
//
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
return;
|
|
33
|
+
// Check if the resource has a tags property
|
|
34
|
+
if (!args.props || typeof args.props !== 'object') {
|
|
35
|
+
return undefined;
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
// Merge default tags with resource-specific tags (resource tags take precedence)
|
|
38
|
+
const currentTags = args.props.tags || {};
|
|
39
|
+
const mergedTags = { ...defaultTags, ...currentTags };
|
|
40
|
+
// Apply the merged tags
|
|
41
|
+
const newProps = {
|
|
42
|
+
...args.props,
|
|
43
|
+
tags: mergedTags,
|
|
44
|
+
};
|
|
45
|
+
// Handle tag ignores via Pulumi's ignoreChanges option
|
|
46
|
+
let newOpts = args.opts;
|
|
47
|
+
if (tagsToIgnore.length > 0) {
|
|
48
|
+
const ignoreChanges = tagsToIgnore.map(tag => `tags.${tag}`);
|
|
49
|
+
newOpts = {
|
|
50
|
+
...args.opts,
|
|
51
|
+
ignoreChanges: [...(args.opts?.ignoreChanges || []), ...ignoreChanges],
|
|
52
|
+
};
|
|
30
53
|
}
|
|
31
|
-
|
|
54
|
+
return {
|
|
55
|
+
props: newProps,
|
|
56
|
+
opts: newOpts,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @summary Helper function to apply tags to a specific resource's properties
|
|
62
|
+
* @param props The resource properties
|
|
63
|
+
* @param defaultTags The default tags to merge with existing tags
|
|
64
|
+
* @returns The properties with merged tags
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const resourceGroupProps = applyTags(props, { environment: 'dev' })
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export function applyTags(props, defaultTags) {
|
|
71
|
+
return {
|
|
72
|
+
...props,
|
|
73
|
+
tags: {
|
|
74
|
+
...defaultTags,
|
|
75
|
+
...(props.tags || {}),
|
|
76
|
+
},
|
|
77
|
+
};
|
|
32
78
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AzurermProviderConfig } from '@cdktf/provider-azurerm/lib/provider/index.js';
|
|
2
|
-
import { AzurermBackendConfig } from 'cdktf';
|
|
3
1
|
import { BaseProps } from '../../common/index.js';
|
|
4
2
|
import { AzureRemoteBackend } from './constants.js';
|
|
5
3
|
/**
|
|
4
|
+
* @interface CommonAzureStackProps
|
|
5
|
+
* @description Common properties for Azure stack configuration using Pulumi
|
|
6
6
|
*/
|
|
7
|
-
export interface CommonAzureStackProps extends BaseProps
|
|
7
|
+
export interface CommonAzureStackProps extends BaseProps {
|
|
8
8
|
resourceGroupName?: string;
|
|
9
9
|
remoteBackend?: AzureRemoteBackendProps;
|
|
10
10
|
globalPrefix?: string;
|
|
@@ -18,9 +18,24 @@ export interface CommonAzureStackProps extends BaseProps, AzurermProviderConfig
|
|
|
18
18
|
defaultTags?: {
|
|
19
19
|
[key: string]: string;
|
|
20
20
|
};
|
|
21
|
+
subscriptionId?: string;
|
|
22
|
+
tenantId?: string;
|
|
23
|
+
clientId?: string;
|
|
24
|
+
clientSecret?: string;
|
|
25
|
+
environment?: string;
|
|
26
|
+
useOidc?: boolean;
|
|
27
|
+
oidcRequestToken?: string;
|
|
28
|
+
oidcRequestUrl?: string;
|
|
29
|
+
useMsi?: boolean;
|
|
30
|
+
msiEndpoint?: string;
|
|
21
31
|
}
|
|
22
|
-
export interface AzureRemoteBackendProps
|
|
32
|
+
export interface AzureRemoteBackendProps {
|
|
23
33
|
type: AzureRemoteBackend;
|
|
34
|
+
storageAccountName?: string;
|
|
35
|
+
containerName?: string;
|
|
36
|
+
resourceGroupName?: string;
|
|
37
|
+
subscriptionId?: string;
|
|
38
|
+
key?: string;
|
|
24
39
|
}
|
|
25
40
|
export interface AzureResourceNameFormatterProps {
|
|
26
41
|
exclude?: boolean;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ApiManagementBackend } from '@cdktf/provider-azurerm/lib/api-management-backend/index.js';
|
|
3
|
-
import { ApiManagementCustomDomain } from '@cdktf/provider-azurerm/lib/api-management-custom-domain/index.js';
|
|
4
|
-
import { ApiManagementLoggerApplicationInsights } from '@cdktf/provider-azurerm/lib/api-management-logger/index.js';
|
|
5
|
-
import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management/index.js';
|
|
6
|
-
import { DataAzurermApiManagement, DataAzurermApiManagementConfig } from '@cdktf/provider-azurerm/lib/data-azurerm-api-management/index.js';
|
|
7
|
-
import { ManagedRedis } from '@cdktf/provider-azurerm/lib/managed-redis/index.js';
|
|
1
|
+
import * as redis from '@pulumi/azure-native/redis/index.js';
|
|
8
2
|
import { CommonAzureConstruct } from '../../common/index.js';
|
|
9
|
-
import { ApiManagementApiProps, ApiManagementBackendProps, ApiManagementCustomDomainProps, ApiManagementProps } from './types.js';
|
|
3
|
+
import { ApiManagementApiProps, ApiManagementBackendProps, ApiManagementCustomDomainProps, ApiManagementProps, ResolveApiManagementProps } from './types.js';
|
|
10
4
|
/**
|
|
11
|
-
* @classdesc Provides operations on Azure
|
|
5
|
+
* @classdesc Provides operations on Azure API Management using Pulumi
|
|
12
6
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
13
7
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
14
8
|
* @example
|
|
15
|
-
* ```
|
|
9
|
+
* ```typescript
|
|
16
10
|
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
17
11
|
*
|
|
18
12
|
* class CustomConstruct extends CommonAzureConstruct {
|
|
19
|
-
* constructor(
|
|
20
|
-
* super(
|
|
13
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
14
|
+
* super(name, props)
|
|
21
15
|
* this.props = props
|
|
22
16
|
* this.apiManagementManager.createApiManagement('MyApiManagement', this, props)
|
|
23
17
|
* }
|
|
@@ -26,43 +20,46 @@ import { ApiManagementApiProps, ApiManagementBackendProps, ApiManagementCustomDo
|
|
|
26
20
|
*/
|
|
27
21
|
export declare class AzureApiManagementManager {
|
|
28
22
|
/**
|
|
29
|
-
* @summary Method to create a new
|
|
23
|
+
* @summary Method to create a new API Management service
|
|
30
24
|
* @param id scoped id of the resource
|
|
31
25
|
* @param scope scope in which this resource is defined
|
|
32
|
-
* @param props
|
|
33
|
-
* @
|
|
26
|
+
* @param props API Management properties
|
|
27
|
+
* @param applicationInsightsKey Optional Application Insights instrumentation key for logging
|
|
28
|
+
* @param externalRedisCache Optional external Redis cache for API Management caching
|
|
29
|
+
* @see [Pulumi Azure Native API Management]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
|
|
34
30
|
*/
|
|
35
|
-
|
|
31
|
+
createApiManagementService(id: string, scope: CommonAzureConstruct, props: ApiManagementProps, applicationInsightsKey?: string, externalRedisCache?: redis.Redis): import("@pulumi/azure-native/apimanagement/apiManagementService.js").ApiManagementService;
|
|
36
32
|
/**
|
|
37
|
-
* @summary Method to resolve an
|
|
33
|
+
* @summary Method to resolve an existing API Management service
|
|
38
34
|
* @param id scoped id of the resource
|
|
39
35
|
* @param scope scope in which this resource is defined
|
|
40
|
-
* @param props
|
|
41
|
-
* @see [
|
|
36
|
+
* @param props API Management lookup properties
|
|
37
|
+
* @see [Pulumi Azure Native API Management Lookup]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
|
|
42
38
|
*/
|
|
43
|
-
|
|
39
|
+
resolveApiManagementService(id: string, scope: CommonAzureConstruct, props: ResolveApiManagementProps): import("@pulumi/pulumi").Output<import("@pulumi/azure-native/apimanagement/getApiManagementService.js").GetApiManagementServiceResult>;
|
|
44
40
|
/**
|
|
45
|
-
* @summary Method to create a new
|
|
41
|
+
* @summary Method to create a new API Management backend
|
|
46
42
|
* @param id scoped id of the resource
|
|
47
43
|
* @param scope scope in which this resource is defined
|
|
48
|
-
* @param props
|
|
49
|
-
* @see [
|
|
44
|
+
* @param props API Management backend properties
|
|
45
|
+
* @see [Pulumi Azure Native API Management Backend]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/backend/}
|
|
50
46
|
*/
|
|
51
|
-
|
|
47
|
+
createBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps): import("@pulumi/azure-native/apimanagement/backend.js").Backend;
|
|
52
48
|
/**
|
|
53
|
-
* @summary Method to create a new
|
|
49
|
+
* @summary Method to create a new API Management API with operations and policies
|
|
54
50
|
* @param id scoped id of the resource
|
|
55
51
|
* @param scope scope in which this resource is defined
|
|
56
|
-
* @param props
|
|
57
|
-
* @see [
|
|
52
|
+
* @param props API Management API properties
|
|
53
|
+
* @see [Pulumi Azure Native API Management API]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/api/}
|
|
58
54
|
*/
|
|
59
|
-
|
|
55
|
+
createApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps): import("@pulumi/azure-native/apimanagement/api.js").Api;
|
|
60
56
|
/**
|
|
61
|
-
* @summary Method to create a new
|
|
57
|
+
* @summary Method to create a new API Management custom domain
|
|
62
58
|
* @param id scoped id of the resource
|
|
63
59
|
* @param scope scope in which this resource is defined
|
|
64
|
-
* @param props
|
|
65
|
-
* @
|
|
60
|
+
* @param props API Management custom domain properties
|
|
61
|
+
* @note In Pulumi Azure Native, custom domains are configured as part of the API Management service resource,
|
|
62
|
+
* not as a separate resource. Use the hostnameConfigurations property when creating the service.
|
|
66
63
|
*/
|
|
67
|
-
createApiManagementCustomDomain(id: string, scope: CommonAzureConstruct, props: ApiManagementCustomDomainProps):
|
|
64
|
+
createApiManagementCustomDomain(id: string, scope: CommonAzureConstruct, props: ApiManagementCustomDomainProps): void;
|
|
68
65
|
}
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ApiManagementApiOperation } from '@cdktf/provider-azurerm/lib/api-management-api-operation/index.js';
|
|
3
|
-
import { ApiManagementApi } from '@cdktf/provider-azurerm/lib/api-management-api/index.js';
|
|
4
|
-
import { ApiManagementBackend } from '@cdktf/provider-azurerm/lib/api-management-backend/index.js';
|
|
5
|
-
import { ApiManagementCustomDomain } from '@cdktf/provider-azurerm/lib/api-management-custom-domain/index.js';
|
|
6
|
-
import { ApiManagementLogger, } from '@cdktf/provider-azurerm/lib/api-management-logger/index.js';
|
|
7
|
-
import { ApiManagementRedisCache } from '@cdktf/provider-azurerm/lib/api-management-redis-cache/index.js';
|
|
8
|
-
import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management/index.js';
|
|
9
|
-
import { DataAzurermApiManagement, } from '@cdktf/provider-azurerm/lib/data-azurerm-api-management/index.js';
|
|
10
|
-
import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js';
|
|
1
|
+
import { Api, ApiManagementService, ApiOperation, ApiOperationPolicy, Backend, BackendProtocol, Cache, getApiManagementServiceOutput, Logger, LoggerType, PolicyContentFormat, Protocol, } from '@pulumi/azure-native/apimanagement/index.js';
|
|
11
2
|
import _ from 'lodash';
|
|
12
|
-
import { createAzureTfOutput } from '../../utils/index.js';
|
|
13
3
|
/**
|
|
14
|
-
* @classdesc Provides operations on Azure
|
|
4
|
+
* @classdesc Provides operations on Azure API Management using Pulumi
|
|
15
5
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
16
6
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
17
7
|
* @example
|
|
18
|
-
* ```
|
|
8
|
+
* ```typescript
|
|
19
9
|
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
20
10
|
*
|
|
21
11
|
* class CustomConstruct extends CommonAzureConstruct {
|
|
22
|
-
* constructor(
|
|
23
|
-
* super(
|
|
12
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
13
|
+
* super(name, props)
|
|
24
14
|
* this.props = props
|
|
25
15
|
* this.apiManagementManager.createApiManagement('MyApiManagement', this, props)
|
|
26
16
|
* }
|
|
@@ -29,135 +19,123 @@ import { createAzureTfOutput } from '../../utils/index.js';
|
|
|
29
19
|
*/
|
|
30
20
|
export class AzureApiManagementManager {
|
|
31
21
|
/**
|
|
32
|
-
* @summary Method to create a new
|
|
22
|
+
* @summary Method to create a new API Management service
|
|
33
23
|
* @param id scoped id of the resource
|
|
34
24
|
* @param scope scope in which this resource is defined
|
|
35
|
-
* @param props
|
|
36
|
-
* @
|
|
25
|
+
* @param props API Management properties
|
|
26
|
+
* @param applicationInsightsKey Optional Application Insights instrumentation key for logging
|
|
27
|
+
* @param externalRedisCache Optional external Redis cache for API Management caching
|
|
28
|
+
* @see [Pulumi Azure Native API Management]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
|
|
37
29
|
*/
|
|
38
|
-
|
|
30
|
+
createApiManagementService(id, scope, props, applicationInsightsKey, externalRedisCache) {
|
|
39
31
|
if (!props)
|
|
40
32
|
throw `Props undefined for ${id}`;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const apiManagement = new ApiManagement(scope, `${id}-am`, {
|
|
33
|
+
// Get resource group name
|
|
34
|
+
const resourceGroupName = scope.props.resourceGroupName
|
|
35
|
+
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
36
|
+
: props.resourceGroupName;
|
|
37
|
+
if (!resourceGroupName)
|
|
38
|
+
throw `Resource group name undefined for ${id}`;
|
|
39
|
+
const apiManagementService = new ApiManagementService(`${id}-am`, {
|
|
49
40
|
...props,
|
|
50
|
-
|
|
51
|
-
resourceGroupName:
|
|
41
|
+
serviceName: scope.resourceNameFormatter.format(props.serviceName?.toString(), scope.props.resourceNameOptions?.apiManagement),
|
|
42
|
+
resourceGroupName: resourceGroupName,
|
|
43
|
+
location: props.location ?? scope.props.location,
|
|
44
|
+
publisherEmail: props.publisherEmail ?? 'noreply@example.com',
|
|
45
|
+
publisherName: props.publisherName ?? 'Default Publisher',
|
|
52
46
|
tags: props.tags ?? {
|
|
53
47
|
environment: scope.props.stage,
|
|
54
48
|
},
|
|
55
|
-
});
|
|
49
|
+
}, { parent: scope });
|
|
50
|
+
// Create logger if Application Insights key is provided
|
|
56
51
|
if (applicationInsightsKey) {
|
|
57
|
-
new
|
|
58
|
-
|
|
59
|
-
resourceGroupName:
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
new Logger(`${id}-am-logger`, {
|
|
53
|
+
loggerId: scope.resourceNameFormatter.format(props.serviceName?.toString(), scope.props.resourceNameOptions?.apiManagementLogger),
|
|
54
|
+
resourceGroupName: resourceGroupName,
|
|
55
|
+
serviceName: apiManagementService.name,
|
|
56
|
+
loggerType: LoggerType.ApplicationInsights,
|
|
57
|
+
credentials: {
|
|
62
58
|
instrumentationKey: applicationInsightsKey,
|
|
63
59
|
},
|
|
64
|
-
});
|
|
60
|
+
}, { parent: scope });
|
|
65
61
|
}
|
|
62
|
+
// Create Redis cache connection if external Redis is provided
|
|
66
63
|
if (externalRedisCache) {
|
|
67
|
-
new
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
new Cache(`${id}-am-redis-cache`, {
|
|
65
|
+
cacheId: scope.resourceNameFormatter.format(props.serviceName?.toString(), scope.props.resourceNameOptions?.apiManagementRedisCache),
|
|
66
|
+
serviceName: apiManagementService.name,
|
|
67
|
+
resourceGroupName: resourceGroupName,
|
|
68
|
+
connectionString: externalRedisCache.hostName.apply(hostName => `${hostName}:10000,password=${externalRedisCache.accessKeys.apply(k => k?.primaryKey)},ssl=True,abortConnect=False`),
|
|
69
|
+
useFromLocation: externalRedisCache.location,
|
|
70
|
+
resourceId: externalRedisCache.id,
|
|
71
|
+
}, { parent: scope });
|
|
74
72
|
}
|
|
75
|
-
|
|
76
|
-
createAzureTfOutput(`${id}-apiManagementFriendlyUniqueId`, scope, apiManagement.friendlyUniqueId);
|
|
77
|
-
createAzureTfOutput(`${id}-apiManagementId`, scope, apiManagement.id);
|
|
78
|
-
return apiManagement;
|
|
73
|
+
return apiManagementService;
|
|
79
74
|
}
|
|
80
75
|
/**
|
|
81
|
-
* @summary Method to resolve an
|
|
76
|
+
* @summary Method to resolve an existing API Management service
|
|
82
77
|
* @param id scoped id of the resource
|
|
83
78
|
* @param scope scope in which this resource is defined
|
|
84
|
-
* @param props
|
|
85
|
-
* @see [
|
|
79
|
+
* @param props API Management lookup properties
|
|
80
|
+
* @see [Pulumi Azure Native API Management Lookup]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
|
|
86
81
|
*/
|
|
87
|
-
|
|
82
|
+
resolveApiManagementService(id, scope, props) {
|
|
88
83
|
if (!props)
|
|
89
84
|
throw `Props undefined for ${id}`;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
93
|
-
: `${props.resourceGroupName}`,
|
|
94
|
-
});
|
|
95
|
-
if (!resourceGroup)
|
|
96
|
-
throw `Resource group undefined for ${id}`;
|
|
97
|
-
const apiManagement = new DataAzurermApiManagement(scope, `${id}-am`, {
|
|
98
|
-
...props,
|
|
99
|
-
name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.dataAzurermApiManagement),
|
|
85
|
+
return getApiManagementServiceOutput({
|
|
86
|
+
serviceName: scope.resourceNameFormatter.format(props.serviceName?.toString(), scope.props.resourceNameOptions?.dataAzurermApiManagement),
|
|
100
87
|
resourceGroupName: scope.props.resourceGroupName
|
|
101
88
|
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
102
|
-
:
|
|
103
|
-
});
|
|
104
|
-
return apiManagement;
|
|
89
|
+
: props.resourceGroupName,
|
|
90
|
+
}, { parent: scope });
|
|
105
91
|
}
|
|
106
92
|
/**
|
|
107
|
-
* @summary Method to create a new
|
|
93
|
+
* @summary Method to create a new API Management backend
|
|
108
94
|
* @param id scoped id of the resource
|
|
109
95
|
* @param scope scope in which this resource is defined
|
|
110
|
-
* @param props
|
|
111
|
-
* @see [
|
|
96
|
+
* @param props API Management backend properties
|
|
97
|
+
* @see [Pulumi Azure Native API Management Backend]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/backend/}
|
|
112
98
|
*/
|
|
113
|
-
|
|
99
|
+
createBackend(id, scope, props) {
|
|
114
100
|
if (!props)
|
|
115
101
|
throw `Props undefined for ${id}`;
|
|
116
|
-
|
|
102
|
+
return new Backend(`${id}-am-be`, {
|
|
117
103
|
...props,
|
|
118
|
-
|
|
119
|
-
description: props.description ?? `Backend for ${props.name}-${scope.props.stage}`,
|
|
120
|
-
protocol: props.protocol ??
|
|
121
|
-
});
|
|
122
|
-
createAzureTfOutput(`${id}-apiManagementBackendName`, scope, apiManagementBackend.name);
|
|
123
|
-
createAzureTfOutput(`${id}-apiManagementBackendFriendlyUniqueId`, scope, apiManagementBackend.friendlyUniqueId);
|
|
124
|
-
createAzureTfOutput(`${id}-apiManagementBackendId`, scope, apiManagementBackend.id);
|
|
125
|
-
return apiManagementBackend;
|
|
104
|
+
backendId: scope.resourceNameFormatter.format(props.backendId?.toString(), scope.props.resourceNameOptions?.apiManagementBackend),
|
|
105
|
+
description: props.description ?? `Backend for ${props.name || id}-${scope.props.stage}`,
|
|
106
|
+
protocol: props.protocol ?? BackendProtocol.Http,
|
|
107
|
+
}, { parent: scope });
|
|
126
108
|
}
|
|
127
109
|
/**
|
|
128
|
-
* @summary Method to create a new
|
|
110
|
+
* @summary Method to create a new API Management API with operations and policies
|
|
129
111
|
* @param id scoped id of the resource
|
|
130
112
|
* @param scope scope in which this resource is defined
|
|
131
|
-
* @param props
|
|
132
|
-
* @see [
|
|
113
|
+
* @param props API Management API properties
|
|
114
|
+
* @see [Pulumi Azure Native API Management API]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/api/}
|
|
133
115
|
*/
|
|
134
|
-
|
|
116
|
+
createApi(id, scope, props) {
|
|
135
117
|
if (!props)
|
|
136
118
|
throw `Props undefined for ${id}`;
|
|
137
|
-
const
|
|
119
|
+
const api = new Api(`${id}-am-api`, {
|
|
138
120
|
...props,
|
|
139
|
-
|
|
140
|
-
displayName: props.displayName ?? props.
|
|
141
|
-
|
|
142
|
-
protocols: props.protocols ?? [
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
createAzureTfOutput(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId);
|
|
146
|
-
createAzureTfOutput(`${id}-apiManagementApiId`, scope, apiManagementApi.id);
|
|
121
|
+
apiId: scope.resourceNameFormatter.format(props.apiId?.toString(), scope.props.resourceNameOptions?.apiManagementApi),
|
|
122
|
+
displayName: props.displayName ?? props.apiId,
|
|
123
|
+
apiRevision: props.apiRevision ?? '1',
|
|
124
|
+
protocols: props.protocols ?? [Protocol.Https],
|
|
125
|
+
}, { parent: scope });
|
|
126
|
+
// Create operations and policies
|
|
147
127
|
_.forEach(props.operations, operation => {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
128
|
+
const operationId = `${operation.displayName}-${operation.method}`;
|
|
129
|
+
const apimOperation = new ApiOperation(`${id}-apim-api-operation-${operation.displayName}-${operation.method}`, {
|
|
130
|
+
operationId: operationId,
|
|
131
|
+
method: operation.method?.toUpperCase() || 'GET',
|
|
132
|
+
serviceName: props.serviceName,
|
|
133
|
+
resourceGroupName: props.resourceGroupName,
|
|
134
|
+
apiId: api.name,
|
|
154
135
|
displayName: operation.displayName,
|
|
155
136
|
urlTemplate: operation.urlTemplate,
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
createAzureTfOutput(`${id}-${operation.displayName}-${operation.method}-apimOperationOperationId`, scope, apimOperation.operationId);
|
|
159
|
-
createAzureTfOutput(`${id}-${operation.displayName}-${operation.method}-apimOperationFriendlyUniqueId`, scope, apimOperation.friendlyUniqueId);
|
|
160
|
-
createAzureTfOutput(`${id}-${operation.displayName}-${operation.method}-apimOperationId`, scope, apimOperation.id);
|
|
137
|
+
templateParameters: operation.templateParameters,
|
|
138
|
+
}, { parent: scope });
|
|
161
139
|
// Define Caching Policy if enabled
|
|
162
140
|
let cacheSetVariablePolicy = '';
|
|
163
141
|
let cacheInvalidateInboundPolicy = '';
|
|
@@ -167,11 +145,11 @@ export class AzureApiManagementManager {
|
|
|
167
145
|
cacheSetVariablePolicy = `<!-- Generate a comprehensive custom cache key (without query params or Accept header) -->
|
|
168
146
|
<set-variable name="customCacheKey" value="@{
|
|
169
147
|
// Instance identification
|
|
170
|
-
|
|
148
|
+
|
|
171
149
|
// API identification
|
|
172
150
|
string apiName = context.Api.Name.Replace(" ", "").ToLower();
|
|
173
151
|
string apiVersion = context.Api.Version ?? "v1";
|
|
174
|
-
|
|
152
|
+
|
|
175
153
|
// Full path construction (without query parameters)
|
|
176
154
|
string fullPath = context.Request.Url.Path.ToLower();
|
|
177
155
|
|
|
@@ -246,7 +224,7 @@ export class AzureApiManagementManager {
|
|
|
246
224
|
// Inject rate limiting policy (if configured)
|
|
247
225
|
let rateLimitPolicy = '';
|
|
248
226
|
if (props.rateLimit && scope.props.subscriptionId) {
|
|
249
|
-
rateLimitPolicy = `<rate-limit-by-key calls="${props.rateLimit.calls}" renewal-period="${props.rateLimit.renewalPeriodInSecs}" counter-key="${scope.props.subscriptionId}-${
|
|
227
|
+
rateLimitPolicy = `<rate-limit-by-key calls="${props.rateLimit.calls}" renewal-period="${props.rateLimit.renewalPeriodInSecs}" counter-key="${scope.props.subscriptionId}-${operationId}"/>`;
|
|
250
228
|
}
|
|
251
229
|
const policyXmlContent = `<policies>
|
|
252
230
|
<inbound>
|
|
@@ -269,31 +247,32 @@ export class AzureApiManagementManager {
|
|
|
269
247
|
<base />
|
|
270
248
|
</on-error>
|
|
271
249
|
</policies>`;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
resourceGroupName:
|
|
275
|
-
|
|
276
|
-
operationId:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
250
|
+
new ApiOperationPolicy(`${id}-apim-api-operation-policy-${operation.displayName}-${operation.method}`, {
|
|
251
|
+
serviceName: props.serviceName,
|
|
252
|
+
resourceGroupName: props.resourceGroupName,
|
|
253
|
+
apiId: api.name,
|
|
254
|
+
operationId: operationId,
|
|
255
|
+
policyId: 'policy',
|
|
256
|
+
value: policyXmlContent,
|
|
257
|
+
format: PolicyContentFormat.Xml,
|
|
258
|
+
}, { parent: scope });
|
|
281
259
|
});
|
|
282
|
-
return
|
|
260
|
+
return api;
|
|
283
261
|
}
|
|
284
262
|
/**
|
|
285
|
-
* @summary Method to create a new
|
|
263
|
+
* @summary Method to create a new API Management custom domain
|
|
286
264
|
* @param id scoped id of the resource
|
|
287
265
|
* @param scope scope in which this resource is defined
|
|
288
|
-
* @param props
|
|
289
|
-
* @
|
|
266
|
+
* @param props API Management custom domain properties
|
|
267
|
+
* @note In Pulumi Azure Native, custom domains are configured as part of the API Management service resource,
|
|
268
|
+
* not as a separate resource. Use the hostnameConfigurations property when creating the service.
|
|
290
269
|
*/
|
|
291
270
|
createApiManagementCustomDomain(id, scope, props) {
|
|
292
271
|
if (!props)
|
|
293
272
|
throw `Props undefined for ${id}`;
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
273
|
+
// Note: In Pulumi Azure Native, custom domains are part of the ApiManagementService
|
|
274
|
+
// This method is provided for API compatibility but should be configured
|
|
275
|
+
// via the hostnameConfigurations property of ApiManagementService instead
|
|
276
|
+
throw new Error('Custom domains should be configured via the hostnameConfigurations property of ApiManagementService in Pulumi Azure Native');
|
|
298
277
|
}
|
|
299
278
|
}
|
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { ApiManagementCustomDomainConfig } from '@cdktf/provider-azurerm/lib/api-management-custom-domain/index.js';
|
|
4
|
-
import { ApiManagementApiConfig } from '@cdktf/provider-azurerm/lib/api-management-api/index.js';
|
|
5
|
-
import { ApiManagementApiOperationConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation/index.js';
|
|
6
|
-
import { ApiManagementRedisCacheConfig } from '@cdktf/provider-azurerm/lib/api-management-redis-cache/index.js';
|
|
7
|
-
export interface ApiManagementProps extends ApiManagementConfig {
|
|
8
|
-
}
|
|
9
|
-
export interface ApiManagementBackendProps extends ApiManagementBackendConfig {
|
|
10
|
-
backendUrlPath?: string;
|
|
11
|
-
apiManagementId: string;
|
|
12
|
-
circuitBreaker: any;
|
|
1
|
+
import { ApiArgs, ApiManagementServiceArgs, ApiOperationArgs, BackendArgs, GetApiManagementServiceOutputArgs } from '@pulumi/azure-native/apimanagement/index.js';
|
|
2
|
+
export interface ApiManagementProps extends ApiManagementServiceArgs {
|
|
13
3
|
}
|
|
14
|
-
export interface
|
|
4
|
+
export interface ApiManagementBackendProps extends BackendArgs {
|
|
5
|
+
backendUrlPath?: string;
|
|
6
|
+
apiManagementId?: string;
|
|
7
|
+
circuitBreaker?: any;
|
|
15
8
|
}
|
|
16
|
-
export interface
|
|
9
|
+
export interface ApiManagementCustomDomainProps {
|
|
10
|
+
apiManagementId: string;
|
|
11
|
+
gateway?: Array<{
|
|
12
|
+
hostName: string;
|
|
13
|
+
certificateId?: string;
|
|
14
|
+
negotiateClientCertificate?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
developerPortal?: Array<{
|
|
17
|
+
hostName: string;
|
|
18
|
+
certificateId?: string;
|
|
19
|
+
}>;
|
|
20
|
+
management?: Array<{
|
|
21
|
+
hostName: string;
|
|
22
|
+
certificateId?: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface ApiManagementApiProps extends ApiArgs {
|
|
17
26
|
operations: ApiManagementApiOperationProps[];
|
|
18
|
-
commonInboundPolicyXml
|
|
19
|
-
commonOutboundPolicyXml
|
|
27
|
+
commonInboundPolicyXml?: string;
|
|
28
|
+
commonOutboundPolicyXml?: string;
|
|
20
29
|
rateLimit?: ApiManagementApiRateLimit;
|
|
21
30
|
}
|
|
22
|
-
export interface ApiManagementApiOperationProps extends
|
|
31
|
+
export interface ApiManagementApiOperationProps extends ApiOperationArgs {
|
|
23
32
|
caching?: ApiManagementApiCaching;
|
|
24
33
|
}
|
|
25
34
|
export interface ApiManagementApiCaching {
|
|
@@ -32,5 +41,11 @@ export interface ApiManagementApiRateLimit {
|
|
|
32
41
|
calls: number;
|
|
33
42
|
renewalPeriodInSecs: number;
|
|
34
43
|
}
|
|
35
|
-
export interface ApiManagementRedisCacheProps
|
|
44
|
+
export interface ApiManagementRedisCacheProps {
|
|
45
|
+
apiManagementId: string;
|
|
46
|
+
connectionString: string;
|
|
47
|
+
cacheLocation: string;
|
|
48
|
+
redisCacheId: string;
|
|
49
|
+
}
|
|
50
|
+
export interface ResolveApiManagementProps extends GetApiManagementServiceOutputArgs {
|
|
36
51
|
}
|