@gradientedge/cdk-utils 9.52.1 → 9.52.2
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.
|
@@ -2,6 +2,7 @@ import { IAspect } from 'cdktf';
|
|
|
2
2
|
import { IConstruct } from 'constructs';
|
|
3
3
|
export declare class TagsAddingAspect implements IAspect {
|
|
4
4
|
private tagsToAdd;
|
|
5
|
-
|
|
5
|
+
private tagsToIgnore;
|
|
6
|
+
constructor(tagsToAdd: Record<string, string>, tagsToIgnore?: string[]);
|
|
6
7
|
visit(node: IConstruct): void;
|
|
7
8
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TagsAddingAspect = void 0;
|
|
4
|
+
const cdktf_1 = require("cdktf");
|
|
4
5
|
const constants_1 = require("./constants");
|
|
5
6
|
function isTaggableConstruct(node) {
|
|
6
7
|
return 'tags' in node && 'tagsInput' in node;
|
|
7
8
|
}
|
|
8
9
|
class TagsAddingAspect {
|
|
9
10
|
tagsToAdd;
|
|
10
|
-
|
|
11
|
+
tagsToIgnore;
|
|
12
|
+
constructor(tagsToAdd, tagsToIgnore = []) {
|
|
11
13
|
this.tagsToAdd = tagsToAdd;
|
|
14
|
+
this.tagsToIgnore = tagsToIgnore;
|
|
12
15
|
}
|
|
13
16
|
// This method is called on every Construct within the specified scope (resources, data sources, etc.).
|
|
14
17
|
visit(node) {
|
|
@@ -23,6 +26,11 @@ class TagsAddingAspect {
|
|
|
23
26
|
}
|
|
24
27
|
const currentTags = node.tagsInput || {};
|
|
25
28
|
node.tags = { ...this.tagsToAdd, ...currentTags };
|
|
29
|
+
// Add ignore_changes overrides for selected tags
|
|
30
|
+
if (node instanceof cdktf_1.TerraformResource && this.tagsToIgnore.length > 0) {
|
|
31
|
+
const ignoreList = this.tagsToIgnore.map(tag => `tags["${tag}"]`);
|
|
32
|
+
node.addOverride('lifecycle.ignore_changes', ignoreList);
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
36
|
exports.TagsAddingAspect = TagsAddingAspect;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAspect } from 'cdktf'
|
|
1
|
+
import { IAspect, TerraformResource } from 'cdktf'
|
|
2
2
|
import { IConstruct } from 'constructs'
|
|
3
3
|
import { RESOURCES_TO_EXCLUDE_TAGS } from './constants'
|
|
4
4
|
|
|
@@ -12,7 +12,10 @@ function isTaggableConstruct(node: IConstruct): node is TaggableConstruct {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export class TagsAddingAspect implements IAspect {
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(
|
|
16
|
+
private tagsToAdd: Record<string, string>,
|
|
17
|
+
private tagsToIgnore: string[] = []
|
|
18
|
+
) {}
|
|
16
19
|
|
|
17
20
|
// This method is called on every Construct within the specified scope (resources, data sources, etc.).
|
|
18
21
|
visit(node: IConstruct) {
|
|
@@ -29,5 +32,11 @@ export class TagsAddingAspect implements IAspect {
|
|
|
29
32
|
|
|
30
33
|
const currentTags = node.tagsInput || {}
|
|
31
34
|
node.tags = { ...this.tagsToAdd, ...currentTags }
|
|
35
|
+
|
|
36
|
+
// Add ignore_changes overrides for selected tags
|
|
37
|
+
if (node instanceof TerraformResource && this.tagsToIgnore.length > 0) {
|
|
38
|
+
const ignoreList = this.tagsToIgnore.map(tag => `tags["${tag}"]`)
|
|
39
|
+
node.addOverride('lifecycle.ignore_changes', ignoreList)
|
|
40
|
+
}
|
|
32
41
|
}
|
|
33
42
|
}
|