@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.
- package/LICENSE +21 -0
- package/dist/src/common/constants.d.ts +83 -0
- package/dist/src/common/constants.js +87 -0
- package/dist/src/common/construct.d.ts +80 -0
- package/dist/src/common/construct.js +128 -0
- package/dist/src/common/index.d.ts +6 -0
- package/dist/src/common/index.js +6 -0
- package/dist/src/common/resource-name-formatter.d.ts +18 -0
- package/dist/src/common/resource-name-formatter.js +34 -0
- package/dist/src/common/stack.d.ts +46 -0
- package/dist/src/common/stack.js +120 -0
- package/dist/src/common/tagging.d.ts +29 -0
- package/dist/src/common/tagging.js +78 -0
- package/dist/src/common/types.d.ts +57 -0
- package/dist/src/common/types.js +1 -0
- package/dist/src/construct/event-handler/index.d.ts +2 -0
- package/dist/src/construct/event-handler/index.js +2 -0
- package/dist/src/construct/event-handler/main.d.ts +61 -0
- package/dist/src/construct/event-handler/main.js +180 -0
- package/dist/src/construct/event-handler/types.d.ts +35 -0
- package/dist/src/construct/event-handler/types.js +1 -0
- package/dist/src/construct/function-app/index.d.ts +2 -0
- package/dist/src/construct/function-app/index.js +2 -0
- package/dist/src/construct/function-app/main.d.ts +128 -0
- package/dist/src/construct/function-app/main.js +374 -0
- package/dist/src/construct/function-app/types.d.ts +33 -0
- package/dist/src/construct/function-app/types.js +1 -0
- package/dist/src/construct/index.d.ts +6 -0
- package/dist/src/construct/index.js +6 -0
- package/dist/src/construct/rest-api/index.d.ts +2 -0
- package/dist/src/construct/rest-api/index.js +2 -0
- package/dist/src/construct/rest-api/main.d.ts +64 -0
- package/dist/src/construct/rest-api/main.js +216 -0
- package/dist/src/construct/rest-api/types.d.ts +25 -0
- package/dist/src/construct/rest-api/types.js +1 -0
- package/dist/src/construct/rest-api-function/index.d.ts +2 -0
- package/dist/src/construct/rest-api-function/index.js +2 -0
- package/dist/src/construct/rest-api-function/main.d.ts +66 -0
- package/dist/src/construct/rest-api-function/main.js +302 -0
- package/dist/src/construct/rest-api-function/types.d.ts +29 -0
- package/dist/src/construct/rest-api-function/types.js +1 -0
- package/dist/src/construct/rest-api-with-cache/index.d.ts +2 -0
- package/dist/src/construct/rest-api-with-cache/index.js +2 -0
- package/dist/src/construct/rest-api-with-cache/main.d.ts +41 -0
- package/dist/src/construct/rest-api-with-cache/main.js +85 -0
- package/dist/src/construct/rest-api-with-cache/types.d.ts +13 -0
- package/dist/src/construct/rest-api-with-cache/types.js +1 -0
- package/dist/src/construct/site-with-webapp/index.d.ts +2 -0
- package/dist/src/construct/site-with-webapp/index.js +2 -0
- package/dist/src/construct/site-with-webapp/main.d.ts +60 -0
- package/dist/src/construct/site-with-webapp/main.js +176 -0
- package/dist/src/construct/site-with-webapp/types.d.ts +30 -0
- package/dist/src/construct/site-with-webapp/types.js +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +4 -0
- package/dist/src/services/api-management/index.d.ts +2 -0
- package/dist/src/services/api-management/index.js +2 -0
- package/dist/src/services/api-management/main.d.ts +143 -0
- package/dist/src/services/api-management/main.js +244 -0
- package/dist/src/services/api-management/types.d.ts +72 -0
- package/dist/src/services/api-management/types.js +1 -0
- package/dist/src/services/app-configuration/index.d.ts +2 -0
- package/dist/src/services/app-configuration/index.js +2 -0
- package/dist/src/services/app-configuration/main.d.ts +41 -0
- package/dist/src/services/app-configuration/main.js +71 -0
- package/dist/src/services/app-configuration/types.d.ts +3 -0
- package/dist/src/services/app-configuration/types.js +1 -0
- package/dist/src/services/app-service/index.d.ts +2 -0
- package/dist/src/services/app-service/index.js +2 -0
- package/dist/src/services/app-service/main.d.ts +40 -0
- package/dist/src/services/app-service/main.js +90 -0
- package/dist/src/services/app-service/types.d.ts +6 -0
- package/dist/src/services/app-service/types.js +1 -0
- package/dist/src/services/application-insights/index.d.ts +2 -0
- package/dist/src/services/application-insights/index.js +2 -0
- package/dist/src/services/application-insights/main.d.ts +40 -0
- package/dist/src/services/application-insights/main.js +68 -0
- package/dist/src/services/application-insights/types.d.ts +6 -0
- package/dist/src/services/application-insights/types.js +1 -0
- package/dist/src/services/authorisation/constants.d.ts +13 -0
- package/dist/src/services/authorisation/constants.js +14 -0
- package/dist/src/services/authorisation/index.d.ts +3 -0
- package/dist/src/services/authorisation/index.js +3 -0
- package/dist/src/services/authorisation/main.d.ts +84 -0
- package/dist/src/services/authorisation/main.js +120 -0
- package/dist/src/services/authorisation/types.d.ts +3 -0
- package/dist/src/services/authorisation/types.js +1 -0
- package/dist/src/services/cosmosdb/constants.d.ts +8 -0
- package/dist/src/services/cosmosdb/constants.js +10 -0
- package/dist/src/services/cosmosdb/index.d.ts +3 -0
- package/dist/src/services/cosmosdb/index.js +3 -0
- package/dist/src/services/cosmosdb/main.d.ts +87 -0
- package/dist/src/services/cosmosdb/main.js +162 -0
- package/dist/src/services/cosmosdb/types.d.ts +9 -0
- package/dist/src/services/cosmosdb/types.js +1 -0
- package/dist/src/services/dns/index.d.ts +2 -0
- package/dist/src/services/dns/index.js +2 -0
- package/dist/src/services/dns/main.d.ts +58 -0
- package/dist/src/services/dns/main.js +107 -0
- package/dist/src/services/dns/types.d.ts +9 -0
- package/dist/src/services/dns/types.js +1 -0
- package/dist/src/services/eventgrid/index.d.ts +2 -0
- package/dist/src/services/eventgrid/index.js +2 -0
- package/dist/src/services/eventgrid/main.d.ts +69 -0
- package/dist/src/services/eventgrid/main.js +136 -0
- package/dist/src/services/eventgrid/types.d.ts +11 -0
- package/dist/src/services/eventgrid/types.js +1 -0
- package/dist/src/services/function/index.d.ts +2 -0
- package/dist/src/services/function/index.js +2 -0
- package/dist/src/services/function/main.d.ts +60 -0
- package/dist/src/services/function/main.js +223 -0
- package/dist/src/services/function/types.d.ts +20 -0
- package/dist/src/services/function/types.js +1 -0
- package/dist/src/services/index.d.ts +18 -0
- package/dist/src/services/index.js +18 -0
- package/dist/src/services/key-vault/index.d.ts +2 -0
- package/dist/src/services/key-vault/index.js +2 -0
- package/dist/src/services/key-vault/main.d.ts +49 -0
- package/dist/src/services/key-vault/main.js +83 -0
- package/dist/src/services/key-vault/types.d.ts +5 -0
- package/dist/src/services/key-vault/types.js +1 -0
- package/dist/src/services/monitor/index.d.ts +2 -0
- package/dist/src/services/monitor/index.js +2 -0
- package/dist/src/services/monitor/main.d.ts +31 -0
- package/dist/src/services/monitor/main.js +36 -0
- package/dist/src/services/monitor/types.d.ts +3 -0
- package/dist/src/services/monitor/types.js +1 -0
- package/dist/src/services/operational-insights/index.d.ts +2 -0
- package/dist/src/services/operational-insights/index.js +2 -0
- package/dist/src/services/operational-insights/main.d.ts +40 -0
- package/dist/src/services/operational-insights/main.js +64 -0
- package/dist/src/services/operational-insights/types.d.ts +5 -0
- package/dist/src/services/operational-insights/types.js +1 -0
- package/dist/src/services/portal/error.d.ts +5 -0
- package/dist/src/services/portal/error.js +10 -0
- package/dist/src/services/portal/index.d.ts +4 -0
- package/dist/src/services/portal/index.js +4 -0
- package/dist/src/services/portal/main.d.ts +33 -0
- package/dist/src/services/portal/main.js +51 -0
- package/dist/src/services/portal/renderer.d.ts +11 -0
- package/dist/src/services/portal/renderer.js +156 -0
- package/dist/src/services/portal/types.d.ts +40 -0
- package/dist/src/services/portal/types.js +1 -0
- package/dist/src/services/redis/index.d.ts +2 -0
- package/dist/src/services/redis/index.js +2 -0
- package/dist/src/services/redis/main.d.ts +31 -0
- package/dist/src/services/redis/main.js +52 -0
- package/dist/src/services/redis/types.d.ts +3 -0
- package/dist/src/services/redis/types.js +1 -0
- package/dist/src/services/resource-group/index.d.ts +2 -0
- package/dist/src/services/resource-group/index.js +2 -0
- package/dist/src/services/resource-group/main.d.ts +38 -0
- package/dist/src/services/resource-group/main.js +53 -0
- package/dist/src/services/resource-group/types.d.ts +3 -0
- package/dist/src/services/resource-group/types.js +1 -0
- package/dist/src/services/security-center/index.d.ts +2 -0
- package/dist/src/services/security-center/index.js +2 -0
- package/dist/src/services/security-center/main.d.ts +31 -0
- package/dist/src/services/security-center/main.js +33 -0
- package/dist/src/services/security-center/types.d.ts +3 -0
- package/dist/src/services/security-center/types.js +1 -0
- package/dist/src/services/servicebus/index.d.ts +2 -0
- package/dist/src/services/servicebus/index.js +2 -0
- package/dist/src/services/servicebus/main.d.ts +67 -0
- package/dist/src/services/servicebus/main.js +127 -0
- package/dist/src/services/servicebus/types.d.ts +11 -0
- package/dist/src/services/servicebus/types.js +1 -0
- package/dist/src/services/storage/index.d.ts +2 -0
- package/dist/src/services/storage/index.js +2 -0
- package/dist/src/services/storage/main.d.ts +88 -0
- package/dist/src/services/storage/main.js +173 -0
- package/dist/src/services/storage/types.d.ts +20 -0
- package/dist/src/services/storage/types.js +1 -0
- package/dist/src/types/index.d.ts +4 -0
- package/dist/src/types/index.js +1 -0
- 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,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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,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 {};
|