@gradientedge/cdk-utils 9.52.0 → 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;
|
|
@@ -114,11 +114,27 @@ class AzureFunctionManager {
|
|
|
114
114
|
},
|
|
115
115
|
});
|
|
116
116
|
new cdktf_local_exec_1.Provider(scope, `${id}-local-exec-provider`);
|
|
117
|
+
// Deploy function app zip package with up to 3 retry attempts.
|
|
118
|
+
// This handles transient issues like HTTP 503s returned from the Azure Kudu deployment endpoint.
|
|
117
119
|
new cdktf_local_exec_1.LocalExec(scope, `${id}-function-app-deploy`, {
|
|
118
120
|
triggers: {
|
|
119
121
|
hash: props.sourceCodeHash,
|
|
120
122
|
},
|
|
121
|
-
command: `
|
|
123
|
+
command: `
|
|
124
|
+
set -e
|
|
125
|
+
MAX_RETRIES=3
|
|
126
|
+
RETRY_COUNT=0
|
|
127
|
+
until az functionapp deployment source config-zip --resource-group "${resourceGroup.name}" --name "${functionApp.name}" --src "${props.deploySource}"; do
|
|
128
|
+
RETRY_COUNT=$((RETRY_COUNT+1))
|
|
129
|
+
echo "Deployment attempt $RETRY_COUNT failed. Retrying in 10 seconds..."
|
|
130
|
+
if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
|
|
131
|
+
echo "Deployment failed after $MAX_RETRIES attempts."
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
sleep 10
|
|
135
|
+
done
|
|
136
|
+
echo "Deployment succeeded."
|
|
137
|
+
`,
|
|
122
138
|
});
|
|
123
139
|
return functionApp;
|
|
124
140
|
}
|
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
|
}
|
|
@@ -127,11 +127,27 @@ export class AzureFunctionManager {
|
|
|
127
127
|
})
|
|
128
128
|
|
|
129
129
|
new Provider(scope, `${id}-local-exec-provider`)
|
|
130
|
+
// Deploy function app zip package with up to 3 retry attempts.
|
|
131
|
+
// This handles transient issues like HTTP 503s returned from the Azure Kudu deployment endpoint.
|
|
130
132
|
new LocalExec(scope, `${id}-function-app-deploy`, {
|
|
131
133
|
triggers: {
|
|
132
134
|
hash: props.sourceCodeHash,
|
|
133
135
|
},
|
|
134
|
-
command: `
|
|
136
|
+
command: `
|
|
137
|
+
set -e
|
|
138
|
+
MAX_RETRIES=3
|
|
139
|
+
RETRY_COUNT=0
|
|
140
|
+
until az functionapp deployment source config-zip --resource-group "${resourceGroup.name}" --name "${functionApp.name}" --src "${props.deploySource}"; do
|
|
141
|
+
RETRY_COUNT=$((RETRY_COUNT+1))
|
|
142
|
+
echo "Deployment attempt $RETRY_COUNT failed. Retrying in 10 seconds..."
|
|
143
|
+
if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
|
|
144
|
+
echo "Deployment failed after $MAX_RETRIES attempts."
|
|
145
|
+
exit 1
|
|
146
|
+
fi
|
|
147
|
+
sleep 10
|
|
148
|
+
done
|
|
149
|
+
echo "Deployment succeeded."
|
|
150
|
+
`,
|
|
135
151
|
})
|
|
136
152
|
|
|
137
153
|
return functionApp
|