@gradientedge/cdk-utils-azure 1.0.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 (176) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/common/constants.d.ts +83 -0
  3. package/dist/src/common/constants.js +87 -0
  4. package/dist/src/common/construct.d.ts +80 -0
  5. package/dist/src/common/construct.js +128 -0
  6. package/dist/src/common/index.d.ts +6 -0
  7. package/dist/src/common/index.js +6 -0
  8. package/dist/src/common/resource-name-formatter.d.ts +18 -0
  9. package/dist/src/common/resource-name-formatter.js +34 -0
  10. package/dist/src/common/stack.d.ts +46 -0
  11. package/dist/src/common/stack.js +120 -0
  12. package/dist/src/common/tagging.d.ts +29 -0
  13. package/dist/src/common/tagging.js +78 -0
  14. package/dist/src/common/types.d.ts +57 -0
  15. package/dist/src/common/types.js +1 -0
  16. package/dist/src/construct/event-handler/index.d.ts +2 -0
  17. package/dist/src/construct/event-handler/index.js +2 -0
  18. package/dist/src/construct/event-handler/main.d.ts +61 -0
  19. package/dist/src/construct/event-handler/main.js +180 -0
  20. package/dist/src/construct/event-handler/types.d.ts +35 -0
  21. package/dist/src/construct/event-handler/types.js +1 -0
  22. package/dist/src/construct/function-app/index.d.ts +2 -0
  23. package/dist/src/construct/function-app/index.js +2 -0
  24. package/dist/src/construct/function-app/main.d.ts +128 -0
  25. package/dist/src/construct/function-app/main.js +374 -0
  26. package/dist/src/construct/function-app/types.d.ts +33 -0
  27. package/dist/src/construct/function-app/types.js +1 -0
  28. package/dist/src/construct/index.d.ts +6 -0
  29. package/dist/src/construct/index.js +6 -0
  30. package/dist/src/construct/rest-api/index.d.ts +2 -0
  31. package/dist/src/construct/rest-api/index.js +2 -0
  32. package/dist/src/construct/rest-api/main.d.ts +64 -0
  33. package/dist/src/construct/rest-api/main.js +216 -0
  34. package/dist/src/construct/rest-api/types.d.ts +25 -0
  35. package/dist/src/construct/rest-api/types.js +1 -0
  36. package/dist/src/construct/rest-api-function/index.d.ts +2 -0
  37. package/dist/src/construct/rest-api-function/index.js +2 -0
  38. package/dist/src/construct/rest-api-function/main.d.ts +66 -0
  39. package/dist/src/construct/rest-api-function/main.js +302 -0
  40. package/dist/src/construct/rest-api-function/types.d.ts +29 -0
  41. package/dist/src/construct/rest-api-function/types.js +1 -0
  42. package/dist/src/construct/rest-api-with-cache/index.d.ts +2 -0
  43. package/dist/src/construct/rest-api-with-cache/index.js +2 -0
  44. package/dist/src/construct/rest-api-with-cache/main.d.ts +41 -0
  45. package/dist/src/construct/rest-api-with-cache/main.js +85 -0
  46. package/dist/src/construct/rest-api-with-cache/types.d.ts +13 -0
  47. package/dist/src/construct/rest-api-with-cache/types.js +1 -0
  48. package/dist/src/construct/site-with-webapp/index.d.ts +2 -0
  49. package/dist/src/construct/site-with-webapp/index.js +2 -0
  50. package/dist/src/construct/site-with-webapp/main.d.ts +60 -0
  51. package/dist/src/construct/site-with-webapp/main.js +176 -0
  52. package/dist/src/construct/site-with-webapp/types.d.ts +30 -0
  53. package/dist/src/construct/site-with-webapp/types.js +1 -0
  54. package/dist/src/index.d.ts +4 -0
  55. package/dist/src/index.js +4 -0
  56. package/dist/src/services/api-management/index.d.ts +2 -0
  57. package/dist/src/services/api-management/index.js +2 -0
  58. package/dist/src/services/api-management/main.d.ts +143 -0
  59. package/dist/src/services/api-management/main.js +244 -0
  60. package/dist/src/services/api-management/types.d.ts +72 -0
  61. package/dist/src/services/api-management/types.js +1 -0
  62. package/dist/src/services/app-configuration/index.d.ts +2 -0
  63. package/dist/src/services/app-configuration/index.js +2 -0
  64. package/dist/src/services/app-configuration/main.d.ts +41 -0
  65. package/dist/src/services/app-configuration/main.js +71 -0
  66. package/dist/src/services/app-configuration/types.d.ts +3 -0
  67. package/dist/src/services/app-configuration/types.js +1 -0
  68. package/dist/src/services/app-service/index.d.ts +2 -0
  69. package/dist/src/services/app-service/index.js +2 -0
  70. package/dist/src/services/app-service/main.d.ts +40 -0
  71. package/dist/src/services/app-service/main.js +90 -0
  72. package/dist/src/services/app-service/types.d.ts +6 -0
  73. package/dist/src/services/app-service/types.js +1 -0
  74. package/dist/src/services/application-insights/index.d.ts +2 -0
  75. package/dist/src/services/application-insights/index.js +2 -0
  76. package/dist/src/services/application-insights/main.d.ts +40 -0
  77. package/dist/src/services/application-insights/main.js +68 -0
  78. package/dist/src/services/application-insights/types.d.ts +6 -0
  79. package/dist/src/services/application-insights/types.js +1 -0
  80. package/dist/src/services/authorisation/constants.d.ts +13 -0
  81. package/dist/src/services/authorisation/constants.js +14 -0
  82. package/dist/src/services/authorisation/index.d.ts +3 -0
  83. package/dist/src/services/authorisation/index.js +3 -0
  84. package/dist/src/services/authorisation/main.d.ts +84 -0
  85. package/dist/src/services/authorisation/main.js +120 -0
  86. package/dist/src/services/authorisation/types.d.ts +3 -0
  87. package/dist/src/services/authorisation/types.js +1 -0
  88. package/dist/src/services/cosmosdb/constants.d.ts +8 -0
  89. package/dist/src/services/cosmosdb/constants.js +10 -0
  90. package/dist/src/services/cosmosdb/index.d.ts +3 -0
  91. package/dist/src/services/cosmosdb/index.js +3 -0
  92. package/dist/src/services/cosmosdb/main.d.ts +87 -0
  93. package/dist/src/services/cosmosdb/main.js +162 -0
  94. package/dist/src/services/cosmosdb/types.d.ts +9 -0
  95. package/dist/src/services/cosmosdb/types.js +1 -0
  96. package/dist/src/services/dns/index.d.ts +2 -0
  97. package/dist/src/services/dns/index.js +2 -0
  98. package/dist/src/services/dns/main.d.ts +58 -0
  99. package/dist/src/services/dns/main.js +107 -0
  100. package/dist/src/services/dns/types.d.ts +9 -0
  101. package/dist/src/services/dns/types.js +1 -0
  102. package/dist/src/services/eventgrid/index.d.ts +2 -0
  103. package/dist/src/services/eventgrid/index.js +2 -0
  104. package/dist/src/services/eventgrid/main.d.ts +69 -0
  105. package/dist/src/services/eventgrid/main.js +136 -0
  106. package/dist/src/services/eventgrid/types.d.ts +11 -0
  107. package/dist/src/services/eventgrid/types.js +1 -0
  108. package/dist/src/services/function/index.d.ts +2 -0
  109. package/dist/src/services/function/index.js +2 -0
  110. package/dist/src/services/function/main.d.ts +60 -0
  111. package/dist/src/services/function/main.js +223 -0
  112. package/dist/src/services/function/types.d.ts +20 -0
  113. package/dist/src/services/function/types.js +1 -0
  114. package/dist/src/services/index.d.ts +18 -0
  115. package/dist/src/services/index.js +18 -0
  116. package/dist/src/services/key-vault/index.d.ts +2 -0
  117. package/dist/src/services/key-vault/index.js +2 -0
  118. package/dist/src/services/key-vault/main.d.ts +49 -0
  119. package/dist/src/services/key-vault/main.js +83 -0
  120. package/dist/src/services/key-vault/types.d.ts +5 -0
  121. package/dist/src/services/key-vault/types.js +1 -0
  122. package/dist/src/services/monitor/index.d.ts +2 -0
  123. package/dist/src/services/monitor/index.js +2 -0
  124. package/dist/src/services/monitor/main.d.ts +31 -0
  125. package/dist/src/services/monitor/main.js +36 -0
  126. package/dist/src/services/monitor/types.d.ts +3 -0
  127. package/dist/src/services/monitor/types.js +1 -0
  128. package/dist/src/services/operational-insights/index.d.ts +2 -0
  129. package/dist/src/services/operational-insights/index.js +2 -0
  130. package/dist/src/services/operational-insights/main.d.ts +40 -0
  131. package/dist/src/services/operational-insights/main.js +64 -0
  132. package/dist/src/services/operational-insights/types.d.ts +5 -0
  133. package/dist/src/services/operational-insights/types.js +1 -0
  134. package/dist/src/services/portal/error.d.ts +5 -0
  135. package/dist/src/services/portal/error.js +10 -0
  136. package/dist/src/services/portal/index.d.ts +4 -0
  137. package/dist/src/services/portal/index.js +4 -0
  138. package/dist/src/services/portal/main.d.ts +33 -0
  139. package/dist/src/services/portal/main.js +51 -0
  140. package/dist/src/services/portal/renderer.d.ts +11 -0
  141. package/dist/src/services/portal/renderer.js +156 -0
  142. package/dist/src/services/portal/types.d.ts +40 -0
  143. package/dist/src/services/portal/types.js +1 -0
  144. package/dist/src/services/redis/index.d.ts +2 -0
  145. package/dist/src/services/redis/index.js +2 -0
  146. package/dist/src/services/redis/main.d.ts +31 -0
  147. package/dist/src/services/redis/main.js +52 -0
  148. package/dist/src/services/redis/types.d.ts +3 -0
  149. package/dist/src/services/redis/types.js +1 -0
  150. package/dist/src/services/resource-group/index.d.ts +2 -0
  151. package/dist/src/services/resource-group/index.js +2 -0
  152. package/dist/src/services/resource-group/main.d.ts +38 -0
  153. package/dist/src/services/resource-group/main.js +53 -0
  154. package/dist/src/services/resource-group/types.d.ts +3 -0
  155. package/dist/src/services/resource-group/types.js +1 -0
  156. package/dist/src/services/security-center/index.d.ts +2 -0
  157. package/dist/src/services/security-center/index.js +2 -0
  158. package/dist/src/services/security-center/main.d.ts +31 -0
  159. package/dist/src/services/security-center/main.js +33 -0
  160. package/dist/src/services/security-center/types.d.ts +3 -0
  161. package/dist/src/services/security-center/types.js +1 -0
  162. package/dist/src/services/servicebus/index.d.ts +2 -0
  163. package/dist/src/services/servicebus/index.js +2 -0
  164. package/dist/src/services/servicebus/main.d.ts +67 -0
  165. package/dist/src/services/servicebus/main.js +127 -0
  166. package/dist/src/services/servicebus/types.d.ts +11 -0
  167. package/dist/src/services/servicebus/types.js +1 -0
  168. package/dist/src/services/storage/index.d.ts +2 -0
  169. package/dist/src/services/storage/index.js +2 -0
  170. package/dist/src/services/storage/main.d.ts +88 -0
  171. package/dist/src/services/storage/main.js +173 -0
  172. package/dist/src/services/storage/types.d.ts +20 -0
  173. package/dist/src/services/storage/types.js +1 -0
  174. package/dist/src/types/index.d.ts +4 -0
  175. package/dist/src/types/index.js +1 -0
  176. package/package.json +41 -0
