@gradientedge/cdk-utils-azure 2.16.0 → 2.17.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { isDevStage, isPrdStage, isTestStage, isUatStage } from '@gradientedge/cdk-utils-common';
|
|
1
2
|
import { getWorkspaceOutput } from '@pulumi/azure-native/operationalinsights/index.js';
|
|
2
3
|
import * as pulumi from '@pulumi/pulumi';
|
|
3
4
|
import { ComponentResource } from '@pulumi/pulumi';
|
|
4
|
-
import { isDevStage, isPrdStage, isTestStage, isUatStage } from '@gradientedge/cdk-utils-common';
|
|
5
5
|
import { AzureAuthorisationManager } from '../services/authorisation/main.js';
|
|
6
6
|
import { AzureApiManagementManager, AzureAppConfigurationManager, AzureApplicationInsightsManager, AzureAppServiceManager, AzureCosmosDbManager, AzureDnsManager, AzureEventgridManager, AzureFunctionManager, AzureKeyVaultManager, AzureMonitorManager, AzureOperationalInsightsManager, AzurePortalManager, AzureRedisManager, AzureResourceGroupManager, AzureSecurityCentermanager, AzureServiceBusManager, AzureStorageManager, } from '../services/index.js';
|
|
7
7
|
import { AzureResourceNameFormatter } from './resource-name-formatter.js';
|
|
@@ -76,7 +76,9 @@ export class CommonAzureConstruct extends ComponentResource {
|
|
|
76
76
|
resolveStack(stackName) {
|
|
77
77
|
if (!stackName)
|
|
78
78
|
throw new Error('Stack name undefined');
|
|
79
|
-
return new pulumi.StackReference(stackName
|
|
79
|
+
return new pulumi.StackReference(stackName, {
|
|
80
|
+
name: stackName,
|
|
81
|
+
});
|
|
80
82
|
}
|
|
81
83
|
createResourceGroup() {
|
|
82
84
|
if (this.resourceGroup)
|
|
@@ -21,6 +21,7 @@ export declare class CommonAzureStack extends ComponentResource {
|
|
|
21
21
|
construct: CommonAzureConstruct;
|
|
22
22
|
props: CommonAzureStackProps;
|
|
23
23
|
config: Config;
|
|
24
|
+
outputs?: Record<string, unknown>;
|
|
24
25
|
constructor(name: string, props: CommonAzureStackProps, options?: ComponentResourceOptions);
|
|
25
26
|
/**
|
|
26
27
|
* @summary Method to determine the core construct properties injected via context
|
|
@@ -44,4 +45,6 @@ export declare class CommonAzureStack extends ComponentResource {
|
|
|
44
45
|
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
45
46
|
*/
|
|
46
47
|
protected fullyQualifiedDomain(): string;
|
|
48
|
+
protected static determineEnvironmentProperty(): string;
|
|
49
|
+
protected static getEnvironmentProperty(property: string): any;
|
|
47
50
|
}
|
package/dist/src/common/stack.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import fs, { readFileSync, statSync } from 'fs';
|
|
2
|
+
import path, { dirname, join } from 'path';
|
|
3
|
+
import { isDevStage } from '@gradientedge/cdk-utils-common';
|
|
3
4
|
import { ComponentResource, Config } from '@pulumi/pulumi';
|
|
4
5
|
import appRoot from 'app-root-path';
|
|
5
6
|
import _ from 'lodash';
|
|
6
|
-
import { isDevStage } from '@gradientedge/cdk-utils-common';
|
|
7
7
|
import { registerTagTransformation } from './tagging.js';
|
|
8
8
|
/**
|
|
9
9
|
* Common stack to use as a base for all higher level constructs using Pulumi
|
|
@@ -25,6 +25,7 @@ export class CommonAzureStack extends ComponentResource {
|
|
|
25
25
|
construct;
|
|
26
26
|
props;
|
|
27
27
|
config;
|
|
28
|
+
outputs;
|
|
28
29
|
constructor(name, props, options) {
|
|
29
30
|
super(`stack:${name}`, name, props, options);
|
|
30
31
|
/* initialise config */
|
|
@@ -118,4 +119,27 @@ export class CommonAzureStack extends ComponentResource {
|
|
|
118
119
|
const subDomain = this.props.subDomain;
|
|
119
120
|
return subDomain ? `${subDomain}.${domainName}` : domainName;
|
|
120
121
|
}
|
|
122
|
+
static determineEnvironmentProperty() {
|
|
123
|
+
const config = new Config();
|
|
124
|
+
const stageContextPath = config.get('stageContextPath');
|
|
125
|
+
let dir = process.cwd();
|
|
126
|
+
for (let i = 0; i < 6; i++) {
|
|
127
|
+
try {
|
|
128
|
+
if (statSync(join(dir, `${stageContextPath}`)).isDirectory())
|
|
129
|
+
return dir;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
/* keep walking */
|
|
133
|
+
}
|
|
134
|
+
dir = dirname(dir);
|
|
135
|
+
}
|
|
136
|
+
throw new Error('Could not locate infrastructure root (pulumi-env/ not found)');
|
|
137
|
+
}
|
|
138
|
+
static getEnvironmentProperty(property) {
|
|
139
|
+
const config = new Config();
|
|
140
|
+
const stage = config.get('stage');
|
|
141
|
+
const stageContextPath = config.get('stageContextPath');
|
|
142
|
+
const envConfig = JSON.parse(readFileSync(join(this.determineEnvironmentProperty(), `${stageContextPath}`, `${stage}.json`), 'utf8'));
|
|
143
|
+
return envConfig[property];
|
|
144
|
+
}
|
|
121
145
|
}
|
|
@@ -7,6 +7,13 @@ import { RESOURCES_TO_EXCLUDE_TAGS } from './constants.js';
|
|
|
7
7
|
*/
|
|
8
8
|
/** @category Constant */
|
|
9
9
|
export function isTaggableResource(resourceType) {
|
|
10
|
+
// Entire providers that don't support tags
|
|
11
|
+
if (resourceType.startsWith('azuread:'))
|
|
12
|
+
return false;
|
|
13
|
+
if (resourceType.startsWith('random:'))
|
|
14
|
+
return false;
|
|
15
|
+
if (resourceType.startsWith('pulumi:'))
|
|
16
|
+
return false;
|
|
10
17
|
// Extract the resource name from the type (e.g., 'ResourceGroup' from 'azure-native:resources:ResourceGroup')
|
|
11
18
|
const resourceName = resourceType.split(':').pop() || '';
|
|
12
19
|
// Check if this resource is in the exclusion list
|
|
@@ -75,9 +75,7 @@ export class AzureStorageManager {
|
|
|
75
75
|
createStorageContainer(id, scope, props, resourceOptions) {
|
|
76
76
|
if (!props)
|
|
77
77
|
throw new Error(`Props undefined for ${id}`);
|
|
78
|
-
const resourceGroupName = scope.props.resourceGroupName
|
|
79
|
-
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
80
|
-
: `${props.resourceGroupName}`;
|
|
78
|
+
const resourceGroupName = props.resourceGroupName ?? scope.resourceNameFormatter.format(scope.props.resourceGroupName);
|
|
81
79
|
return new BlobContainer(`${id}-sc`, {
|
|
82
80
|
...props,
|
|
83
81
|
containerName: scope.resourceNameFormatter.format(props.containerName?.toString(), scope.props.resourceNameOptions?.storageContainer),
|
|
@@ -97,9 +95,7 @@ export class AzureStorageManager {
|
|
|
97
95
|
createStorageBlob(id, scope, props, resourceOptions) {
|
|
98
96
|
if (!props)
|
|
99
97
|
throw new Error(`Props undefined for ${id}`);
|
|
100
|
-
const resourceGroupName = scope.props.resourceGroupName
|
|
101
|
-
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
102
|
-
: `${props.resourceGroupName}`;
|
|
98
|
+
const resourceGroupName = props.resourceGroupName ?? scope.resourceNameFormatter.format(scope.props.resourceGroupName);
|
|
103
99
|
return new Blob(`${id}-sb`, {
|
|
104
100
|
...props,
|
|
105
101
|
blobName: scope.resourceNameFormatter.format(props.blobName?.toString(), scope.props.resourceNameOptions?.storageBlob),
|
|
@@ -126,9 +122,7 @@ export class AzureStorageManager {
|
|
|
126
122
|
* @see https://www.pulumi.com/registry/packages/azure-native/api-docs/storage/liststorageaccountsas/
|
|
127
123
|
*/
|
|
128
124
|
generateContainerSasToken(id, scope, props, storageAccount) {
|
|
129
|
-
const resourceGroupName = scope.props.resourceGroupName
|
|
130
|
-
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
131
|
-
: `${props.resourceGroupName}`;
|
|
125
|
+
const resourceGroupName = props.resourceGroupName ?? scope.resourceNameFormatter.format(scope.props.resourceGroupName);
|
|
132
126
|
return pulumi
|
|
133
127
|
.all([storageAccount.name])
|
|
134
128
|
.apply(([accountName]) => {
|