@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,10 @@
|
|
|
1
|
+
export class TemplateError extends Error {
|
|
2
|
+
isTemplateError = true;
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = 'TemplateError';
|
|
6
|
+
}
|
|
7
|
+
static isInstance(error) {
|
|
8
|
+
return error instanceof Object && 'isTemplateError' in error && error.isTemplateError === true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ResourceOptions } from '@pulumi/pulumi';
|
|
2
|
+
import { CommonAzureConstruct } from '../../index.js';
|
|
3
|
+
import { AzureDashboardRenderer } from './renderer.js';
|
|
4
|
+
import { PortalDashboardProps } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* @classdesc Provides operations on Azure Portal Dashboards 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.azurePortalManager.createDashBoard('MyDashboard', this, props)
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class AzurePortalManager {
|
|
23
|
+
/**
|
|
24
|
+
* @summary Method to create a new portal dashboard
|
|
25
|
+
* @param id scoped id of the resource
|
|
26
|
+
* @param scope scope in which this resource is defined
|
|
27
|
+
* @param props the dashboard properties
|
|
28
|
+
* @param renderer An optional renderer to use
|
|
29
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
30
|
+
* @see [Pulumi Azure Native Portal Dashboard]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/portal/dashboard/}
|
|
31
|
+
*/
|
|
32
|
+
createDashBoard(id: string, scope: CommonAzureConstruct, props: PortalDashboardProps, renderer?: AzureDashboardRenderer, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/portal/dashboard.js").Dashboard;
|
|
33
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Dashboard } from '@pulumi/azure-native/portal/index.js';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { AzureDashboardRenderer } from './renderer.js';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Azure Portal Dashboards using Pulumi
|
|
6
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
7
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
13
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
14
|
+
* super(name, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.azurePortalManager.createDashBoard('MyDashboard', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class AzurePortalManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new portal dashboard
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props the dashboard properties
|
|
27
|
+
* @param renderer An optional renderer to use
|
|
28
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
29
|
+
* @see [Pulumi Azure Native Portal Dashboard]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/portal/dashboard/}
|
|
30
|
+
*/
|
|
31
|
+
createDashBoard(id, scope, props, renderer, resourceOptions) {
|
|
32
|
+
if (!props)
|
|
33
|
+
throw `Props undefined for ${id}`;
|
|
34
|
+
const resourceGroup = scope.resourceGroupManager.resolveResourceGroup(scope, props.resourceGroupName.toString() ?? scope.props.resourceGroupName, resourceOptions);
|
|
35
|
+
const dashboardName = scope.resourceNameFormatter.format(props.dashboardName?.toString(), scope.props.resourceNameOptions?.portalDashboard);
|
|
36
|
+
const dashboardRenderer = renderer ?? new AzureDashboardRenderer();
|
|
37
|
+
const templateFile = dashboardRenderer.renderToFile(dashboardName, props);
|
|
38
|
+
const template = fs.readFileSync(templateFile, 'utf-8');
|
|
39
|
+
const content = Object.entries(props.variables).reduce((result, [key, value]) => result.replaceAll(`\${${key}}`, String(value)), template);
|
|
40
|
+
return new Dashboard(`${id}-dashboard`, {
|
|
41
|
+
...props,
|
|
42
|
+
dashboardName: scope.resourceNameFormatter.format(props.dashboardName?.toString(), scope.props.resourceNameOptions?.portalDashboard),
|
|
43
|
+
resourceGroupName: resourceGroup.name,
|
|
44
|
+
location: props.location ?? resourceGroup.location,
|
|
45
|
+
properties: JSON.parse(content),
|
|
46
|
+
tags: {
|
|
47
|
+
'hidden-title': `${props.location} - ${props.displayName}`,
|
|
48
|
+
},
|
|
49
|
+
}, { ...resourceOptions, ignoreChanges: ['location'] });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DashboardRenderer, MissingKeys, PaneTemplate, RenderParams } from './types.js';
|
|
2
|
+
export declare class AzureDashboardRenderer implements DashboardRenderer {
|
|
3
|
+
private readonly paneTemplatePath;
|
|
4
|
+
private readonly outputDir;
|
|
5
|
+
constructor(basePath?: string, outputDir?: string);
|
|
6
|
+
private getPaneId;
|
|
7
|
+
getMissingProperties(template: PaneTemplate, properties?: RenderParams['properties']): MissingKeys;
|
|
8
|
+
getMissingVariables(template: PaneTemplate, variables: RenderParams['variables']): MissingKeys;
|
|
9
|
+
render(params: RenderParams): string;
|
|
10
|
+
renderToFile(filename: string, params: RenderParams): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import appRoot from 'app-root-path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { parse } from 'yaml';
|
|
6
|
+
import { TemplateError } from './error.js';
|
|
7
|
+
export class AzureDashboardRenderer {
|
|
8
|
+
paneTemplatePath;
|
|
9
|
+
outputDir;
|
|
10
|
+
constructor(basePath, outputDir) {
|
|
11
|
+
this.paneTemplatePath = basePath ?? path.join(appRoot.path, 'template', 'dashboard');
|
|
12
|
+
this.outputDir = outputDir ?? path.join(appRoot.path, '.artifacts');
|
|
13
|
+
}
|
|
14
|
+
getPaneId(id) {
|
|
15
|
+
const panePath = `${this.paneTemplatePath}/${id}.yaml`;
|
|
16
|
+
const paneFileContent = fs.readFileSync(panePath, 'utf-8');
|
|
17
|
+
const paneTemplate = parse(paneFileContent);
|
|
18
|
+
return paneTemplate;
|
|
19
|
+
}
|
|
20
|
+
getMissingProperties(template, properties = []) {
|
|
21
|
+
const keys = Object.keys(template.properties).filter(key => !(key in properties));
|
|
22
|
+
return {
|
|
23
|
+
keys,
|
|
24
|
+
hasMissingKeys: keys.length !== 0,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
getMissingVariables(template, variables) {
|
|
28
|
+
const keys = Object.keys(template.variables).filter(key => !(key in variables));
|
|
29
|
+
return {
|
|
30
|
+
keys,
|
|
31
|
+
hasMissingKeys: keys.length !== 0,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
render(params) {
|
|
35
|
+
_.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
|
|
36
|
+
// if client is used instead of hosts
|
|
37
|
+
let partsIndex = 0;
|
|
38
|
+
let yIndex = 0;
|
|
39
|
+
const parts = {};
|
|
40
|
+
for (const pane of params.panes) {
|
|
41
|
+
try {
|
|
42
|
+
const paneTemplate = this.getPaneId(pane.id);
|
|
43
|
+
const compiled = _.template(paneTemplate.template);
|
|
44
|
+
function getValue(value) {
|
|
45
|
+
try {
|
|
46
|
+
if (typeof value === 'number') {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
if (value.includes(':')) {
|
|
50
|
+
const [property, formatter] = value.split(':');
|
|
51
|
+
const unformattedValue = _.get(params.properties, property);
|
|
52
|
+
if (formatter === 'host') {
|
|
53
|
+
const host = new URL(unformattedValue);
|
|
54
|
+
const port = host.protocol.startsWith('https') ? '443' : '80';
|
|
55
|
+
return `${host.host}:${port}`;
|
|
56
|
+
}
|
|
57
|
+
return unformattedValue;
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
console.error('failed to process', value, 'with error', e);
|
|
63
|
+
return '';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const missingVariables = this.getMissingVariables(paneTemplate, params.variables);
|
|
67
|
+
if (missingVariables.hasMissingKeys) {
|
|
68
|
+
throw new TemplateError(`Failed to render pane ${pane.id}: Missing required variables [${missingVariables.keys.join(', ')}] for template substitution.`);
|
|
69
|
+
}
|
|
70
|
+
const paneProperties = {};
|
|
71
|
+
for (const [key, value] of Object.entries(pane.properties ?? {})) {
|
|
72
|
+
if (value === undefined || value === null) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
let resolvedValue = '';
|
|
76
|
+
if (typeof value === 'string') {
|
|
77
|
+
resolvedValue = getValue(value);
|
|
78
|
+
}
|
|
79
|
+
if (Array.isArray(value)) {
|
|
80
|
+
resolvedValue = value.map(v => getValue(v));
|
|
81
|
+
}
|
|
82
|
+
paneProperties[key] = resolvedValue;
|
|
83
|
+
}
|
|
84
|
+
const properties = { ...params.properties, yIndex, ...paneProperties };
|
|
85
|
+
const missingProperties = this.getMissingProperties(paneTemplate, properties);
|
|
86
|
+
if (missingProperties.hasMissingKeys) {
|
|
87
|
+
throw new TemplateError(`Failed to render pane ${pane.id}: Missing required properties [${missingProperties.keys.join(', ')}] for template substitution.`);
|
|
88
|
+
}
|
|
89
|
+
const paneContent = compiled(properties);
|
|
90
|
+
const paneJSON = JSON.parse(paneContent);
|
|
91
|
+
const templateParts = paneJSON.parts;
|
|
92
|
+
for (const part of templateParts) {
|
|
93
|
+
parts[`${partsIndex}`] = part;
|
|
94
|
+
partsIndex++;
|
|
95
|
+
}
|
|
96
|
+
yIndex += paneTemplate.dimensions.height;
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
if (TemplateError.isInstance(e)) {
|
|
100
|
+
throw e;
|
|
101
|
+
}
|
|
102
|
+
console.error('failed to render pane', pane.id, 'with error', e);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const dashboard = {
|
|
106
|
+
lenses: {
|
|
107
|
+
'0': {
|
|
108
|
+
order: 0,
|
|
109
|
+
parts,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
metadata: {
|
|
113
|
+
model: {
|
|
114
|
+
timeRange: {
|
|
115
|
+
value: {
|
|
116
|
+
relative: {
|
|
117
|
+
duration: 24,
|
|
118
|
+
timeUnit: 1,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
type: 'MsPortalFx.Composition.Configuration.ValueTypes.TimeRange',
|
|
122
|
+
},
|
|
123
|
+
filterLocale: {
|
|
124
|
+
value: params.filter?.locale ?? 'en-us',
|
|
125
|
+
},
|
|
126
|
+
filters: {
|
|
127
|
+
value: {
|
|
128
|
+
MsPortalFx_TimeRange: {
|
|
129
|
+
model: {
|
|
130
|
+
format: params.filter?.timeFormat ?? 'utc',
|
|
131
|
+
granularity: params.filter?.timeGranularity ?? 'auto',
|
|
132
|
+
relative: params.filter?.timeRelative ?? '4h',
|
|
133
|
+
},
|
|
134
|
+
displayCache: {
|
|
135
|
+
name: 'UTC Time',
|
|
136
|
+
value: 'Past 4 hours',
|
|
137
|
+
},
|
|
138
|
+
filteredPartIds: [],
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
return JSON.stringify(dashboard, null, 2);
|
|
146
|
+
}
|
|
147
|
+
renderToFile(filename, params) {
|
|
148
|
+
const templateOutput = this.render(params);
|
|
149
|
+
if (!fs.existsSync(this.outputDir)) {
|
|
150
|
+
fs.mkdirSync(this.outputDir, { recursive: true });
|
|
151
|
+
}
|
|
152
|
+
const filePath = path.join(this.outputDir, `${filename}.tftpl`);
|
|
153
|
+
fs.writeFileSync(filePath, templateOutput);
|
|
154
|
+
return filePath;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DashboardArgs } from '@pulumi/azure-native/portal/index.js';
|
|
2
|
+
export type PaneTemplate = {
|
|
3
|
+
dimensions: {
|
|
4
|
+
height: number;
|
|
5
|
+
};
|
|
6
|
+
properties: Record<string, string>;
|
|
7
|
+
variables: Record<string, string>;
|
|
8
|
+
template: string;
|
|
9
|
+
};
|
|
10
|
+
export type MissingKeys = {
|
|
11
|
+
keys: Array<string>;
|
|
12
|
+
hasMissingKeys: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type Pane = {
|
|
15
|
+
id: string;
|
|
16
|
+
properties?: Record<string, string | number | Array<string | number>>;
|
|
17
|
+
};
|
|
18
|
+
export type Filter = {
|
|
19
|
+
locale?: string;
|
|
20
|
+
timeFormat?: string;
|
|
21
|
+
timeGranularity?: string;
|
|
22
|
+
timeRelative?: string;
|
|
23
|
+
};
|
|
24
|
+
export type RenderParams = {
|
|
25
|
+
panes: Array<Pane>;
|
|
26
|
+
variables: Record<string, any>;
|
|
27
|
+
properties?: Record<string, any>;
|
|
28
|
+
filter?: Filter;
|
|
29
|
+
};
|
|
30
|
+
export interface DashboardRenderer {
|
|
31
|
+
render(params: RenderParams): string;
|
|
32
|
+
renderToFile(filename: string, params: RenderParams): string;
|
|
33
|
+
}
|
|
34
|
+
export interface PortalDashboardProps extends DashboardArgs {
|
|
35
|
+
displayName: string;
|
|
36
|
+
panes: Array<Pane>;
|
|
37
|
+
variables: Record<string, string>;
|
|
38
|
+
filter?: Filter;
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ResourceOptions } from '@pulumi/pulumi';
|
|
2
|
+
import { CommonAzureConstruct } from '../../common/index.js';
|
|
3
|
+
import { RedisProps } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Azure Redis using Pulumi
|
|
6
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
7
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
13
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
14
|
+
* super(name, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.redisManager.createManagedRedis('MyManagedRedis', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class AzureRedisManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new managed redis cache
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props redis cache properties
|
|
27
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
28
|
+
* @see [Pulumi Azure Native Redis]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/cache/redis/}
|
|
29
|
+
*/
|
|
30
|
+
createManagedRedis(id: string, scope: CommonAzureConstruct, props: RedisProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/redis/redis.js").Redis;
|
|
31
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Redis, SkuFamily, SkuName } from '@pulumi/azure-native/redis/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @classdesc Provides operations on Azure Redis 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.redisManager.createManagedRedis('MyManagedRedis', this, props)
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class AzureRedisManager {
|
|
20
|
+
/**
|
|
21
|
+
* @summary Method to create a new managed redis cache
|
|
22
|
+
* @param id scoped id of the resource
|
|
23
|
+
* @param scope scope in which this resource is defined
|
|
24
|
+
* @param props redis cache properties
|
|
25
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
26
|
+
* @see [Pulumi Azure Native Redis]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/cache/redis/}
|
|
27
|
+
*/
|
|
28
|
+
createManagedRedis(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.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
34
|
+
: props.resourceGroupName;
|
|
35
|
+
if (!resourceGroupName)
|
|
36
|
+
throw `Resource group name undefined for ${id}`;
|
|
37
|
+
return new Redis(`${id}-rc`, {
|
|
38
|
+
...props,
|
|
39
|
+
name: scope.resourceNameFormatter.format(props.name?.toString(), scope.props.resourceNameOptions?.managedRedis),
|
|
40
|
+
location: props.location ?? scope.props.location,
|
|
41
|
+
resourceGroupName: resourceGroupName,
|
|
42
|
+
sku: props.sku ?? {
|
|
43
|
+
name: SkuName.Basic,
|
|
44
|
+
family: SkuFamily.C,
|
|
45
|
+
capacity: 0,
|
|
46
|
+
},
|
|
47
|
+
tags: props.tags ?? {
|
|
48
|
+
environment: scope.props.stage,
|
|
49
|
+
},
|
|
50
|
+
}, { parent: scope, ...resourceOptions });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ResourceOptions } from '@pulumi/pulumi';
|
|
2
|
+
import { CommonAzureConstruct } from '../../common/index.js';
|
|
3
|
+
import { ResourceGroupProps } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Azure Resource Group using Pulumi
|
|
6
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
7
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
13
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
14
|
+
* super(name, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.resourceGroupManager.createResourceGroup('MyResourceGroup', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class AzureResourceGroupManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new resource group
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props resource group properties
|
|
27
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
28
|
+
* @see [Pulumi Azure Native Resource Group]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/resources/resourcegroup/}
|
|
29
|
+
*/
|
|
30
|
+
createResourceGroup(id: string, scope: CommonAzureConstruct, props: ResourceGroupProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/resources/resourceGroup.js").ResourceGroup;
|
|
31
|
+
/**
|
|
32
|
+
* @summary Method to resolve an existing resource group
|
|
33
|
+
* @param scope scope in which this resource is defined
|
|
34
|
+
* @param resourceGroupName the resource group name
|
|
35
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
36
|
+
*/
|
|
37
|
+
resolveResourceGroup(scope: CommonAzureConstruct, resourceGroupName: string, resourceOptions?: ResourceOptions): import("@pulumi/pulumi").Output<import("@pulumi/azure-native/resources/getResourceGroup.js").GetResourceGroupResult>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getResourceGroupOutput, ResourceGroup } from '@pulumi/azure-native/resources/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @classdesc Provides operations on Azure Resource Group 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.resourceGroupManager.createResourceGroup('MyResourceGroup', this, props)
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class AzureResourceGroupManager {
|
|
20
|
+
/**
|
|
21
|
+
* @summary Method to create a new resource group
|
|
22
|
+
* @param id scoped id of the resource
|
|
23
|
+
* @param scope scope in which this resource is defined
|
|
24
|
+
* @param props resource group properties
|
|
25
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
26
|
+
* @see [Pulumi Azure Native Resource Group]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/resources/resourcegroup/}
|
|
27
|
+
*/
|
|
28
|
+
createResourceGroup(id, scope, props, resourceOptions) {
|
|
29
|
+
if (!props)
|
|
30
|
+
throw `Props undefined for ${id}`;
|
|
31
|
+
return new ResourceGroup(`${id}-rg`, {
|
|
32
|
+
...props,
|
|
33
|
+
resourceGroupName: scope.resourceNameFormatter.format(props.resourceGroupName?.toString(), scope.props.resourceNameOptions?.resourceGroup),
|
|
34
|
+
location: props.location,
|
|
35
|
+
tags: props.tags ?? {
|
|
36
|
+
environment: scope.props.stage,
|
|
37
|
+
},
|
|
38
|
+
}, { parent: scope, ...resourceOptions });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @summary Method to resolve an existing resource group
|
|
42
|
+
* @param scope scope in which this resource is defined
|
|
43
|
+
* @param resourceGroupName the resource group name
|
|
44
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
45
|
+
*/
|
|
46
|
+
resolveResourceGroup(scope, resourceGroupName, resourceOptions) {
|
|
47
|
+
if (!resourceGroupName)
|
|
48
|
+
throw `Resource Group Name undefined`;
|
|
49
|
+
return getResourceGroupOutput({
|
|
50
|
+
resourceGroupName: scope.resourceNameFormatter.format(resourceGroupName?.toString(), scope.props.resourceNameOptions?.resourceGroup),
|
|
51
|
+
}, { parent: scope, ...resourceOptions });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ResourceOptions } from '@pulumi/pulumi';
|
|
2
|
+
import { CommonAzureConstruct } from '../../common/index.js';
|
|
3
|
+
import { DefenderForStorageProps } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Azure Security Center using Pulumi
|
|
6
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
7
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
13
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
14
|
+
* super(name, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.securityCenterManager.createDefenderForStorage('MyDefender', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class AzureSecurityCentermanager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new defender for storage account
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props defender for storage account properties
|
|
27
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
28
|
+
* @see [Pulumi Azure Native Defender For Storage]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/security/defenderforstorage/}
|
|
29
|
+
*/
|
|
30
|
+
createDefenderForStorage(id: string, scope: CommonAzureConstruct, props: DefenderForStorageProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/security/defenderForStorage.js").DefenderForStorage;
|
|
31
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DefenderForStorage } from '@pulumi/azure-native/security/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @classdesc Provides operations on Azure Security Center 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.securityCenterManager.createDefenderForStorage('MyDefender', this, props)
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class AzureSecurityCentermanager {
|
|
20
|
+
/**
|
|
21
|
+
* @summary Method to create a new defender for storage account
|
|
22
|
+
* @param id scoped id of the resource
|
|
23
|
+
* @param scope scope in which this resource is defined
|
|
24
|
+
* @param props defender for storage account properties
|
|
25
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
26
|
+
* @see [Pulumi Azure Native Defender For Storage]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/security/defenderforstorage/}
|
|
27
|
+
*/
|
|
28
|
+
createDefenderForStorage(id, scope, props, resourceOptions) {
|
|
29
|
+
if (!props)
|
|
30
|
+
throw `Props undefined for ${id}`;
|
|
31
|
+
return new DefenderForStorage(`${id}`, props, { parent: scope, ...resourceOptions });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|