@gradientedge/cdk-utils 10.1.0 → 10.2.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 (112) hide show
  1. package/dist/src/lib/azure/common/constants.d.ts +3 -2
  2. package/dist/src/lib/azure/common/constants.js +2 -1
  3. package/dist/src/lib/azure/common/construct.d.ts +26 -12
  4. package/dist/src/lib/azure/common/construct.js +31 -45
  5. package/dist/src/lib/azure/common/resource-name-formatter.d.ts +9 -4
  6. package/dist/src/lib/azure/common/resource-name-formatter.js +9 -5
  7. package/dist/src/lib/azure/common/stack.d.ts +18 -32
  8. package/dist/src/lib/azure/common/stack.js +77 -74
  9. package/dist/src/lib/azure/common/tagging.d.ts +29 -8
  10. package/dist/src/lib/azure/common/tagging.js +72 -26
  11. package/dist/src/lib/azure/common/types.d.ts +19 -4
  12. package/dist/src/lib/azure/services/api-management/main.d.ts +29 -32
  13. package/dist/src/lib/azure/services/api-management/main.js +100 -121
  14. package/dist/src/lib/azure/services/api-management/types.d.ts +33 -18
  15. package/dist/src/lib/azure/services/app-configuration/main.d.ts +6 -7
  16. package/dist/src/lib/azure/services/app-configuration/main.js +23 -26
  17. package/dist/src/lib/azure/services/app-configuration/types.d.ts +2 -2
  18. package/dist/src/lib/azure/services/app-service/main.d.ts +10 -12
  19. package/dist/src/lib/azure/services/app-service/main.js +37 -49
  20. package/dist/src/lib/azure/services/app-service/types.d.ts +4 -4
  21. package/dist/src/lib/azure/services/application-insights/main.d.ts +7 -8
  22. package/dist/src/lib/azure/services/application-insights/main.js +20 -26
  23. package/dist/src/lib/azure/services/application-insights/types.d.ts +2 -4
  24. package/dist/src/lib/azure/services/cosmosdb/main.d.ts +12 -15
  25. package/dist/src/lib/azure/services/cosmosdb/main.js +42 -61
  26. package/dist/src/lib/azure/services/cosmosdb/types.d.ts +4 -6
  27. package/dist/src/lib/azure/services/dns/main.d.ts +13 -17
  28. package/dist/src/lib/azure/services/dns/main.js +33 -51
  29. package/dist/src/lib/azure/services/dns/types.d.ts +5 -8
  30. package/dist/src/lib/azure/services/eventgrid/main.d.ts +20 -22
  31. package/dist/src/lib/azure/services/eventgrid/main.js +61 -89
  32. package/dist/src/lib/azure/services/eventgrid/types.d.ts +7 -8
  33. package/dist/src/lib/azure/services/function/main.d.ts +15 -15
  34. package/dist/src/lib/azure/services/function/main.js +54 -59
  35. package/dist/src/lib/azure/services/function/types.d.ts +18 -6
  36. package/dist/src/lib/azure/services/index.d.ts +1 -1
  37. package/dist/src/lib/azure/services/index.js +1 -1
  38. package/dist/src/lib/azure/services/key-vault/main.d.ts +6 -7
  39. package/dist/src/lib/azure/services/key-vault/main.js +29 -28
  40. package/dist/src/lib/azure/services/key-vault/types.d.ts +3 -2
  41. package/dist/src/lib/azure/services/monitor/main.d.ts +7 -8
  42. package/dist/src/lib/azure/services/monitor/main.js +10 -15
  43. package/dist/src/lib/azure/services/monitor/types.d.ts +2 -2
  44. package/dist/src/lib/azure/services/operational-insights/main.d.ts +29 -0
  45. package/dist/src/lib/azure/services/operational-insights/main.js +50 -0
  46. package/dist/src/lib/azure/services/operational-insights/types.d.ts +3 -0
  47. package/dist/src/lib/azure/services/redis/main.d.ts +8 -9
  48. package/dist/src/lib/azure/services/redis/main.js +24 -26
  49. package/dist/src/lib/azure/services/redis/types.d.ts +2 -2
  50. package/dist/src/lib/azure/services/resource-group/main.d.ts +6 -7
  51. package/dist/src/lib/azure/services/resource-group/main.js +9 -14
  52. package/dist/src/lib/azure/services/resource-group/types.d.ts +2 -2
  53. package/dist/src/lib/azure/services/servicebus/main.d.ts +17 -22
  54. package/dist/src/lib/azure/services/servicebus/main.js +47 -70
  55. package/dist/src/lib/azure/services/servicebus/types.d.ts +6 -10
  56. package/dist/src/lib/azure/services/storage/main.d.ts +24 -27
  57. package/dist/src/lib/azure/services/storage/main.js +70 -88
  58. package/dist/src/lib/azure/services/storage/types.d.ts +10 -8
  59. package/dist/src/lib/azure/types/index.d.ts +2 -1
  60. package/dist/src/lib/azure/utils/index.d.ts +19 -3
  61. package/dist/src/lib/azure/utils/index.js +19 -13
  62. package/dist/src/lib/cloudflare/common/stack.js +1 -1
  63. package/package.json +2 -1
  64. package/src/lib/azure/common/constants.ts +2 -1
  65. package/src/lib/azure/common/construct.ts +32 -48
  66. package/src/lib/azure/common/resource-name-formatter.ts +10 -6
  67. package/src/lib/azure/common/stack.ts +78 -78
  68. package/src/lib/azure/common/tagging.ts +78 -29
  69. package/src/lib/azure/common/types.ts +21 -4
  70. package/src/lib/azure/services/api-management/main.ts +172 -169
  71. package/src/lib/azure/services/api-management/types.ts +39 -16
  72. package/src/lib/azure/services/app-configuration/main.ts +33 -31
  73. package/src/lib/azure/services/app-configuration/types.ts +2 -2
  74. package/src/lib/azure/services/app-service/main.ts +61 -62
  75. package/src/lib/azure/services/app-service/types.ts +4 -4
  76. package/src/lib/azure/services/application-insights/main.ts +29 -30
  77. package/src/lib/azure/services/application-insights/types.ts +2 -5
  78. package/src/lib/azure/services/cosmosdb/main.ts +78 -77
  79. package/src/lib/azure/services/cosmosdb/types.ts +10 -6
  80. package/src/lib/azure/services/dns/main.ts +65 -72
  81. package/src/lib/azure/services/dns/types.ts +9 -9
  82. package/src/lib/azure/services/eventgrid/main.ts +120 -122
  83. package/src/lib/azure/services/eventgrid/types.ts +13 -8
  84. package/src/lib/azure/services/function/main.ts +75 -72
  85. package/src/lib/azure/services/function/types.ts +21 -6
  86. package/src/lib/azure/services/index.ts +1 -1
  87. package/src/lib/azure/services/key-vault/main.ts +38 -32
  88. package/src/lib/azure/services/key-vault/types.ts +4 -2
  89. package/src/lib/azure/services/monitor/main.ts +17 -21
  90. package/src/lib/azure/services/monitor/types.ts +2 -2
  91. package/src/lib/azure/services/operational-insights/main.ts +61 -0
  92. package/src/lib/azure/services/operational-insights/types.ts +3 -0
  93. package/src/lib/azure/services/redis/main.ts +30 -30
  94. package/src/lib/azure/services/redis/types.ts +2 -2
  95. package/src/lib/azure/services/resource-group/main.ts +20 -20
  96. package/src/lib/azure/services/resource-group/types.ts +2 -2
  97. package/src/lib/azure/services/servicebus/main.ts +103 -94
  98. package/src/lib/azure/services/servicebus/types.ts +17 -11
  99. package/src/lib/azure/services/storage/main.ts +113 -114
  100. package/src/lib/azure/services/storage/types.ts +16 -8
  101. package/src/lib/azure/types/index.ts +2 -1
  102. package/src/lib/azure/utils/index.ts +20 -22
  103. package/src/lib/cloudflare/common/stack.ts +1 -1
  104. package/dist/src/lib/azure/services/log-analytics-workspace/main.d.ts +0 -30
  105. package/dist/src/lib/azure/services/log-analytics-workspace/main.js +0 -55
  106. package/dist/src/lib/azure/services/log-analytics-workspace/types.d.ts +0 -3
  107. package/src/lib/azure/services/log-analytics-workspace/main.ts +0 -61
  108. package/src/lib/azure/services/log-analytics-workspace/types.ts +0 -3
  109. /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.d.ts +0 -0
  110. /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.js +0 -0
  111. /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/types.js +0 -0
  112. /package/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.ts +0 -0
