@drunk-pulumi/azure-components 0.0.6 → 1.0.1
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/helpers/autoTags.d.ts +10 -0
- package/helpers/autoTags.js +16 -1
- package/helpers/azureEnv.d.ts +81 -0
- package/helpers/azureEnv.js +95 -1
- package/helpers/configHelper.d.ts +52 -0
- package/helpers/configHelper.js +53 -1
- package/helpers/rsHelpers.d.ts +55 -2
- package/helpers/rsHelpers.js +67 -6
- package/helpers/stackEnv.d.ts +24 -0
- package/helpers/stackEnv.js +29 -2
- package/package.json +1 -1
- package/vault/helpers.js +3 -7
package/helpers/autoTags.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a stack transformation that automatically applies tags to resources.
|
|
3
|
+
*
|
|
4
|
+
* This function creates a Pulumi stack transformation that adds specified tags to
|
|
5
|
+
* supported Azure resources. It excludes certain resource types defined in the
|
|
6
|
+
* ignoredTags list and handles resource groups differently.
|
|
7
|
+
*
|
|
8
|
+
* @param autoTags - An object containing key-value pairs of tags to be applied
|
|
9
|
+
* @returns void - The function registers a stack transformation with Pulumi runtime
|
|
10
|
+
*/
|
|
1
11
|
export declare const registerAutoTags: (autoTags: Record<string, string>) => void;
|
package/helpers/autoTags.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerAutoTags = void 0;
|
|
4
4
|
const pulumi_1 = require("@pulumi/pulumi");
|
|
5
|
+
/**
|
|
6
|
+
* List of resource types that should be excluded from automatic tagging.
|
|
7
|
+
* These are typically identity/auth related resources or external provider resources
|
|
8
|
+
* that don't support or need tagging.
|
|
9
|
+
*/
|
|
5
10
|
const ignoredTags = [
|
|
6
11
|
'Group',
|
|
7
12
|
'GroupMember',
|
|
@@ -14,6 +19,16 @@ const ignoredTags = [
|
|
|
14
19
|
'providers',
|
|
15
20
|
'dynamic:Resource',
|
|
16
21
|
];
|
|
22
|
+
/**
|
|
23
|
+
* Registers a stack transformation that automatically applies tags to resources.
|
|
24
|
+
*
|
|
25
|
+
* This function creates a Pulumi stack transformation that adds specified tags to
|
|
26
|
+
* supported Azure resources. It excludes certain resource types defined in the
|
|
27
|
+
* ignoredTags list and handles resource groups differently.
|
|
28
|
+
*
|
|
29
|
+
* @param autoTags - An object containing key-value pairs of tags to be applied
|
|
30
|
+
* @returns void - The function registers a stack transformation with Pulumi runtime
|
|
31
|
+
*/
|
|
17
32
|
const registerAutoTags = (autoTags) => pulumi_1.runtime.registerStackTransformation((resource) => {
|
|
18
33
|
//Check and ignore tag
|
|
19
34
|
if (!resource.type.toLowerCase().includes('resourcegroup') &&
|
|
@@ -24,4 +39,4 @@ const registerAutoTags = (autoTags) => pulumi_1.runtime.registerStackTransformat
|
|
|
24
39
|
return { props: resource.props, opts: resource.opts };
|
|
25
40
|
});
|
|
26
41
|
exports.registerAutoTags = registerAutoTags;
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0b1RhZ3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaGVscGVycy9hdXRvVGFncy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwyQ0FBeUM7QUFFekM7Ozs7R0FJRztBQUNILE1BQU0sV0FBVyxHQUFHO0lBQ2xCLE9BQU87SUFDUCxhQUFhO0lBQ2IsYUFBYTtJQUNiLHFCQUFxQjtJQUNyQixrQkFBa0I7SUFDbEIsMEJBQTBCO0lBQzFCLFlBQVk7SUFDWixZQUFZO0lBQ1osV0FBVztJQUNYLGtCQUFrQjtDQUNuQixDQUFDO0FBRUY7Ozs7Ozs7OztHQVNHO0FBQ0ksTUFBTSxnQkFBZ0IsR0FBRyxDQUFDLFFBQWdDLEVBQUUsRUFBRSxDQUNuRSxnQkFBTyxDQUFDLDJCQUEyQixDQUFDLENBQUMsUUFBUSxFQUFFLEVBQUU7SUFDL0Msc0JBQXNCO0lBQ3RCLElBQ0UsQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDLFFBQVEsQ0FBQyxlQUFlLENBQUM7UUFDdEQsV0FBVyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsRUFBRSxFQUFFLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUM7UUFFOUUsT0FBTyxFQUFFLEtBQUssRUFBRSxRQUFRLENBQUMsS0FBSyxFQUFFLElBQUksRUFBRSxRQUFRLENBQUMsSUFBSSxFQUFFLENBQUM7SUFFeEQsbUJBQW1CO0lBQ25CLFFBQVEsQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLEdBQUcsRUFBRSxHQUFHLFFBQVEsQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLEVBQUUsR0FBRyxRQUFRLEVBQUUsQ0FBQztJQUNwRSxPQUFPLEVBQUUsS0FBSyxFQUFFLFFBQVEsQ0FBQyxLQUFLLEVBQUUsSUFBSSxFQUFFLFFBQVEsQ0FBQyxJQUFJLEVBQUUsQ0FBQztBQUN4RCxDQUFDLENBQUMsQ0FBQztBQVpRLFFBQUEsZ0JBQWdCLG9CQVl4QiJ9
|
package/helpers/azureEnv.d.ts
CHANGED
|
@@ -1,21 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module azureEnv
|
|
3
|
+
* @description Module for handling Azure environment configuration and settings
|
|
4
|
+
*/
|
|
1
5
|
import * as pulumi from '@pulumi/pulumi';
|
|
6
|
+
/**
|
|
7
|
+
* @enum {string}
|
|
8
|
+
* @description Enumeration of supported Azure deployment environments
|
|
9
|
+
*/
|
|
2
10
|
export declare enum Environments {
|
|
3
11
|
Global = "global",
|
|
4
12
|
Dev = "dev",
|
|
5
13
|
Sandbox = "sandbox",
|
|
6
14
|
Prd = "prd"
|
|
7
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* @constant {Output<string>} tenantId
|
|
18
|
+
* @description Azure tenant ID from config or client config
|
|
19
|
+
*/
|
|
8
20
|
export declare const tenantId: any;
|
|
21
|
+
/**
|
|
22
|
+
* @constant {Output<string>} subscriptionId
|
|
23
|
+
* @description Azure subscription ID from config or client config
|
|
24
|
+
*/
|
|
9
25
|
export declare const subscriptionId: any;
|
|
26
|
+
/**
|
|
27
|
+
* @constant {Output<string>} currentPrincipal
|
|
28
|
+
* @description Current Azure principal object ID
|
|
29
|
+
*/
|
|
10
30
|
export declare const currentPrincipal: pulumi.Output<string>;
|
|
31
|
+
/**
|
|
32
|
+
* @constant {string} currentRegionName
|
|
33
|
+
* @description Current Azure region name, defaults to 'SoutheastAsia'
|
|
34
|
+
*/
|
|
11
35
|
export declare const currentRegionName: string;
|
|
36
|
+
/**
|
|
37
|
+
* @constant {string} currentRegionCode
|
|
38
|
+
* @description Region code derived from current region name
|
|
39
|
+
*/
|
|
12
40
|
export declare const currentRegionCode: string;
|
|
41
|
+
/**
|
|
42
|
+
* @constant {string} currentCountryCode
|
|
43
|
+
* @description Country code derived from current region name
|
|
44
|
+
*/
|
|
13
45
|
export declare const currentCountryCode: string;
|
|
46
|
+
/**
|
|
47
|
+
* @constant {Output<string>} defaultSubScope
|
|
48
|
+
* @description Default subscription scope string
|
|
49
|
+
*/
|
|
14
50
|
export declare const defaultSubScope: pulumi.Output<string>;
|
|
51
|
+
/**
|
|
52
|
+
* @function isEnv
|
|
53
|
+
* @description Checks if current stack includes specified environment
|
|
54
|
+
* @param {Environments} env - Environment to check
|
|
55
|
+
* @returns {boolean} True if stack includes the environment
|
|
56
|
+
*/
|
|
15
57
|
export declare const isEnv: (env: Environments) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* @constant {boolean} isDev
|
|
60
|
+
* @description Indicates if current environment is Development
|
|
61
|
+
*/
|
|
16
62
|
export declare const isDev: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* @constant {boolean} isSandbox
|
|
65
|
+
* @description Indicates if current environment is Sandbox
|
|
66
|
+
*/
|
|
17
67
|
export declare const isSandbox: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* @constant {boolean} isPrd
|
|
70
|
+
* @description Indicates if current environment is Production
|
|
71
|
+
*/
|
|
18
72
|
export declare const isPrd: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* @constant {boolean} isGlobal
|
|
75
|
+
* @description Indicates if current environment is Global
|
|
76
|
+
*/
|
|
19
77
|
export declare const isGlobal: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* @constant {Environments} currentEnv
|
|
80
|
+
* @description Current environment value
|
|
81
|
+
*/
|
|
20
82
|
export declare const currentEnv: Environments;
|
|
83
|
+
/**
|
|
84
|
+
* @constant {string[]} defaultAzurePorts
|
|
85
|
+
* @description List of default Azure ports commonly used in network security rules
|
|
86
|
+
* @property {string} 22 - SSH
|
|
87
|
+
* @property {string} 443 - HTTPS
|
|
88
|
+
* @property {string} 445 - SMB
|
|
89
|
+
* @property {string} 1433 - MSSQL
|
|
90
|
+
* @property {string} 1194 - OpenVPN
|
|
91
|
+
* @property {string} 3306 - MySQL
|
|
92
|
+
* @property {string} 3389 - RDP
|
|
93
|
+
* @property {string} 5432 - PostgreSQL
|
|
94
|
+
* @property {string} 5671 - AMQP with TLS
|
|
95
|
+
* @property {string} 5672 - AMQP
|
|
96
|
+
* @property {string} 6379 - Redis
|
|
97
|
+
* @property {string} 6380 - Redis with TLS
|
|
98
|
+
* @property {string} 8883 - MQTT
|
|
99
|
+
* @property {string} 9000 - Azure Storage
|
|
100
|
+
* @property {string} 10255 - Kubernetes
|
|
101
|
+
*/
|
|
21
102
|
export declare const defaultAzurePorts: string[];
|
package/helpers/azureEnv.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module azureEnv
|
|
4
|
+
* @description Module for handling Azure environment configuration and settings
|
|
5
|
+
*/
|
|
2
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
7
|
if (k2 === undefined) k2 = k;
|
|
4
8
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -38,6 +42,10 @@ const azure_native_1 = require("@pulumi/azure-native");
|
|
|
38
42
|
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
39
43
|
const Location_1 = require("./Location");
|
|
40
44
|
const stackEnv_1 = require("./stackEnv");
|
|
45
|
+
/**
|
|
46
|
+
* @enum {string}
|
|
47
|
+
* @description Enumeration of supported Azure deployment environments
|
|
48
|
+
*/
|
|
41
49
|
var Environments;
|
|
42
50
|
(function (Environments) {
|
|
43
51
|
Environments["Global"] = "global";
|
|
@@ -45,21 +53,84 @@ var Environments;
|
|
|
45
53
|
Environments["Sandbox"] = "sandbox";
|
|
46
54
|
Environments["Prd"] = "prd";
|
|
47
55
|
})(Environments || (exports.Environments = Environments = {}));
|
|
56
|
+
/**
|
|
57
|
+
* @constant {Object} azEnv
|
|
58
|
+
* @description Parsed Pulumi configuration from environment variables
|
|
59
|
+
*/
|
|
48
60
|
const azEnv = JSON.parse(process.env.PULUMI_CONFIG ?? '{}');
|
|
61
|
+
/**
|
|
62
|
+
* @constant {Output} config
|
|
63
|
+
* @description Azure client configuration output
|
|
64
|
+
*/
|
|
49
65
|
const config = azure_native_1.authorization.getClientConfigOutput();
|
|
66
|
+
/**
|
|
67
|
+
* @constant {Output<string>} tenantId
|
|
68
|
+
* @description Azure tenant ID from config or client config
|
|
69
|
+
*/
|
|
50
70
|
exports.tenantId = azEnv['azure-native:config:tenantId'] ?? config.tenantId;
|
|
71
|
+
/**
|
|
72
|
+
* @constant {Output<string>} subscriptionId
|
|
73
|
+
* @description Azure subscription ID from config or client config
|
|
74
|
+
*/
|
|
51
75
|
exports.subscriptionId = azEnv['azure-native:config:subscriptionId'] ?? config.subscriptionId;
|
|
76
|
+
/**
|
|
77
|
+
* @constant {Output<string>} currentPrincipal
|
|
78
|
+
* @description Current Azure principal object ID
|
|
79
|
+
*/
|
|
52
80
|
exports.currentPrincipal = config.objectId;
|
|
81
|
+
/**
|
|
82
|
+
* @constant {string} currentRegionName
|
|
83
|
+
* @description Current Azure region name, defaults to 'SoutheastAsia'
|
|
84
|
+
*/
|
|
53
85
|
exports.currentRegionName = (azEnv['azure-native:config:location'] ?? 'SoutheastAsia');
|
|
86
|
+
/**
|
|
87
|
+
* @constant {string} currentRegionCode
|
|
88
|
+
* @description Region code derived from current region name
|
|
89
|
+
*/
|
|
54
90
|
exports.currentRegionCode = (0, Location_1.getRegionCode)(exports.currentRegionName);
|
|
91
|
+
/**
|
|
92
|
+
* @constant {string} currentCountryCode
|
|
93
|
+
* @description Country code derived from current region name
|
|
94
|
+
*/
|
|
55
95
|
exports.currentCountryCode = (0, Location_1.getCountryCode)(exports.currentRegionName);
|
|
96
|
+
/**
|
|
97
|
+
* @constant {Output<string>} defaultSubScope
|
|
98
|
+
* @description Default subscription scope string
|
|
99
|
+
*/
|
|
56
100
|
exports.defaultSubScope = pulumi.interpolate `/subscriptions/${exports.subscriptionId}`;
|
|
101
|
+
/**
|
|
102
|
+
* @function isEnv
|
|
103
|
+
* @description Checks if current stack includes specified environment
|
|
104
|
+
* @param {Environments} env - Environment to check
|
|
105
|
+
* @returns {boolean} True if stack includes the environment
|
|
106
|
+
*/
|
|
57
107
|
const isEnv = (env) => stackEnv_1.stack.includes(env);
|
|
58
108
|
exports.isEnv = isEnv;
|
|
109
|
+
/**
|
|
110
|
+
* @constant {boolean} isDev
|
|
111
|
+
* @description Indicates if current environment is Development
|
|
112
|
+
*/
|
|
59
113
|
exports.isDev = (0, exports.isEnv)(Environments.Dev);
|
|
114
|
+
/**
|
|
115
|
+
* @constant {boolean} isSandbox
|
|
116
|
+
* @description Indicates if current environment is Sandbox
|
|
117
|
+
*/
|
|
60
118
|
exports.isSandbox = (0, exports.isEnv)(Environments.Sandbox);
|
|
119
|
+
/**
|
|
120
|
+
* @constant {boolean} isPrd
|
|
121
|
+
* @description Indicates if current environment is Production
|
|
122
|
+
*/
|
|
61
123
|
exports.isPrd = (0, exports.isEnv)(Environments.Prd);
|
|
124
|
+
/**
|
|
125
|
+
* @constant {boolean} isGlobal
|
|
126
|
+
* @description Indicates if current environment is Global
|
|
127
|
+
*/
|
|
62
128
|
exports.isGlobal = (0, exports.isEnv)(Environments.Global);
|
|
129
|
+
/**
|
|
130
|
+
* @function getCurrentEnv
|
|
131
|
+
* @description Determines current environment based on environment flags
|
|
132
|
+
* @returns {Environments} Current environment enum value
|
|
133
|
+
*/
|
|
63
134
|
function getCurrentEnv() {
|
|
64
135
|
if (exports.isGlobal)
|
|
65
136
|
return Environments.Global;
|
|
@@ -69,6 +140,10 @@ function getCurrentEnv() {
|
|
|
69
140
|
return Environments.Sandbox;
|
|
70
141
|
return Environments.Dev;
|
|
71
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* @constant {Environments} currentEnv
|
|
145
|
+
* @description Current environment value
|
|
146
|
+
*/
|
|
72
147
|
exports.currentEnv = getCurrentEnv();
|
|
73
148
|
//Print and Check
|
|
74
149
|
pulumi.all([exports.subscriptionId, exports.tenantId, exports.currentPrincipal]).apply(([s, t, p]) => {
|
|
@@ -82,6 +157,25 @@ pulumi.all([exports.subscriptionId, exports.tenantId, exports.currentPrincipal])
|
|
|
82
157
|
currentEnv: exports.currentEnv,
|
|
83
158
|
});
|
|
84
159
|
});
|
|
160
|
+
/**
|
|
161
|
+
* @constant {string[]} defaultAzurePorts
|
|
162
|
+
* @description List of default Azure ports commonly used in network security rules
|
|
163
|
+
* @property {string} 22 - SSH
|
|
164
|
+
* @property {string} 443 - HTTPS
|
|
165
|
+
* @property {string} 445 - SMB
|
|
166
|
+
* @property {string} 1433 - MSSQL
|
|
167
|
+
* @property {string} 1194 - OpenVPN
|
|
168
|
+
* @property {string} 3306 - MySQL
|
|
169
|
+
* @property {string} 3389 - RDP
|
|
170
|
+
* @property {string} 5432 - PostgreSQL
|
|
171
|
+
* @property {string} 5671 - AMQP with TLS
|
|
172
|
+
* @property {string} 5672 - AMQP
|
|
173
|
+
* @property {string} 6379 - Redis
|
|
174
|
+
* @property {string} 6380 - Redis with TLS
|
|
175
|
+
* @property {string} 8883 - MQTT
|
|
176
|
+
* @property {string} 9000 - Azure Storage
|
|
177
|
+
* @property {string} 10255 - Kubernetes
|
|
178
|
+
*/
|
|
85
179
|
exports.defaultAzurePorts = [
|
|
86
180
|
'22',
|
|
87
181
|
'443',
|
|
@@ -99,4 +193,4 @@ exports.defaultAzurePorts = [
|
|
|
99
193
|
'9000',
|
|
100
194
|
'10255',
|
|
101
195
|
];
|
|
102
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
196
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp1cmVFbnYuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaGVscGVycy9henVyZUVudi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7OztHQUdHOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFSCx1REFBcUQ7QUFDckQsdURBQXlDO0FBQ3pDLHlDQUEyRDtBQUMzRCx5Q0FBbUM7QUFFbkM7OztHQUdHO0FBQ0gsSUFBWSxZQUtYO0FBTEQsV0FBWSxZQUFZO0lBQ3RCLGlDQUFpQixDQUFBO0lBQ2pCLDJCQUFXLENBQUE7SUFDWCxtQ0FBbUIsQ0FBQTtJQUNuQiwyQkFBVyxDQUFBO0FBQ2IsQ0FBQyxFQUxXLFlBQVksNEJBQVosWUFBWSxRQUt2QjtBQUVEOzs7R0FHRztBQUNILE1BQU0sS0FBSyxHQUFHLElBQUksQ0FBQyxL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Qix5QkFBaUI7UUFDakIsaUJBQWlCLEVBQWpCLHlCQUFpQjtRQUNqQixrQkFBa0IsRUFBbEIsMEJBQWtCO1FBQ2xCLFVBQVUsRUFBVixrQkFBVTtLQUNYLENBQUMsQ0FBQztBQUNMLENBQUMsQ0FBQyxDQUFDO0FBRUg7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQWtCRztBQUNVLFFBQUEsaUJBQWlCLEdBQUc7SUFDL0IsSUFBSTtJQUNKLEtBQUs7SUFDTCxLQUFLO0lBQ0wsTUFBTTtJQUNOLE1BQU07SUFDTixNQUFNO0lBQ04sTUFBTTtJQUNOLE1BQU07SUFDTixNQUFNO0lBQ04sTUFBTTtJQUNOLE1BQU07SUFDTixNQUFNO0lBQ04sTUFBTTtJQUNOLE1BQU07SUFDTixPQUFPO0NBQ1IsQ0FBQyJ9
|
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
import * as pulumi from '@pulumi/pulumi';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves a configuration value by name.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} name - The name of the configuration value to retrieve
|
|
6
|
+
* @returns {string | undefined} The configuration value if found, undefined otherwise
|
|
7
|
+
* @description This function attempts to get a configuration value from Pulumi's configuration system.
|
|
8
|
+
* If the configuration value doesn't exist, it returns undefined instead of throwing an error.
|
|
9
|
+
* @example
|
|
10
|
+
* const dbHost = getValue('database-host');
|
|
11
|
+
* if (dbHost) {
|
|
12
|
+
* // use dbHost
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
2
15
|
export declare function getValue(name: string): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a required configuration value by name.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} name - The name of the required configuration value to retrieve
|
|
20
|
+
* @returns {string} The configuration value
|
|
21
|
+
* @throws {Error} If the configuration value is not found
|
|
22
|
+
* @description This function retrieves a configuration value that must exist.
|
|
23
|
+
* If the configuration value doesn't exist, it throws an error instead of returning undefined.
|
|
24
|
+
* @example
|
|
25
|
+
* const requiredApiKey = requireValue('api-key');
|
|
26
|
+
* // requiredApiKey is guaranteed to have a value
|
|
27
|
+
*/
|
|
3
28
|
export declare function requireValue(name: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves a secret configuration value by name.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} name - The name of the secret configuration value to retrieve
|
|
33
|
+
* @returns {pulumi.Output<string> | undefined} The secret configuration value if found, undefined otherwise
|
|
34
|
+
* @description This function attempts to get a secret configuration value from Pulumi's configuration system.
|
|
35
|
+
* The returned value is wrapped in a Pulumi.Output to ensure secure handling of sensitive data.
|
|
36
|
+
* If the secret doesn't exist, it returns undefined instead of throwing an error.
|
|
37
|
+
* @example
|
|
38
|
+
* const dbPassword = getSecret('database-password');
|
|
39
|
+
* if (dbPassword) {
|
|
40
|
+
* // use dbPassword securely
|
|
41
|
+
* }
|
|
42
|
+
*/
|
|
4
43
|
export declare function getSecret(name: string): pulumi.Output<string> | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves a required secret configuration value by name.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} name - The name of the required secret configuration value to retrieve
|
|
48
|
+
* @returns {pulumi.Output<string>} The secret configuration value
|
|
49
|
+
* @throws {Error} If the secret configuration value is not found
|
|
50
|
+
* @description This function retrieves a secret configuration value that must exist.
|
|
51
|
+
* The returned value is wrapped in a Pulumi.Output to ensure secure handling of sensitive data.
|
|
52
|
+
* If the secret doesn't exist, it throws an error instead of returning undefined.
|
|
53
|
+
* @example
|
|
54
|
+
* const requiredDbPassword = requireSecret('database-password');
|
|
55
|
+
* // requiredDbPassword is guaranteed to have a value
|
|
56
|
+
*/
|
|
5
57
|
export declare function requireSecret(name: string): pulumi.Output<string>;
|
package/helpers/configHelper.js
CHANGED
|
@@ -39,16 +39,68 @@ exports.getSecret = getSecret;
|
|
|
39
39
|
exports.requireSecret = requireSecret;
|
|
40
40
|
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
41
41
|
const config = new pulumi.Config();
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves a configuration value by name.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} name - The name of the configuration value to retrieve
|
|
46
|
+
* @returns {string | undefined} The configuration value if found, undefined otherwise
|
|
47
|
+
* @description This function attempts to get a configuration value from Pulumi's configuration system.
|
|
48
|
+
* If the configuration value doesn't exist, it returns undefined instead of throwing an error.
|
|
49
|
+
* @example
|
|
50
|
+
* const dbHost = getValue('database-host');
|
|
51
|
+
* if (dbHost) {
|
|
52
|
+
* // use dbHost
|
|
53
|
+
* }
|
|
54
|
+
*/
|
|
42
55
|
function getValue(name) {
|
|
43
56
|
return config.get(name);
|
|
44
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves a required configuration value by name.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} name - The name of the required configuration value to retrieve
|
|
62
|
+
* @returns {string} The configuration value
|
|
63
|
+
* @throws {Error} If the configuration value is not found
|
|
64
|
+
* @description This function retrieves a configuration value that must exist.
|
|
65
|
+
* If the configuration value doesn't exist, it throws an error instead of returning undefined.
|
|
66
|
+
* @example
|
|
67
|
+
* const requiredApiKey = requireValue('api-key');
|
|
68
|
+
* // requiredApiKey is guaranteed to have a value
|
|
69
|
+
*/
|
|
45
70
|
function requireValue(name) {
|
|
46
71
|
return config.require(name);
|
|
47
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Retrieves a secret configuration value by name.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} name - The name of the secret configuration value to retrieve
|
|
77
|
+
* @returns {pulumi.Output<string> | undefined} The secret configuration value if found, undefined otherwise
|
|
78
|
+
* @description This function attempts to get a secret configuration value from Pulumi's configuration system.
|
|
79
|
+
* The returned value is wrapped in a Pulumi.Output to ensure secure handling of sensitive data.
|
|
80
|
+
* If the secret doesn't exist, it returns undefined instead of throwing an error.
|
|
81
|
+
* @example
|
|
82
|
+
* const dbPassword = getSecret('database-password');
|
|
83
|
+
* if (dbPassword) {
|
|
84
|
+
* // use dbPassword securely
|
|
85
|
+
* }
|
|
86
|
+
*/
|
|
48
87
|
function getSecret(name) {
|
|
49
88
|
return config.getSecret(name);
|
|
50
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves a required secret configuration value by name.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} name - The name of the required secret configuration value to retrieve
|
|
94
|
+
* @returns {pulumi.Output<string>} The secret configuration value
|
|
95
|
+
* @throws {Error} If the secret configuration value is not found
|
|
96
|
+
* @description This function retrieves a secret configuration value that must exist.
|
|
97
|
+
* The returned value is wrapped in a Pulumi.Output to ensure secure handling of sensitive data.
|
|
98
|
+
* If the secret doesn't exist, it throws an error instead of returning undefined.
|
|
99
|
+
* @example
|
|
100
|
+
* const requiredDbPassword = requireSecret('database-password');
|
|
101
|
+
* // requiredDbPassword is guaranteed to have a value
|
|
102
|
+
*/
|
|
51
103
|
function requireSecret(name) {
|
|
52
104
|
return config.requireSecret(name);
|
|
53
105
|
}
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
106
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnSGVscGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2hlbHBlcnMvY29uZmlnSGVscGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBaUJBLDRCQUVDO0FBY0Qsb0NBRUM7QUFnQkQsOEJBRUM7QUFlRCxzQ0FFQztBQXRFRCx1REFBeUM7QUFFekMsTUFBTSxNQUFNLEdBQUcsSUFBSSxNQUFNLENBQUMsTUFBTSxFQUFFLENBQUM7QUFFbkM7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsU0FBZ0IsUUFBUSxDQUFDLElBQVk7SUFDbkMsT0FBTyxNQUFNLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQzFCLENBQUM7QUFFRDs7Ozs7Ozs7Ozs7R0FXRztBQUNILFNBQWdCLFlBQVksQ0FBQyxJQUFZO0lBQ3ZDLE9BQU8sTUFBTSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUM5QixDQUFDO0FBRUQ7Ozs7Ozs7Ozs7Ozs7R0FhRztBQUNILFNBQWdCLFNBQVMsQ0FBQyxJQUFZO0lBQ3BDLE9BQU8sTUFBTSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUNoQyxDQUFDO0FBRUQ7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsU0FBZ0IsYUFBYSxDQUFDLElBQVk7SUFDeEMsT0FBTyxNQUFNLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQ3BDLENBQUMifQ==
|
package/helpers/rsHelpers.d.ts
CHANGED
|
@@ -1,15 +1,68 @@
|
|
|
1
1
|
import * as pulumi from '@pulumi/pulumi';
|
|
2
2
|
import * as types from '../types';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Removes leading and trailing dashes from a string and replaces multiple consecutive dashes with a single dash
|
|
5
|
+
* @param s - The input string to process
|
|
6
|
+
* @returns The string with leading/trailing dashes removed and multiple dashes replaced with single dash
|
|
7
|
+
* @example
|
|
8
|
+
* removeDashes("--test--") // returns "test"
|
|
9
|
+
* removeDashes("hello--world--test") // returns "hello-world-test"
|
|
10
|
+
*/
|
|
11
|
+
export declare function removeDashes(s: string): string;
|
|
12
|
+
export declare function getNameNormalize(name: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Gets a shortened name by removing organization, project name and stack information
|
|
15
|
+
* @param name - The full resource name
|
|
16
|
+
* @returns Shortened name with organization, project and stack info removed
|
|
17
|
+
* @example
|
|
18
|
+
* getShortName("org-project-stack-resource") // returns "resource"
|
|
19
|
+
*/
|
|
4
20
|
export declare function getShortName(name: string): string;
|
|
5
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Generates the full Azure resource group ID from resource group inputs
|
|
23
|
+
* @param rsGroup - The resource group input object containing the resource group name
|
|
24
|
+
* @returns A Pulumi interpolated string with the full resource group ID
|
|
25
|
+
* @example
|
|
26
|
+
* getRsGroupIdFrom({resourceGroupName: "my-rg"}) // returns "/subscriptions/sub-id/resourceGroups/my-rg"
|
|
27
|
+
*/
|
|
6
28
|
export declare const getRsGroupIdFrom: (rsGroup: types.ResourceGroupInputs) => pulumi.Output<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Extracts the resource name from a resource ID or domain
|
|
31
|
+
* @param resourceId - The resource identifier (can be a resource ID, domain, or plain string)
|
|
32
|
+
* @returns The extracted resource name
|
|
33
|
+
* @example
|
|
34
|
+
* getRsNameFromId("/subscriptions/sub-id/resourceGroups/rg/providers/Microsoft.Web/sites/my-site") // returns "my-site"
|
|
35
|
+
* getRsNameFromId("my-site.azurewebsites.net") // returns "my-site"
|
|
36
|
+
*/
|
|
7
37
|
export declare function getRsNameFromId(resourceId: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Converts a Pulumi Input string resource ID to an Output containing just the resource name
|
|
40
|
+
* @param resourceId - The Pulumi Input string containing the resource ID
|
|
41
|
+
* @returns A Pulumi Output containing the extracted resource name
|
|
42
|
+
*/
|
|
8
43
|
export declare function getRsNameFromIdOutput(resourceId: pulumi.Input<string>): pulumi.Output<string | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Parses an Azure resource ID string to extract resource information
|
|
46
|
+
* @param resourceId - The full Azure resource ID string
|
|
47
|
+
* @returns An object containing the resource name, ID, resource group, and subscription ID
|
|
48
|
+
* @example
|
|
49
|
+
* getRsInfoFromId("/subscriptions/sub123/resourceGroups/rg-name/providers/Microsoft.Web/sites/site-name")
|
|
50
|
+
* // returns {
|
|
51
|
+
* // resourceName: "site-name",
|
|
52
|
+
* // id: "/subscriptions/sub123/resourceGroups/rg-name/providers/Microsoft.Web/sites/site-name",
|
|
53
|
+
* // rsGroup: { resourceGroupName: "rg-name" },
|
|
54
|
+
* // subscriptionId: "sub123"
|
|
55
|
+
* // }
|
|
56
|
+
*/
|
|
9
57
|
export declare function getRsInfoFromId(resourceId: string): types.ResourceWithGroupType & {
|
|
10
58
|
id: string;
|
|
11
59
|
subscriptionId: string;
|
|
12
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Converts a Pulumi Input string resource ID to an Output containing parsed resource information
|
|
63
|
+
* @param resourceId - The Pulumi Input string containing the resource ID
|
|
64
|
+
* @returns A Pulumi Output containing the parsed resource information
|
|
65
|
+
*/
|
|
13
66
|
export declare function getRsInfoFromIdOutputs(resourceId: pulumi.Input<string>): pulumi.Output<types.ResourceType & {
|
|
14
67
|
rsGroup: types.ResourceGroupType;
|
|
15
68
|
} & {
|
package/helpers/rsHelpers.js
CHANGED
|
@@ -33,7 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getRsGroupIdFrom =
|
|
36
|
+
exports.getRsGroupIdFrom = void 0;
|
|
37
|
+
exports.removeDashes = removeDashes;
|
|
38
|
+
exports.getNameNormalize = getNameNormalize;
|
|
37
39
|
exports.getShortName = getShortName;
|
|
38
40
|
exports.getRsNameFromId = getRsNameFromId;
|
|
39
41
|
exports.getRsNameFromIdOutput = getRsNameFromIdOutput;
|
|
@@ -42,15 +44,51 @@ exports.getRsInfoFromIdOutputs = getRsInfoFromIdOutputs;
|
|
|
42
44
|
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
43
45
|
const azureEnv = __importStar(require("./azureEnv"));
|
|
44
46
|
const stackInfo = __importStar(require("./stackEnv"));
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Removes leading and trailing dashes from a string and replaces multiple consecutive dashes with a single dash
|
|
49
|
+
* @param s - The input string to process
|
|
50
|
+
* @returns The string with leading/trailing dashes removed and multiple dashes replaced with single dash
|
|
51
|
+
* @example
|
|
52
|
+
* removeDashes("--test--") // returns "test"
|
|
53
|
+
* removeDashes("hello--world--test") // returns "hello-world-test"
|
|
54
|
+
*/
|
|
55
|
+
function removeDashes(s) {
|
|
56
|
+
return s.replace(/^-+|-+$/g, '').replace(/-{2,}/g, '-');
|
|
57
|
+
}
|
|
58
|
+
function getNameNormalize(name) {
|
|
59
|
+
const n = name
|
|
60
|
+
.replace(/[^a-zA-Z0-9]/g, '-') // Replace any non-alphanumeric character with "-"
|
|
61
|
+
.toLowerCase(); // Convert the result to lowercase
|
|
62
|
+
return removeDashes(n);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets a shortened name by removing organization, project name and stack information
|
|
66
|
+
* @param name - The full resource name
|
|
67
|
+
* @returns Shortened name with organization, project and stack info removed
|
|
68
|
+
* @example
|
|
69
|
+
* getShortName("org-project-stack-resource") // returns "resource"
|
|
70
|
+
*/
|
|
47
71
|
function getShortName(name) {
|
|
48
72
|
const n = name.replace(stackInfo.organization, '').replace(stackInfo.projectName, '').replace(stackInfo.stack, '');
|
|
49
|
-
return (
|
|
73
|
+
return removeDashes(n);
|
|
50
74
|
}
|
|
51
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Generates the full Azure resource group ID from resource group inputs
|
|
77
|
+
* @param rsGroup - The resource group input object containing the resource group name
|
|
78
|
+
* @returns A Pulumi interpolated string with the full resource group ID
|
|
79
|
+
* @example
|
|
80
|
+
* getRsGroupIdFrom({resourceGroupName: "my-rg"}) // returns "/subscriptions/sub-id/resourceGroups/my-rg"
|
|
81
|
+
*/
|
|
52
82
|
const getRsGroupIdFrom = (rsGroup) => pulumi.interpolate `${azureEnv.defaultSubScope}/resourceGroups/${rsGroup.resourceGroupName}`;
|
|
53
83
|
exports.getRsGroupIdFrom = getRsGroupIdFrom;
|
|
84
|
+
/**
|
|
85
|
+
* Extracts the resource name from a resource ID or domain
|
|
86
|
+
* @param resourceId - The resource identifier (can be a resource ID, domain, or plain string)
|
|
87
|
+
* @returns The extracted resource name
|
|
88
|
+
* @example
|
|
89
|
+
* getRsNameFromId("/subscriptions/sub-id/resourceGroups/rg/providers/Microsoft.Web/sites/my-site") // returns "my-site"
|
|
90
|
+
* getRsNameFromId("my-site.azurewebsites.net") // returns "my-site"
|
|
91
|
+
*/
|
|
54
92
|
function getRsNameFromId(resourceId) {
|
|
55
93
|
resourceId = resourceId.trim();
|
|
56
94
|
//Resource ID
|
|
@@ -63,9 +101,27 @@ function getRsNameFromId(resourceId) {
|
|
|
63
101
|
//If not just get last 25 character
|
|
64
102
|
return resourceId.slice(-25);
|
|
65
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Converts a Pulumi Input string resource ID to an Output containing just the resource name
|
|
106
|
+
* @param resourceId - The Pulumi Input string containing the resource ID
|
|
107
|
+
* @returns A Pulumi Output containing the extracted resource name
|
|
108
|
+
*/
|
|
66
109
|
function getRsNameFromIdOutput(resourceId) {
|
|
67
110
|
return pulumi.output(resourceId).apply((id) => getRsNameFromId(id));
|
|
68
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Parses an Azure resource ID string to extract resource information
|
|
114
|
+
* @param resourceId - The full Azure resource ID string
|
|
115
|
+
* @returns An object containing the resource name, ID, resource group, and subscription ID
|
|
116
|
+
* @example
|
|
117
|
+
* getRsInfoFromId("/subscriptions/sub123/resourceGroups/rg-name/providers/Microsoft.Web/sites/site-name")
|
|
118
|
+
* // returns {
|
|
119
|
+
* // resourceName: "site-name",
|
|
120
|
+
* // id: "/subscriptions/sub123/resourceGroups/rg-name/providers/Microsoft.Web/sites/site-name",
|
|
121
|
+
* // rsGroup: { resourceGroupName: "rg-name" },
|
|
122
|
+
* // subscriptionId: "sub123"
|
|
123
|
+
* // }
|
|
124
|
+
*/
|
|
69
125
|
function getRsInfoFromId(resourceId) {
|
|
70
126
|
const details = resourceId.trim().split('/');
|
|
71
127
|
let name = '';
|
|
@@ -86,7 +142,12 @@ function getRsInfoFromId(resourceId) {
|
|
|
86
142
|
subscriptionId: subId ?? azureEnv.subscriptionId,
|
|
87
143
|
};
|
|
88
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Converts a Pulumi Input string resource ID to an Output containing parsed resource information
|
|
147
|
+
* @param resourceId - The Pulumi Input string containing the resource ID
|
|
148
|
+
* @returns A Pulumi Output containing the parsed resource information
|
|
149
|
+
*/
|
|
89
150
|
function getRsInfoFromIdOutputs(resourceId) {
|
|
90
151
|
return pulumi.output(resourceId).apply((id) => getRsInfoFromId(id));
|
|
91
152
|
}
|
|
92
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
153
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnNIZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2hlbHBlcnMvcnNIZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQWFBLG9DQUVDO0FBRUQsNENBS0M7QUFTRCxvQ0FHQztBQW9CRCwwQ0FVQztBQU9ELHNEQUVDO0FBZUQsMENBb0JDO0FBT0Qsd0RBRUM7QUFySEQsdURBQXlDO0FBRXpDLHFEQUF1QztBQUN2QyxzREFBd0M7QUFFeEM7Ozs7Ozs7R0FPRztBQUNILFNBQWdCLFlBQVksQ0FBQyxDQUFTO0lBQ3BDLE9BQU8sQ0FBQyxDQUFDLE9BQU8sQ0FBQyxVQUFVLEVBQUUsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLFFBQVEsRUFBRSxHQUFHLENBQUMsQ0FBQztBQUMxRCxDQUFDO0FBRUQsU0FBZ0IsZ0JBQWdCLENBQUMsSUFBWTtJQUMzQyxNQUFNL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yxHQUFHLENBQUMsQ0FBQyxDQUFDO1FBQ3JGLElBQUksS0FBSyxLQUFLLE9BQU8sQ0FBQyxNQUFNLEdBQUcsQ0FBQztZQUFFLElBQUksR0FBRyxDQUFDLENBQUM7SUFDN0MsQ0FBQyxDQUFDLENBQUM7SUFFSCxPQUFPO1FBQ0wsWUFBWSxFQUFFLElBQUk7UUFDbEIsRUFBRSxFQUFFLFVBQVU7UUFDZCxPQUFPLEVBQUUsRUFBRSxpQkFBaUIsRUFBRSxTQUFTLEVBQUU7UUFDekMsY0FBYyxFQUFFLEtBQUssSUFBSSxRQUFRLENBQUMsY0FBYztLQUNqRCxDQUFDO0FBQ0osQ0FBQztBQUVEOzs7O0dBSUc7QUFDSCxTQUFnQixzQkFBc0IsQ0FBQyxVQUFnQztJQUNyRSxPQUFPLE1BQU0sQ0FBQyxNQUFNLENBQUMsVUFBVSxDQUFDLENBQUMsS0FBSyxDQUFDLENBQUMsRUFBRSxFQUFFLEVBQUUsQ0FBQyxlQUFlLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztBQUN0RSxDQUFDIn0=
|
package/helpers/stackEnv.d.ts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
2
|
+
/**
|
|
3
|
+
* Indicates if Pulumi is running in dry-run mode
|
|
4
|
+
* @type {boolean}
|
|
5
|
+
*/
|
|
1
6
|
export declare const isDryRun: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The Pulumi organization name
|
|
9
|
+
* @type {string}
|
|
10
|
+
*/
|
|
2
11
|
export declare const organization: string;
|
|
12
|
+
/**
|
|
13
|
+
* The Pulumi project name. Falls back to the current project name in lowercase if not specified
|
|
14
|
+
* @type {string}
|
|
15
|
+
*/
|
|
3
16
|
export declare const projectName: string;
|
|
17
|
+
/**
|
|
18
|
+
* The Pulumi stack name. Falls back to the current stack name in lowercase if not specified
|
|
19
|
+
* @type {string}
|
|
20
|
+
*/
|
|
4
21
|
export declare const stack: string;
|
|
22
|
+
/**
|
|
23
|
+
* Gets stack outputs from a specified project
|
|
24
|
+
* @template TOutput - The type of the stack outputs
|
|
25
|
+
* @param {string} [name=projectName] - The name of the project to get outputs from. Defaults to current project
|
|
26
|
+
* @returns {pulumi.Output<TOutput>} The stack outputs
|
|
27
|
+
*/
|
|
28
|
+
export declare const getStackOutputs: <TOutput>(name?: string) => pulumi.Output<TOutput>;
|
package/helpers/stackEnv.js
CHANGED
|
@@ -33,13 +33,40 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.stack = exports.projectName = exports.organization = exports.isDryRun = void 0;
|
|
36
|
+
exports.getStackOutputs = exports.stack = exports.projectName = exports.organization = exports.isDryRun = void 0;
|
|
37
37
|
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
38
38
|
const autoTags_1 = require("./autoTags");
|
|
39
|
+
/**
|
|
40
|
+
* Indicates if Pulumi is running in dry-run mode
|
|
41
|
+
* @type {boolean}
|
|
42
|
+
*/
|
|
39
43
|
exports.isDryRun = Boolean(process.env.PULUMI_NODEJS_DRY_RUN);
|
|
44
|
+
/**
|
|
45
|
+
* The Pulumi organization name
|
|
46
|
+
* @type {string}
|
|
47
|
+
*/
|
|
40
48
|
exports.organization = process.env.PULUMI_NODEJS_ORGANIZATION;
|
|
49
|
+
/**
|
|
50
|
+
* The Pulumi project name. Falls back to the current project name in lowercase if not specified
|
|
51
|
+
* @type {string}
|
|
52
|
+
*/
|
|
41
53
|
exports.projectName = process.env.PULUMI_NODEJS_PROJECT ?? pulumi.getProject().toLowerCase();
|
|
54
|
+
/**
|
|
55
|
+
* The Pulumi stack name. Falls back to the current stack name in lowercase if not specified
|
|
56
|
+
* @type {string}
|
|
57
|
+
*/
|
|
42
58
|
exports.stack = process.env.PULUMI_NODEJS_STACK ?? pulumi.getStack().toLowerCase();
|
|
59
|
+
/**
|
|
60
|
+
* Gets stack outputs from a specified project
|
|
61
|
+
* @template TOutput - The type of the stack outputs
|
|
62
|
+
* @param {string} [name=projectName] - The name of the project to get outputs from. Defaults to current project
|
|
63
|
+
* @returns {pulumi.Output<TOutput>} The stack outputs
|
|
64
|
+
*/
|
|
65
|
+
const getStackOutputs = (name = exports.projectName) => {
|
|
66
|
+
const stackRef = new pulumi.StackReference(`${exports.organization}/${name}/${exports.stack}`);
|
|
67
|
+
return stackRef.outputs.apply((s) => s.default ?? s);
|
|
68
|
+
};
|
|
69
|
+
exports.getStackOutputs = getStackOutputs;
|
|
43
70
|
console.log('Pulumi Environments:', {
|
|
44
71
|
organization: exports.organization,
|
|
45
72
|
projectName: exports.projectName,
|
|
@@ -51,4 +78,4 @@ console.log('Pulumi Environments:', {
|
|
|
51
78
|
organization: exports.organization,
|
|
52
79
|
'pulumi-project': exports.projectName,
|
|
53
80
|
});
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
81
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhY2tFbnYuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaGVscGVycy9zdGFja0Vudi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSx1REFBeUM7QUFDekMseUNBQThDO0FBRTlDOzs7R0FHRztBQUNVLFFBQUEsUUFBUSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLHFCQUFxQixDQUFDLENBQUM7QUFFbkU7OztHQUdHO0FBQ1UsUUFBQSxZQUFZLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQywwQkFBMkIsQ0FBQztBQUVwRTs7O0dBR0c7QUFDVSxRQUFBLFdBQVcsR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFDLHFCQUFxQixJQUFJLE1BQU0sQ0FBQyxVQUFVLEVBQUUsQ0FBQyxXQUFXLEVBQUUsQ0FBQztBQUVsRzs7O0dBR0c7QUFDVSxRQUFBLEtBQUssR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFDLG1CQUFtQixJQUFJLE1BQU0sQ0FBQyxRQUFRLEVBQUUsQ0FBQyxXQUFXLEVBQUUsQ0FBQztBQUV4Rjs7Ozs7R0FLRztBQUNJLE1BQU0sZUFBZSxHQUFHLENBQVUsT0FBZSxtQkFBVyxFQUEwQixFQUFFO0lBQzdGLE1BQU0sUUFBUSxHQUFHLElBQUksTUFBTSxDQUFDLGNBQWMsQ0FBQyxHQUFHLG9CQUFZLElBQUksSUFBSSxJQUFJLGFBQUssRUFBRSxDQUFDLENBQUM7SUFDL0UsT0FBTyxRQUFRLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FBQyxDQUFDLE9BQU8sSUFBSSxDQUFDLENBQTJCLENBQUM7QUFDakYsQ0FBQyxDQUFDO0FBSFcsUUFBQSxlQUFlLG1CQUcxQjtBQUVGLE9BQU8sQ0FBQyxHQUFHLENBQUMsc0JBQXNCLEVBQUU7SUFDbEMsWUFBWSxFQUFaLG9CQUFZO0lBQ1osV0FBVyxFQUFYLG1CQUFXO0lBQ1gsS0FBSyxFQUFMLGFBQUs7SUFDTCxRQUFRLEVBQVIsZ0JBQVE7Q0FDVCxDQUFDLENBQUM7QUFFSCxJQUFBLDJCQUFnQixFQUFDO0lBQ2YsV0FBVyxFQUFFLGFBQUs7SUFDbEIsWUFBWSxFQUFFLG9CQUFZO0lBQzFCLGdCQUFnQixFQUFFLG1CQUFXO0NBQzlCLENBQUMsQ0FBQyJ9
|
package/package.json
CHANGED
package/vault/helpers.js
CHANGED
|
@@ -3,11 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getSecretName = getSecretName;
|
|
4
4
|
const helpers_1 = require("../helpers");
|
|
5
5
|
function getSecretName(name) {
|
|
6
|
-
const n = name
|
|
7
|
-
|
|
8
|
-
.replace(/\.|_|\s/g, '-') // Replace ".", "_", and spaces with "-"
|
|
9
|
-
.replace(/-+/g, '-') // Replace multiple dashes with a single dash
|
|
10
|
-
.toLowerCase(); // Convert the result to lowercase
|
|
11
|
-
return helpers_1.rsHelpers.removeLeadingAndTrailingDash(n);
|
|
6
|
+
const n = name.replace(new RegExp(helpers_1.stackInfo.stack, 'g'), ''); // Replace occurrences of "stack" variable with "-"
|
|
7
|
+
return helpers_1.rsHelpers.getNameNormalize(n);
|
|
12
8
|
}
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92YXVsdC9oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBRUEsc0NBSUM7QUFORCx3Q0FBa0Q7QUFFbEQsU0FBZ0IsYUFBYSxDQUFDLElBQVk7SUFDeEMsTUFBTSxDQUFDLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxJQUFJLE1BQU0sQ0FBQyxtQkFBUyxDQUFDLEtBQUssRUFBRSxHQUFHLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FBQyxDQUFDLG1EQUFtRDtJQUVqSCxPQUFPLG1CQUFTLENBQUMsZ0JBQWdCLENBQUMsQ0FBQyxDQUFDLENBQUM7QUFDdkMsQ0FBQyJ9
|