@gradientedge/cdk-utils-azure 2.29.0 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/services/app-service/main.js +1 -1
- package/dist/src/services/application-insights/index.d.ts +1 -0
- package/dist/src/services/application-insights/index.js +1 -0
- package/dist/src/services/application-insights/main.d.ts +11 -1
- package/dist/src/services/application-insights/main.js +37 -1
- package/dist/src/services/application-insights/renderer.d.ts +7 -0
- package/dist/src/services/application-insights/renderer.js +25 -0
- package/dist/src/services/application-insights/types.d.ts +11 -1
- package/package.json +5 -5
|
@@ -42,7 +42,7 @@ export class AzureAppServiceManager {
|
|
|
42
42
|
tier: 'FlexConsumption',
|
|
43
43
|
},
|
|
44
44
|
reserved: props.reserved ?? true,
|
|
45
|
-
zoneRedundant: props.zoneRedundant ??
|
|
45
|
+
zoneRedundant: props.zoneRedundant ?? true,
|
|
46
46
|
tags: {
|
|
47
47
|
environment: scope.props.stage,
|
|
48
48
|
...scope.props.defaultTags,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ResourceOptions } from '@pulumi/pulumi';
|
|
2
2
|
import { CommonAzureConstruct } from '../../common/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { AzureWorkbookRenderer } from './renderer.js';
|
|
4
|
+
import { ApplicationInsightsProps, ComponentCurrentBillingFeatureProps, WorkbookProps } from './types.js';
|
|
4
5
|
/**
|
|
5
6
|
* Provides operations on Azure Application Insights using Pulumi
|
|
6
7
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -38,4 +39,13 @@ export declare class AzureApplicationInsightsManager {
|
|
|
38
39
|
* @see [Pulumi Azure Native Application Insights Billing Feature]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/insights/componentcurrentbillingfeature/}
|
|
39
40
|
*/
|
|
40
41
|
createComponentCurrentBillingFeature(id: string, scope: CommonAzureConstruct, props: ComponentCurrentBillingFeatureProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/applicationinsights/componentCurrentBillingFeature.js").ComponentCurrentBillingFeature;
|
|
42
|
+
/**
|
|
43
|
+
* @summary Method to create a new application insights workbook
|
|
44
|
+
* @param id scoped id of the resource
|
|
45
|
+
* @param scope scope in which this resource is defined
|
|
46
|
+
* @param props application insights workbook properties
|
|
47
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
48
|
+
* @see [Pulumi Azure Native Application Insights Billing Feature]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/applicationinsights/workbook/}
|
|
49
|
+
*/
|
|
50
|
+
createWorkbook(id: string, scope: CommonAzureConstruct, props: WorkbookProps, renderer?: AzureWorkbookRenderer, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/applicationinsights/workbook.js").Workbook;
|
|
41
51
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { ApplicationType, Component, ComponentCurrentBillingFeature, Workbook, WorkbookSharedTypeKind, } from '@pulumi/azure-native/applicationinsights/index.js';
|
|
3
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
4
|
+
import { AzureWorkbookRenderer } from './renderer.js';
|
|
2
5
|
/**
|
|
3
6
|
* Provides operations on Azure Application Insights using Pulumi
|
|
4
7
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -72,4 +75,37 @@ export class AzureApplicationInsightsManager {
|
|
|
72
75
|
throw new Error(`Props undefined for ${id}`);
|
|
73
76
|
return new ComponentCurrentBillingFeature(`${id}`, props, { parent: scope, ...resourceOptions });
|
|
74
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* @summary Method to create a new application insights workbook
|
|
80
|
+
* @param id scoped id of the resource
|
|
81
|
+
* @param scope scope in which this resource is defined
|
|
82
|
+
* @param props application insights workbook properties
|
|
83
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
84
|
+
* @see [Pulumi Azure Native Application Insights Billing Feature]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/applicationinsights/workbook/}
|
|
85
|
+
*/
|
|
86
|
+
createWorkbook(id, scope, props, renderer, resourceOptions) {
|
|
87
|
+
if (!props)
|
|
88
|
+
throw new Error(`Props undefined for ${id}`);
|
|
89
|
+
const resourceGroup = scope.resourceGroup ??
|
|
90
|
+
scope.resourceGroupManager.resolveResourceGroup(scope, props.resourceGroupName.toString() ?? scope.props.resourceGroupName, resourceOptions);
|
|
91
|
+
const workbookRenderer = renderer ?? new AzureWorkbookRenderer();
|
|
92
|
+
const templateFile = workbookRenderer.renderToFile(props.slug, props.templateId, props.variables);
|
|
93
|
+
const template = fs.readFileSync(templateFile, 'utf-8');
|
|
94
|
+
const keys = Object.keys(props.variables);
|
|
95
|
+
const values = Object.values(props.variables);
|
|
96
|
+
const properties = pulumi.all(values).apply(resolved => {
|
|
97
|
+
const content = keys.reduce((result, key, i) => result.replaceAll(`\${${key}}`, JSON.stringify(String(resolved[i])).slice(1, -1)), template);
|
|
98
|
+
return JSON.parse(content);
|
|
99
|
+
});
|
|
100
|
+
return new Workbook(`${id}`, {
|
|
101
|
+
...props,
|
|
102
|
+
displayName: `${props.location} - ${props.displayName}`,
|
|
103
|
+
resourceGroupName: resourceGroup.name,
|
|
104
|
+
location: props.location ?? resourceGroup.location,
|
|
105
|
+
kind: props.kind ?? WorkbookSharedTypeKind.Shared,
|
|
106
|
+
serializedData: properties.apply(p => JSON.stringify(p)),
|
|
107
|
+
sourceId: props.sourceId?.toString().toLowerCase(),
|
|
108
|
+
category: props.category ?? 'workbook',
|
|
109
|
+
}, { parent: scope, ...resourceOptions, ignoreChanges: ['location'] });
|
|
110
|
+
}
|
|
75
111
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WorkbookRenderer } from './types.js';
|
|
2
|
+
export declare class AzureWorkbookRenderer implements WorkbookRenderer {
|
|
3
|
+
readonly templatePath: string;
|
|
4
|
+
readonly outputDir: string;
|
|
5
|
+
constructor(basePath?: string, outputDir?: string);
|
|
6
|
+
renderToFile(filename: string, templateId: string, variables: Record<string, string>): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import appRoot from 'app-root-path';
|
|
4
|
+
import { parse } from 'yaml';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
export class AzureWorkbookRenderer {
|
|
7
|
+
templatePath;
|
|
8
|
+
outputDir;
|
|
9
|
+
constructor(basePath, outputDir) {
|
|
10
|
+
this.templatePath = basePath ?? path.join(appRoot.path, 'template', 'workbook');
|
|
11
|
+
this.outputDir = outputDir ?? path.join(appRoot.path, '.artifacts');
|
|
12
|
+
}
|
|
13
|
+
renderToFile(filename, templateId, variables) {
|
|
14
|
+
const templateFilePath = `${this.templatePath}/${templateId}.yaml`;
|
|
15
|
+
const templateContent = fs.readFileSync(templateFilePath, 'utf-8');
|
|
16
|
+
const parsed = parse(templateContent);
|
|
17
|
+
_.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
|
|
18
|
+
const compiled = _.template(parsed.template);
|
|
19
|
+
const rendered = compiled(variables);
|
|
20
|
+
const outputPath = path.join(this.outputDir, `${filename}-workbook.json`);
|
|
21
|
+
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
22
|
+
fs.writeFileSync(outputPath, rendered, 'utf-8');
|
|
23
|
+
return outputPath;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import { ComponentArgs, ComponentCurrentBillingFeatureArgs } from '@pulumi/azure-native/applicationinsights/index.js';
|
|
1
|
+
import { ComponentArgs, ComponentCurrentBillingFeatureArgs, WorkbookArgs } from '@pulumi/azure-native/applicationinsights/index.js';
|
|
2
2
|
/** @category Interface */
|
|
3
3
|
export interface ComponentCurrentBillingFeatureProps extends ComponentCurrentBillingFeatureArgs {
|
|
4
4
|
}
|
|
5
5
|
/** @category Interface */
|
|
6
|
+
export interface WorkbookProps extends WorkbookArgs {
|
|
7
|
+
slug: string;
|
|
8
|
+
templateId: string;
|
|
9
|
+
variables: Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
/** @category Interface */
|
|
6
12
|
export interface ApplicationInsightsProps extends ComponentArgs {
|
|
7
13
|
billingFeatures?: ComponentCurrentBillingFeatureProps;
|
|
8
14
|
}
|
|
15
|
+
/** @category Interface */
|
|
16
|
+
export interface WorkbookRenderer {
|
|
17
|
+
renderToFile(filename: string, templateId: string, variables: Record<string, any>): string;
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils-azure",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.0",
|
|
4
4
|
"description": "Azure Pulumi utilities for @gradientedge/cdk-utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"dist/src/"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@pulumi/archive": "0.3.
|
|
17
|
+
"@pulumi/archive": "0.3.8",
|
|
18
18
|
"@pulumi/azure-native": "3.17.0",
|
|
19
19
|
"@pulumi/azuread": "6.9.0",
|
|
20
|
-
"@pulumi/pulumi": "3.
|
|
20
|
+
"@pulumi/pulumi": "3.236.0",
|
|
21
21
|
"@types/lodash": "4.17.24",
|
|
22
22
|
"app-root-path": "3.1.0",
|
|
23
23
|
"lodash": "4.18.1",
|
|
24
24
|
"uuid": "14.0.0",
|
|
25
|
-
"yaml": "2.8.
|
|
26
|
-
"@gradientedge/cdk-utils-common": "2.2.
|
|
25
|
+
"yaml": "2.8.4",
|
|
26
|
+
"@gradientedge/cdk-utils-common": "2.2.1"
|
|
27
27
|
},
|
|
28
28
|
"keywords": [
|
|
29
29
|
"gradientedge",
|