@@ -1,32 +1,78 @@
1
- import { TerraformResource } from 'cdktf';
1
+ import * as pulumi from '@pulumi/pulumi';
2
2
  import { RESOURCES_TO_EXCLUDE_TAGS } from './constants.js';
3
- function isTaggableConstruct(node) {
4
- return 'tags' in node && 'tagsInput' in node;
5
- }
6
- export class TagsAddingAspect {
7
- tagsToAdd;
8
- tagsToIgnore;
9
- constructor(tagsToAdd, tagsToIgnore = []) {
10
- this.tagsToAdd = tagsToAdd;
11
- this.tagsToIgnore = tagsToIgnore;
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
- // This method is called on every Construct within the specified scope (resources, data sources, etc.).
14
- visit(node) {
15
- // We need to take the input value to not create a circular reference
16
- if (!isTaggableConstruct(node)) {
17
- return;
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
- // Determine if the resource excludes `tags`
20
- if (RESOURCES_TO_EXCLUDE_TAGS.has(node.constructor.name)) {
21
- node.tags = undefined; // Completely remove tags for this resource
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
- const currentTags = node.tagsInput || {};
25
- node.tags = { ...this.tagsToAdd, ...currentTags };
26
- // Add ignore_changes overrides for selected tags
27
- if (node instanceof TerraformResource && this.tagsToIgnore.length > 0) {
28
- const ignoreList = this.tagsToIgnore.map(tag => `tags["${tag}"]`);
29
- node.addOverride('lifecycle.ignore_changes', ignoreList);
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, AzurermProviderConfig {
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 extends AzurermBackendConfig {
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 { ApiManagementApi } from '@cdktf/provider-azurerm/lib/api-management-api/index.js';
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 Api Management
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(parent: Construct, id: string, props: CommonAzureStackProps) {
20
- * super(parent, id, props)
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 api management
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 api management properties
33
- * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
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
- createApiManagement(id: string, scope: CommonAzureConstruct, props: ApiManagementProps, applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey'], externalRedisCache?: ManagedRedis): ApiManagement;
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 api management
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 api management properties
41
- * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
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
- resolveApiManagement(id: string, scope: CommonAzureConstruct, props: DataAzurermApiManagementConfig): DataAzurermApiManagement;
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 api management backend
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 api management backend properties
49
- * @see [CDKTF Api management Backend Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementBackend.typescript.md}
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
- createApiManagementBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps): ApiManagementBackend;
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 api management api
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 api management api properties
57
- * @see [CDKTF Api management Api Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementApi.typescript.md}
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
- createApiManagementApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps): ApiManagementApi;
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 api management custom domain
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 api management custom domain properties
65
- * @see [CDKTF Api management Custom Domain Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/createApiManagementCustomDomain.typescript.md}
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): ApiManagementCustomDomain;
64
+ createApiManagementCustomDomain(id: string, scope: CommonAzureConstruct, props: ApiManagementCustomDomainProps): void;
68
65
  }
@@ -1,26 +1,16 @@
1
- import { ApiManagementApiOperationPolicy } from '@cdktf/provider-azurerm/lib/api-management-api-operation-policy/index.js';
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 Api Management
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(parent: Construct, id: string, props: CommonAzureStackProps) {
23
- * super(parent, id, props)
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 api management
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 api management properties
36
- * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
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
- createApiManagement(id, scope, props, applicationInsightsKey, externalRedisCache) {
30
+ createApiManagementService(id, scope, props, applicationInsightsKey, externalRedisCache) {
39
31
  if (!props)
40
32
  throw `Props undefined for ${id}`;
41
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
42
- name: scope.props.resourceGroupName
43
- ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
44
- : `${props.resourceGroupName}`,
45
- });
46
- if (!resourceGroup)
47
- throw `Resource group undefined for ${id}`;
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
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagement),
51
- resourceGroupName: resourceGroup.name,
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 ApiManagementLogger(scope, `${id}-am-logger`, {
58
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementLogger),
59
- resourceGroupName: resourceGroup.name,
60
- apiManagementName: apiManagement.name,
61
- applicationInsights: {
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 ApiManagementRedisCache(scope, `${id}-am-redis-cache`, {
68
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementRedisCache),
69
- apiManagementId: apiManagement.id,
70
- connectionString: `${externalRedisCache.name}:10000,password=${externalRedisCache.defaultDatabase.primaryAccessKey},ssl=True,abortConnect=False`,
71
- cacheLocation: externalRedisCache.location,
72
- redisCacheId: externalRedisCache.id,
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
- createAzureTfOutput(`${id}-apiManagementName`, scope, apiManagement.name);
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 api management
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 api management properties
85
- * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
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
- resolveApiManagement(id, scope, props) {
82
+ resolveApiManagementService(id, scope, props) {
88
83
  if (!props)
89
84
  throw `Props undefined for ${id}`;
90
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
91
- name: scope.props.resourceGroupName
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
- : `${props.resourceGroupName}`,
103
- });
104
- return apiManagement;
89
+ : props.resourceGroupName,
90
+ }, { parent: scope });
105
91
  }
106
92
  /**
107
- * @summary Method to create a new api management backend
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 api management backend properties
111
- * @see [CDKTF Api management Backend Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementBackend.typescript.md}
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
- createApiManagementBackend(id, scope, props) {
99
+ createBackend(id, scope, props) {
114
100
  if (!props)
115
101
  throw `Props undefined for ${id}`;
116
- const apiManagementBackend = new ApiManagementBackend(scope, `${id}-am-be`, {
102
+ return new Backend(`${id}-am-be`, {
117
103
  ...props,
118
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementBackend),
119
- description: props.description ?? `Backend for ${props.name}-${scope.props.stage}`,
120
- protocol: props.protocol ?? 'http',
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 api management api
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 api management api properties
132
- * @see [CDKTF Api management Api Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementApi.typescript.md}
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
- createApiManagementApi(id, scope, props) {
116
+ createApi(id, scope, props) {
135
117
  if (!props)
136
118
  throw `Props undefined for ${id}`;
137
- const apiManagementApi = new ApiManagementApi(scope, `${id}-am-api`, {
119
+ const api = new Api(`${id}-am-api`, {
138
120
  ...props,
139
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementApi),
140
- displayName: props.displayName ?? props.name,
141
- revision: props.revision ?? '1',
142
- protocols: props.protocols ?? ['https'],
143
- });
144
- createAzureTfOutput(`${id}-apiManagementApiName`, scope, apiManagementApi.name);
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 apimOperation = new ApiManagementApiOperation(scope, `${id}-apim-api-operation-${operation.displayName}-${operation.method}`, {
149
- operationId: `${operation.displayName}-${operation.method}`,
150
- method: operation.method.toUpperCase(),
151
- apiManagementName: apiManagementApi.apiManagementName,
152
- resourceGroupName: apiManagementApi.resourceGroupName,
153
- apiName: apiManagementApi.name,
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
- templateParameter: operation.templateParameter,
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}-${apimOperation.operationId}"/>`;
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
- const apimOperationPolicy = new ApiManagementApiOperationPolicy(scope, `${id}-apim-api-operation-policy-${operation.displayName}-${operation.method}`, {
273
- apiManagementName: apiManagementApi.apiManagementName,
274
- resourceGroupName: apiManagementApi.resourceGroupName,
275
- apiName: apiManagementApi.name,
276
- operationId: apimOperation.operationId,
277
- xmlContent: policyXmlContent,
278
- });
279
- createAzureTfOutput(`${id}-${operation.displayName}-${operation.method}-apimOperationPolicyFriendlyUniqueId`, scope, apimOperationPolicy.friendlyUniqueId);
280
- createAzureTfOutput(`${id}-${operation.displayName}-${operation.method}-apimOperationPolicyId`, scope, apimOperationPolicy.id);
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 apiManagementApi;
260
+ return api;
283
261
  }
284
262
  /**
285
- * @summary Method to create a new api management custom domain
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 api management custom domain properties
289
- * @see [CDKTF Api management Custom Domain Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/createApiManagementCustomDomain.typescript.md}
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
- const apiManagementCustomDomain = new ApiManagementCustomDomain(scope, `${id}-am-cd`, props);
295
- createAzureTfOutput(`${id}-apiManagementCustomDomainFriendlyUniqueId`, scope, apiManagementCustomDomain.friendlyUniqueId);
296
- createAzureTfOutput(`${id}-apiManagementCustomDomainId`, scope, apiManagementCustomDomain.id);
297
- return apiManagementCustomDomain;
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 { ApiManagementConfig } from '@cdktf/provider-azurerm/lib/api-management/index.js';
2
- import { ApiManagementBackendConfig } from '@cdktf/provider-azurerm/lib/api-management-backend/index.js';
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 ApiManagementCustomDomainProps extends ApiManagementCustomDomainConfig {
4
+ export interface ApiManagementBackendProps extends BackendArgs {
5
+ backendUrlPath?: string;
6
+ apiManagementId?: string;
7
+ circuitBreaker?: any;
15
8
  }
16
- export interface ApiManagementApiProps extends ApiManagementApiConfig {
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: string;
19
- commonOutboundPolicyXml: string;
27
+ commonInboundPolicyXml?: string;
28
+ commonOutboundPolicyXml?: string;
20
29
  rateLimit?: ApiManagementApiRateLimit;
21
30
  }
22
- export interface ApiManagementApiOperationProps extends ApiManagementApiOperationConfig {
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 extends ApiManagementRedisCacheConfig {
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
  }