@@ -0,0 +1,68 @@
1
+ import { ApplicationType, Component, ComponentCurrentBillingFeature, } from '@pulumi/azure-native/applicationinsights/index.js';
2
+ /**
3
+ * @classdesc Provides operations on Azure Application Insights using Pulumi
4
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
5
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
6
+ * @example
7
+ * ```typescript
8
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
9
+ *
10
+ * class CustomConstruct extends CommonAzureConstruct {
11
+ * constructor(name: string, props: CommonAzureStackProps) {
12
+ * super(name, props)
13
+ * this.props = props
14
+ * this.applicationInsightsManager.createApplicationInsights('MyApplicationInsights', this, props)
15
+ * }
16
+ * }
17
+ * ```
18
+ */
19
+ export class AzureApplicationInsightsManager {
20
+ /**
21
+ * @summary Method to create a new application insights component
22
+ * @param id scoped id of the resource
23
+ * @param scope scope in which this resource is defined
24
+ * @param props application insights component properties
25
+ * @param resourceOptions Optional settings to control resource behaviour
26
+ * @see [Pulumi Azure Native Application Insights Component]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/insights/component/}
27
+ */
28
+ createComponent(id, scope, props, resourceOptions) {
29
+ if (!props)
30
+ throw `Props undefined for ${id}`;
31
+ // Get resource group name
32
+ const resourceGroupName = scope.props.resourceGroupName
33
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
34
+ : props.resourceGroupName;
35
+ if (!resourceGroupName)
36
+ throw `Resource group name undefined for ${id}`;
37
+ const component = new Component(`${id}-ai`, {
38
+ ...props,
39
+ resourceName: scope.resourceNameFormatter.format(props.resourceName?.toString(), scope.props.resourceNameOptions?.applicationInsights),
40
+ resourceGroupName: resourceGroupName,
41
+ applicationType: props.applicationType ?? ApplicationType.Web,
42
+ kind: props.kind ?? 'web',
43
+ tags: props.tags ?? {
44
+ environment: scope.props.stage,
45
+ },
46
+ }, { parent: scope, ...resourceOptions });
47
+ if (props.billingFeatures) {
48
+ this.createComponentCurrentBillingFeature(`${id}-billing`, scope, props.billingFeatures, {
49
+ parent: scope,
50
+ ...resourceOptions,
51
+ });
52
+ }
53
+ return component;
54
+ }
55
+ /**
56
+ * @summary Method to create a new application insights component billing feature
57
+ * @param id scoped id of the resource
58
+ * @param scope scope in which this resource is defined
59
+ * @param props application insights properties component billing featureø
60
+ * @param resourceOptions Optional settings to control resource behaviour
61
+ * @see [Pulumi Azure Native Application Insights Billing Feature]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/insights/componentcurrentbillingfeature/}
62
+ */
63
+ createComponentCurrentBillingFeature(id, scope, props, resourceOptions) {
64
+ if (!props)
65
+ throw `Props undefined for ${id}`;
66
+ return new ComponentCurrentBillingFeature(`${id}`, props, { parent: scope, ...resourceOptions });
67
+ }
68
+ }
@@ -0,0 +1,6 @@
1
+ import { ComponentArgs, ComponentCurrentBillingFeatureArgs } from '@pulumi/azure-native/applicationinsights/index.js';
2
+ export interface ComponentCurrentBillingFeatureProps extends ComponentCurrentBillingFeatureArgs {
3
+ }
4
+ export interface ApplicationInsightsProps extends ComponentArgs {
5
+ billingFeatures?: ComponentCurrentBillingFeatureProps;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @summary Enumerations for publicly available built in RBAC roles
3
+ * @see https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles
4
+ */
5
+ export declare enum RoleDefinitionId {
6
+ APP_CONFIGURATION_DATA_READER = "/providers/Microsoft.Authorization/roleDefinitions/516239f1-63e1-4d78-a4de-a74fb236a071",
7
+ APP_CONFIGURATION_DATA_OWNER = "/providers/Microsoft.Authorization/roleDefinitions/5ae67dd6-50cb-40e7-96ff-dc2bfa4b606b",
8
+ EVENTGRID_DATA_SENDER = "/providers/Microsoft.Authorization/roleDefinitions/d5a91429-5739-47e2-a06b-3470a27159e7",
9
+ KEY_VAULT_CERTIFICATE_USER = "/providers/Microsoft.Authorization/roleDefinitions/db79e9a7-68ee-4b58-9aeb-b90e7c24fcba",
10
+ KEY_VAULT_SECRETS_USER = "/providers/Microsoft.Authorization/roleDefinitions/4633458b-17de-408a-b874-0445c86b69e6",
11
+ STORAGE_BLOB_DATA_CONTRIBUTOR = "/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe",
12
+ STORAGE_TABLE_DATA_CONTRIBUTOR = "/providers/Microsoft.Authorization/roleDefinitions/0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3"
13
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @summary Enumerations for publicly available built in RBAC roles
3
+ * @see https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles
4
+ */
5
+ export var RoleDefinitionId;
6
+ (function (RoleDefinitionId) {
7
+ RoleDefinitionId["APP_CONFIGURATION_DATA_READER"] = "/providers/Microsoft.Authorization/roleDefinitions/516239f1-63e1-4d78-a4de-a74fb236a071";
8
+ RoleDefinitionId["APP_CONFIGURATION_DATA_OWNER"] = "/providers/Microsoft.Authorization/roleDefinitions/5ae67dd6-50cb-40e7-96ff-dc2bfa4b606b";
9
+ RoleDefinitionId["EVENTGRID_DATA_SENDER"] = "/providers/Microsoft.Authorization/roleDefinitions/d5a91429-5739-47e2-a06b-3470a27159e7";
10
+ RoleDefinitionId["KEY_VAULT_CERTIFICATE_USER"] = "/providers/Microsoft.Authorization/roleDefinitions/db79e9a7-68ee-4b58-9aeb-b90e7c24fcba";
11
+ RoleDefinitionId["KEY_VAULT_SECRETS_USER"] = "/providers/Microsoft.Authorization/roleDefinitions/4633458b-17de-408a-b874-0445c86b69e6";
12
+ RoleDefinitionId["STORAGE_BLOB_DATA_CONTRIBUTOR"] = "/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe";
13
+ RoleDefinitionId["STORAGE_TABLE_DATA_CONTRIBUTOR"] = "/providers/Microsoft.Authorization/roleDefinitions/0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3";
14
+ })(RoleDefinitionId || (RoleDefinitionId = {}));
@@ -0,0 +1,3 @@
1
+ export * from './constants.js';
2
+ export * from './main.js';
3
+ export * from './types.js';
@@ -0,0 +1,3 @@
1
+ export * from './constants.js';
2
+ export * from './main.js';
3
+ export * from './types.js';
@@ -0,0 +1,84 @@
1
+ import { Input, ResourceOptions } from '@pulumi/pulumi';
2
+ import { CommonAzureConstruct } from '../../common/index.js';
3
+ import { RoleDefinitionId } from './constants.js';
4
+ import { RoleAssignmentProps } from './types.js';
5
+ /**
6
+ * @classdesc Provides operations on Azure Authorisation using Pulumi
7
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
8
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
9
+ * @example
10
+ * ```typescript
11
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
12
+ *
13
+ * class CustomConstruct extends CommonAzureConstruct {
14
+ * constructor(name: string, props: CommonAzureStackProps) {
15
+ * super(name, props)
16
+ * this.props = props
17
+ * this.authorisationManager.createRoleAssignment('MyRoleAssignment', this, props)
18
+ * }
19
+ * }
20
+ * ```
21
+ */
22
+ export declare class AzureAuthorisationManager {
23
+ /**
24
+ * @summary Method to create a new role assignment
25
+ * @param id scoped id of the resource
26
+ * @param scope scope in which this resource is defined
27
+ * @param props Role assignment properties
28
+ * @param resourceOptions Optional settings to control resource behaviour
29
+ * @see [Pulumi Azure Native Role Assignment]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/authorization/roleassignment/}
30
+ */
31
+ createRoleAssignment(id: string, scope: CommonAzureConstruct, props: RoleAssignmentProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/authorization/roleAssignment.js").RoleAssignment;
32
+ /**
33
+ * @summary Method to grant a role assignment to key vault
34
+ * @param id scoped id of the resource
35
+ * @param scope scope in which this resource is defined
36
+ * @param vaultName the key vault name
37
+ * @param resourceGroupName the resource group name
38
+ * @param principalId the principal id to which the role is assigned to
39
+ * @param roleDefinitionId the role definition id
40
+ * @param resourceOptions Optional settings to control resource behaviour
41
+ */
42
+ grantRoleAssignmentToKeyVault(id: string, scope: CommonAzureConstruct, vaultName: string, resourceGroupName: string, principalId: Input<string>, roleDefinitionId: RoleDefinitionId, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/authorization/roleAssignment.js").RoleAssignment;
43
+ /**
44
+ * @summary Method to grant a role assignment to event grid topic
45
+ * @param id scoped id of the resource
46
+ * @param scope scope in which this resource is defined
47
+ * @param topicName the topic name
48
+ * @param resourceGroupName the resource group name
49
+ * @param principalId the principal id to which the role is assigned to
50
+ * @param roleDefinitionId the role definition id
51
+ * @param resourceOptions Optional settings to control resource behaviour
52
+ */
53
+ grantRoleAssignmentToEventgridTopic(id: string, scope: CommonAzureConstruct, topicName: string, resourceGroupName: string, principalId: Input<string>, roleDefinitionId: RoleDefinitionId, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/authorization/roleAssignment.js").RoleAssignment;
54
+ /**
55
+ * @summary Method to grant a role assignment to application configuration
56
+ * @param id scoped id of the resource
57
+ * @param scope scope in which this resource is defined
58
+ * @param appConfigId the application configuration id
59
+ * @param principalId the principal id to which the role is assigned to
60
+ * @param roleDefinitionId the role definition id
61
+ * @param resourceOptions Optional settings to control resource behaviour
62
+ */
63
+ grantRoleAssignmentToApplicationConfiguration(id: string, scope: CommonAzureConstruct, appConfigId: Input<string>, principalId: Input<string>, roleDefinitionId: RoleDefinitionId, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/authorization/roleAssignment.js").RoleAssignment;
64
+ /**
65
+ * @summary Method to grant a role assignment to storage account
66
+ * @param id scoped id of the resource
67
+ * @param scope scope in which this resource is defined
68
+ * @param accountId the storage account id
69
+ * @param principalId the principal id to which the role is assigned to
70
+ * @param roleDefinitionId the role definition id
71
+ * @param resourceOptions Optional settings to control resource behaviour
72
+ */
73
+ grantRoleAssignmentToStorageAccount(id: string, scope: CommonAzureConstruct, accountId: Input<string>, principalId: Input<string>, roleDefinitionId: RoleDefinitionId, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/authorization/roleAssignment.js").RoleAssignment;
74
+ /**
75
+ * @summary Method to grant a role assignment to storage table
76
+ * @param id scoped id of the resource
77
+ * @param scope scope in which this resource is defined
78
+ * @param tableId the storage table id
79
+ * @param principalId the principal id to which the role is assigned to
80
+ * @param roleDefinitionId the role definition id
81
+ * @param resourceOptions Optional settings to control resource behaviour
82
+ */
83
+ grantRoleAssignmentToStorageTable(id: string, scope: CommonAzureConstruct, tableId: Input<string>, principalId: Input<string>, roleDefinitionId: RoleDefinitionId, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/authorization/roleAssignment.js").RoleAssignment;
84
+ }
@@ -0,0 +1,120 @@
1
+ import { RoleAssignment } from '@pulumi/azure-native/authorization/index.js';
2
+ /**
3
+ * @classdesc Provides operations on Azure Authorisation using Pulumi
4
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
5
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
6
+ * @example
7
+ * ```typescript
8
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
9
+ *
10
+ * class CustomConstruct extends CommonAzureConstruct {
11
+ * constructor(name: string, props: CommonAzureStackProps) {
12
+ * super(name, props)
13
+ * this.props = props
14
+ * this.authorisationManager.createRoleAssignment('MyRoleAssignment', this, props)
15
+ * }
16
+ * }
17
+ * ```
18
+ */
19
+ export class AzureAuthorisationManager {
20
+ /**
21
+ * @summary Method to create a new role assignment
22
+ * @param id scoped id of the resource
23
+ * @param scope scope in which this resource is defined
24
+ * @param props Role assignment properties
25
+ * @param resourceOptions Optional settings to control resource behaviour
26
+ * @see [Pulumi Azure Native Role Assignment]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/authorization/roleassignment/}
27
+ */
28
+ createRoleAssignment(id, scope, props, resourceOptions) {
29
+ if (!props)
30
+ throw `Props undefined for ${id}`;
31
+ return new RoleAssignment(`${id}`, props, { parent: scope, ...resourceOptions });
32
+ }
33
+ /**
34
+ * @summary Method to grant a role assignment to key vault
35
+ * @param id scoped id of the resource
36
+ * @param scope scope in which this resource is defined
37
+ * @param vaultName the key vault name
38
+ * @param resourceGroupName the resource group name
39
+ * @param principalId the principal id to which the role is assigned to
40
+ * @param roleDefinitionId the role definition id
41
+ * @param resourceOptions Optional settings to control resource behaviour
42
+ */
43
+ grantRoleAssignmentToKeyVault(id, scope, vaultName, resourceGroupName, principalId, roleDefinitionId, resourceOptions) {
44
+ const keyVault = scope.keyVaultManager.resolveKeyVault(scope, vaultName, resourceGroupName, resourceOptions);
45
+ return this.createRoleAssignment(`${id}-kv-role-${vaultName}`, scope, {
46
+ principalId,
47
+ roleDefinitionId,
48
+ scope: keyVault.id,
49
+ }, resourceOptions);
50
+ }
51
+ /**
52
+ * @summary Method to grant a role assignment to event grid topic
53
+ * @param id scoped id of the resource
54
+ * @param scope scope in which this resource is defined
55
+ * @param topicName the topic name
56
+ * @param resourceGroupName the resource group name
57
+ * @param principalId the principal id to which the role is assigned to
58
+ * @param roleDefinitionId the role definition id
59
+ * @param resourceOptions Optional settings to control resource behaviour
60
+ */
61
+ grantRoleAssignmentToEventgridTopic(id, scope, topicName, resourceGroupName, principalId, roleDefinitionId, resourceOptions) {
62
+ const topic = scope.eventgridManager.resolveEventgridTopic(`${id}-egt-role-${topicName}`, scope, {
63
+ topicName,
64
+ resourceGroupName,
65
+ }, resourceOptions);
66
+ return this.createRoleAssignment(`${id}-egt-role-${topicName}`, scope, {
67
+ principalId,
68
+ roleDefinitionId,
69
+ scope: topic.id,
70
+ }, resourceOptions);
71
+ }
72
+ /**
73
+ * @summary Method to grant a role assignment to application configuration
74
+ * @param id scoped id of the resource
75
+ * @param scope scope in which this resource is defined
76
+ * @param appConfigId the application configuration id
77
+ * @param principalId the principal id to which the role is assigned to
78
+ * @param roleDefinitionId the role definition id
79
+ * @param resourceOptions Optional settings to control resource behaviour
80
+ */
81
+ grantRoleAssignmentToApplicationConfiguration(id, scope, appConfigId, principalId, roleDefinitionId, resourceOptions) {
82
+ return this.createRoleAssignment(`${id}-ac-role`, scope, {
83
+ principalId,
84
+ roleDefinitionId,
85
+ scope: appConfigId,
86
+ }, resourceOptions);
87
+ }
88
+ /**
89
+ * @summary Method to grant a role assignment to storage account
90
+ * @param id scoped id of the resource
91
+ * @param scope scope in which this resource is defined
92
+ * @param accountId the storage account id
93
+ * @param principalId the principal id to which the role is assigned to
94
+ * @param roleDefinitionId the role definition id
95
+ * @param resourceOptions Optional settings to control resource behaviour
96
+ */
97
+ grantRoleAssignmentToStorageAccount(id, scope, accountId, principalId, roleDefinitionId, resourceOptions) {
98
+ return this.createRoleAssignment(`${id}-sa-role`, scope, {
99
+ principalId,
100
+ roleDefinitionId,
101
+ scope: accountId,
102
+ }, resourceOptions);
103
+ }
104
+ /**
105
+ * @summary Method to grant a role assignment to storage table
106
+ * @param id scoped id of the resource
107
+ * @param scope scope in which this resource is defined
108
+ * @param tableId the storage table id
109
+ * @param principalId the principal id to which the role is assigned to
110
+ * @param roleDefinitionId the role definition id
111
+ * @param resourceOptions Optional settings to control resource behaviour
112
+ */
113
+ grantRoleAssignmentToStorageTable(id, scope, tableId, principalId, roleDefinitionId, resourceOptions) {
114
+ return this.createRoleAssignment(`${id}-st-role`, scope, {
115
+ principalId,
116
+ roleDefinitionId,
117
+ scope: tableId,
118
+ }, resourceOptions);
119
+ }
120
+ }
@@ -0,0 +1,3 @@
1
+ import { RoleAssignmentArgs } from '@pulumi/azure-native/authorization/index.js';
2
+ export interface RoleAssignmentProps extends RoleAssignmentArgs {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare enum CosmosRoleDefinition {
2
+ CONTRIBUTOR = "CONTRIBUTOR",
3
+ READER = "READER"
4
+ }
5
+ export declare enum CosmosRoleDefinitionId {
6
+ CONTRIBUTOR = "00000000-0000-0000-0000-000000000001",
7
+ READER = "00000000-0000-0000-0000-000000000002"
8
+ }
@@ -0,0 +1,10 @@
1
+ export var CosmosRoleDefinition;
2
+ (function (CosmosRoleDefinition) {
3
+ CosmosRoleDefinition["CONTRIBUTOR"] = "CONTRIBUTOR";
4
+ CosmosRoleDefinition["READER"] = "READER";
5
+ })(CosmosRoleDefinition || (CosmosRoleDefinition = {}));
6
+ export var CosmosRoleDefinitionId;
7
+ (function (CosmosRoleDefinitionId) {
8
+ CosmosRoleDefinitionId["CONTRIBUTOR"] = "00000000-0000-0000-0000-000000000001";
9
+ CosmosRoleDefinitionId["READER"] = "00000000-0000-0000-0000-000000000002";
10
+ })(CosmosRoleDefinitionId || (CosmosRoleDefinitionId = {}));
@@ -0,0 +1,3 @@
1
+ export * from './constants.js';
2
+ export * from './main.js';
3
+ export * from './types.js';
@@ -0,0 +1,3 @@
1
+ export * from './constants.js';
2
+ export * from './main.js';
3
+ export * from './types.js';
@@ -0,0 +1,87 @@
1
+ import { Input, ResourceOptions } from '@pulumi/pulumi';
2
+ import { CommonAzureConstruct } from '../../common/index.js';
3
+ import { CosmosRoleDefinition } from './constants.js';
4
+ import { CosmosdbAccountProps, CosmosdbSqlContainerProps, CosmosdbSqlDatabaseProps, SqlResourceSqlRoleAssignmentProps } from './types.js';
5
+ /**
6
+ * @classdesc Provides operations on Azure CosmosDB using Pulumi
7
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
8
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
9
+ * @example
10
+ * ```typescript
11
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
12
+ *
13
+ * class CustomConstruct extends CommonAzureConstruct {
14
+ * constructor(name: string, props: CommonAzureStackProps) {
15
+ * super(name, props)
16
+ * this.props = props
17
+ * this.CosmosDbManager.createCosmosDbAccount('MyCosmosDb', this, props)
18
+ * }
19
+ * }
20
+ * ```
21
+ */
22
+ export declare class AzureCosmosDbManager {
23
+ /**
24
+ * @summary Method to create a new cosmosdb account
25
+ * @param id scoped id of the resource
26
+ * @param scope scope in which this resource is defined
27
+ * @param props cosmosdb account properties
28
+ * @param resourceOptions Optional settings to control resource behaviour
29
+ * @see [Pulumi Azure Native CosmosDB Database Account]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/databaseaccount/}
30
+ */
31
+ createCosmosDbAccount(id: string, scope: CommonAzureConstruct, props: CosmosdbAccountProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/cosmosdb/databaseAccount.js").DatabaseAccount;
32
+ /**
33
+ * @summary Method to create a new cosmosdb database
34
+ * @param id scoped id of the resource
35
+ * @param scope scope in which this resource is defined
36
+ * @param props cosmosdb database properties
37
+ * @param resourceOptions Optional settings to control resource behaviour
38
+ * @see [Pulumi Azure Native CosmosDB SQL Database]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqldatabase/}
39
+ */
40
+ createCosmosDbDatabase(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlDatabaseProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/cosmosdb/sqlResourceSqlDatabase.js").SqlResourceSqlDatabase;
41
+ /**
42
+ * @summary Method to create a new cosmosdb container
43
+ * @param id scoped id of the resource
44
+ * @param scope scope in which this resource is defined
45
+ * @param props cosmosdb container properties
46
+ * @param resourceOptions Optional settings to control resource behaviour
47
+ * @see [Pulumi Azure Native CosmosDB SQL Container]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqlcontainer/}
48
+ */
49
+ createCosmosDbContainer(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlContainerProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/cosmosdb/sqlResourceSqlContainer.js").SqlResourceSqlContainer;
50
+ /**
51
+ * @summary Method to create a sql role assignment
52
+ * @param id scoped id of the resource
53
+ * @param scope scope in which this resource is defined
54
+ * @param props sql role assignment properties
55
+ * @param resourceOptions Optional settings to control resource behaviour
56
+ * @see [Pulumi Azure Native CosmosDB SQL Role Assignment]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqlroleassignment/}
57
+ */
58
+ createSqlResourceSqlRoleAssignment(id: string, scope: CommonAzureConstruct, props: SqlResourceSqlRoleAssignmentProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/cosmosdb/sqlResourceSqlRoleAssignment.js").SqlResourceSqlRoleAssignment;
59
+ /**
60
+ * @summary Method to resolve an existing cosmosdb account
61
+ * @param scope scope in which this resource is defined
62
+ * @param accountName the account name
63
+ * @param resourceGroupName the resource group name
64
+ * @param resourceOptions Optional settings to control resource behaviour
65
+ */
66
+ resolveCosmosDbAccount(scope: CommonAzureConstruct, accountName: string, resourceGroupName: string, resourceOptions?: ResourceOptions): import("@pulumi/pulumi").Output<import("@pulumi/azure-native/cosmosdb/getDatabaseAccount.js").GetDatabaseAccountResult>;
67
+ /**
68
+ * @summary Method to resolve an existing sql role definition
69
+ * @param scope scope in which this resource is defined
70
+ * @param accountName the account name
71
+ * @param resourceGroupName the resource group name
72
+ * @param roleDefinitionId the role definition id
73
+ * @param resourceOptions Optional settings to control resource behaviour
74
+ */
75
+ resolveSqlRoleDefinition(scope: CommonAzureConstruct, accountName: Input<string>, resourceGroupName: string, roleDefinitionId: string, resourceOptions?: ResourceOptions): import("@pulumi/pulumi").Output<import("@pulumi/azure-native/cosmosdb/getSqlResourceSqlRoleDefinition.js").GetSqlResourceSqlRoleDefinitionResult>;
76
+ /**
77
+ * @summary Method to assign a sql role assignment
78
+ * @param id scoped id of the resource
79
+ * @param scope scope in which this resource is defined
80
+ * @param accountName the account name
81
+ * @param resourceGroupName the resource group name
82
+ * @param principalId the principal id to which the role is assigned to
83
+ * @param roleDefinitions list of role definitions to
84
+ * @param resourceOptions Optional settings to control resource behaviour
85
+ */
86
+ grantSqlRoleDefinitionToAccount(id: string, scope: CommonAzureConstruct, accountName: string, resourceGroupName: string, principalId: Input<string>, roleDefinitions: CosmosRoleDefinition[], resourceOptions?: ResourceOptions): void;
87
+ }
@@ -0,0 +1,162 @@
1
+ import { DatabaseAccount, getDatabaseAccountOutput, getSqlResourceSqlRoleDefinitionOutput, ResourceIdentityType, SqlResourceSqlContainer, SqlResourceSqlDatabase, SqlResourceSqlRoleAssignment, } from '@pulumi/azure-native/cosmosdb/index.js';
2
+ import { CosmosRoleDefinition, CosmosRoleDefinitionId } from './constants.js';
3
+ /**
4
+ * @classdesc Provides operations on Azure CosmosDB using Pulumi
5
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
6
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
7
+ * @example
8
+ * ```typescript
9
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
10
+ *
11
+ * class CustomConstruct extends CommonAzureConstruct {
12
+ * constructor(name: string, props: CommonAzureStackProps) {
13
+ * super(name, props)
14
+ * this.props = props
15
+ * this.CosmosDbManager.createCosmosDbAccount('MyCosmosDb', this, props)
16
+ * }
17
+ * }
18
+ * ```
19
+ */
20
+ export class AzureCosmosDbManager {
21
+ /**
22
+ * @summary Method to create a new cosmosdb account
23
+ * @param id scoped id of the resource
24
+ * @param scope scope in which this resource is defined
25
+ * @param props cosmosdb account properties
26
+ * @param resourceOptions Optional settings to control resource behaviour
27
+ * @see [Pulumi Azure Native CosmosDB Database Account]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/databaseaccount/}
28
+ */
29
+ createCosmosDbAccount(id, scope, props, resourceOptions) {
30
+ if (!props)
31
+ throw `Props undefined for ${id}`;
32
+ // Get resource group name
33
+ const resourceGroupName = scope.props.resourceGroupName
34
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
35
+ : props.resourceGroupName;
36
+ if (!resourceGroupName)
37
+ throw `Resource group name undefined for ${id}`;
38
+ return new DatabaseAccount(`${id}-ca`, {
39
+ ...props,
40
+ accountName: scope.resourceNameFormatter.format(props.accountName?.toString(), scope.props.resourceNameOptions?.cosmosDbAccount),
41
+ location: props.location ?? scope.props.location,
42
+ resourceGroupName: resourceGroupName,
43
+ tags: props.tags ?? {
44
+ environment: scope.props.stage,
45
+ },
46
+ identity: props.identity ?? {
47
+ type: ResourceIdentityType.SystemAssigned,
48
+ },
49
+ }, { parent: scope, ...resourceOptions });
50
+ }
51
+ /**
52
+ * @summary Method to create a new cosmosdb database
53
+ * @param id scoped id of the resource
54
+ * @param scope scope in which this resource is defined
55
+ * @param props cosmosdb database properties
56
+ * @param resourceOptions Optional settings to control resource behaviour
57
+ * @see [Pulumi Azure Native CosmosDB SQL Database]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqldatabase/}
58
+ */
59
+ createCosmosDbDatabase(id, scope, props, resourceOptions) {
60
+ if (!props)
61
+ throw `Props undefined for ${id}`;
62
+ // Get resource group name
63
+ const resourceGroupName = scope.props.resourceGroupName
64
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
65
+ : props.resourceGroupName;
66
+ if (!resourceGroupName)
67
+ throw `Resource group name undefined for ${id}`;
68
+ return new SqlResourceSqlDatabase(`${id}-cd`, {
69
+ ...props,
70
+ databaseName: scope.resourceNameFormatter.format(props.databaseName?.toString(), scope.props.resourceNameOptions?.cosmosDbSqlDatabase),
71
+ resourceGroupName: resourceGroupName,
72
+ }, { parent: scope, ...resourceOptions });
73
+ }
74
+ /**
75
+ * @summary Method to create a new cosmosdb container
76
+ * @param id scoped id of the resource
77
+ * @param scope scope in which this resource is defined
78
+ * @param props cosmosdb container properties
79
+ * @param resourceOptions Optional settings to control resource behaviour
80
+ * @see [Pulumi Azure Native CosmosDB SQL Container]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqlcontainer/}
81
+ */
82
+ createCosmosDbContainer(id, scope, props, resourceOptions) {
83
+ if (!props)
84
+ throw `Props undefined for ${id}`;
85
+ // Get resource group name
86
+ const resourceGroupName = scope.props.resourceGroupName
87
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
88
+ : props.resourceGroupName;
89
+ if (!resourceGroupName)
90
+ throw `Resource group name undefined for ${id}`;
91
+ return new SqlResourceSqlContainer(`${id}-cc`, {
92
+ ...props,
93
+ containerName: scope.resourceNameFormatter.format(props.containerName?.toString(), scope.props.resourceNameOptions?.cosmosDbSqlContainer),
94
+ resourceGroupName: resourceGroupName,
95
+ }, { parent: scope, ...resourceOptions });
96
+ }
97
+ /**
98
+ * @summary Method to create a sql role assignment
99
+ * @param id scoped id of the resource
100
+ * @param scope scope in which this resource is defined
101
+ * @param props sql role assignment properties
102
+ * @param resourceOptions Optional settings to control resource behaviour
103
+ * @see [Pulumi Azure Native CosmosDB SQL Role Assignment]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqlroleassignment/}
104
+ */
105
+ createSqlResourceSqlRoleAssignment(id, scope, props, resourceOptions) {
106
+ return new SqlResourceSqlRoleAssignment(`${id}`, props, { parent: scope, ...resourceOptions });
107
+ }
108
+ /**
109
+ * @summary Method to resolve an existing cosmosdb account
110
+ * @param scope scope in which this resource is defined
111
+ * @param accountName the account name
112
+ * @param resourceGroupName the resource group name
113
+ * @param resourceOptions Optional settings to control resource behaviour
114
+ */
115
+ resolveCosmosDbAccount(scope, accountName, resourceGroupName, resourceOptions) {
116
+ return getDatabaseAccountOutput({ accountName, resourceGroupName }, { parent: scope, ...resourceOptions });
117
+ }
118
+ /**
119
+ * @summary Method to resolve an existing sql role definition
120
+ * @param scope scope in which this resource is defined
121
+ * @param accountName the account name
122
+ * @param resourceGroupName the resource group name
123
+ * @param roleDefinitionId the role definition id
124
+ * @param resourceOptions Optional settings to control resource behaviour
125
+ */
126
+ resolveSqlRoleDefinition(scope, accountName, resourceGroupName, roleDefinitionId, resourceOptions) {
127
+ return getSqlResourceSqlRoleDefinitionOutput({ accountName, resourceGroupName, roleDefinitionId }, { parent: scope, ...resourceOptions });
128
+ }
129
+ /**
130
+ * @summary Method to assign a sql role assignment
131
+ * @param id scoped id of the resource
132
+ * @param scope scope in which this resource is defined
133
+ * @param accountName the account name
134
+ * @param resourceGroupName the resource group name
135
+ * @param principalId the principal id to which the role is assigned to
136
+ * @param roleDefinitions list of role definitions to
137
+ * @param resourceOptions Optional settings to control resource behaviour
138
+ */
139
+ grantSqlRoleDefinitionToAccount(id, scope, accountName, resourceGroupName, principalId, roleDefinitions, resourceOptions) {
140
+ const cosmosDbAccount = this.resolveCosmosDbAccount(scope, accountName, resourceGroupName, resourceOptions);
141
+ if (roleDefinitions.includes(CosmosRoleDefinition.CONTRIBUTOR)) {
142
+ const cosmosdbSqlRoleDefinitionContributor = this.resolveSqlRoleDefinition(scope, cosmosDbAccount.name, resourceGroupName, CosmosRoleDefinitionId.CONTRIBUTOR, resourceOptions);
143
+ this.createSqlResourceSqlRoleAssignment(`${id}-cdb-ra-contributor`, scope, {
144
+ accountName: cosmosDbAccount.name,
145
+ resourceGroupName: resourceGroupName,
146
+ roleDefinitionId: cosmosdbSqlRoleDefinitionContributor.id,
147
+ principalId,
148
+ scope: cosmosDbAccount.id,
149
+ }, resourceOptions);
150
+ }
151
+ if (roleDefinitions.includes(CosmosRoleDefinition.READER)) {
152
+ const cosmosdbSqlRoleDefinitionReader = this.resolveSqlRoleDefinition(scope, cosmosDbAccount.name, resourceGroupName, CosmosRoleDefinitionId.READER, resourceOptions);
153
+ this.createSqlResourceSqlRoleAssignment(`${id}-cdb-ra-reader`, scope, {
154
+ accountName: cosmosDbAccount.name,
155
+ resourceGroupName: resourceGroupName,
156
+ roleDefinitionId: cosmosdbSqlRoleDefinitionReader.id,
157
+ principalId,
158
+ scope: cosmosDbAccount.id,
159
+ }, resourceOptions);
160
+ }
161
+ }
162
+ }
@@ -0,0 +1,9 @@
1
+ import { DatabaseAccountArgs, SqlResourceSqlContainerArgs, SqlResourceSqlDatabaseArgs, SqlResourceSqlRoleAssignmentArgs } from '@pulumi/azure-native/cosmosdb/index.js';
2
+ export interface CosmosdbAccountProps extends DatabaseAccountArgs {
3
+ }
4
+ export interface CosmosdbSqlDatabaseProps extends SqlResourceSqlDatabaseArgs {
5
+ }
6
+ export interface CosmosdbSqlContainerProps extends SqlResourceSqlContainerArgs {
7
+ }
8
+ export interface SqlResourceSqlRoleAssignmentProps extends SqlResourceSqlRoleAssignmentArgs {
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './main.js';
2
+ export * from './types.js';
@@ -0,0 +1,2 @@
1
+ export * from './main.js';
2
+ export * from './types.js';