@gradientedge/cdk-utils 9.53.2 → 9.55.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/lib/azure/common/stack.js +1 -1
- package/dist/src/lib/azure/services/function/main.js +25 -14
- package/dist/src/lib/azure/services/function/types.d.ts +5 -0
- package/dist/src/lib/cloudflare/common/stack.js +1 -1
- package/package.json +1 -1
- package/src/lib/azure/common/stack.ts +1 -1
- package/src/lib/azure/services/function/main.ts +27 -14
- package/src/lib/azure/services/function/types.ts +6 -0
- package/src/lib/cloudflare/common/stack.ts +1 -1
|
@@ -95,7 +95,7 @@ class CommonAzureStack extends cdktf_1.TerraformStack {
|
|
|
95
95
|
* - Primary use is to have layered config for each environment which is injected into the context
|
|
96
96
|
*/
|
|
97
97
|
determineStageContexts() {
|
|
98
|
-
const stage = this.node.tryGetContext('stage');
|
|
98
|
+
const stage = process.env.STAGE ?? this.node.tryGetContext('stage');
|
|
99
99
|
const stageContextPath = this.node.tryGetContext('stageContextPath') || 'cdkEnv';
|
|
100
100
|
const stageContextFilePath = path_1.default.join(app_root_path_1.default.path, stageContextPath, `${stage}.json`);
|
|
101
101
|
const debug = this.node.tryGetContext('debug');
|
|
@@ -114,6 +114,17 @@ class AzureFunctionManager {
|
|
|
114
114
|
},
|
|
115
115
|
});
|
|
116
116
|
new cdktf_local_exec_1.Provider(scope, `${id}-local-exec-provider`);
|
|
117
|
+
// Temporary workaround until https://github.com/hashicorp/terraform-provider-azurerm/pull/29023 is made available
|
|
118
|
+
new cdktf_local_exec_1.LocalExec(scope, `${id}-function-app-always-ready`, {
|
|
119
|
+
triggers: {
|
|
120
|
+
hash: props.sourceCodeHash,
|
|
121
|
+
alwaysReadyConfigName: props.alwaysReadyConfig[0].name,
|
|
122
|
+
alwaysReadyConfigInstanceCount: props.alwaysReadyConfig[0].instanceCount.toString(),
|
|
123
|
+
},
|
|
124
|
+
command: `
|
|
125
|
+
az functionapp scale config always-ready set --name "${functionApp.name}" --resource-group "${resourceGroup.name}" --settings "${props.alwaysReadyConfig[0].name}"="${props.alwaysReadyConfig[0].instanceCount}"
|
|
126
|
+
`,
|
|
127
|
+
});
|
|
117
128
|
// Deploy function app zip package with up to 3 retry attempts.
|
|
118
129
|
// This handles transient issues like HTTP 503s returned from the Azure Kudu deployment endpoint.
|
|
119
130
|
new cdktf_local_exec_1.LocalExec(scope, `${id}-function-app-deploy`, {
|
|
@@ -121,20 +132,20 @@ class AzureFunctionManager {
|
|
|
121
132
|
hash: props.sourceCodeHash,
|
|
122
133
|
},
|
|
123
134
|
command: `
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
set -e
|
|
136
|
+
MAX_RETRIES=3
|
|
137
|
+
RETRY_COUNT=0
|
|
138
|
+
until az functionapp deployment source config-zip --resource-group "${resourceGroup.name}" --name "${functionApp.name}" --src "${props.deploySource}"; do
|
|
139
|
+
RETRY_COUNT=$((RETRY_COUNT+1))
|
|
140
|
+
echo "Deployment attempt $RETRY_COUNT failed. Retrying in 10 seconds..."
|
|
141
|
+
if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
|
|
142
|
+
echo "Deployment failed after $MAX_RETRIES attempts."
|
|
143
|
+
exit 1
|
|
144
|
+
fi
|
|
145
|
+
sleep 10
|
|
146
|
+
done
|
|
147
|
+
echo "Deployment succeeded."
|
|
148
|
+
`,
|
|
138
149
|
});
|
|
139
150
|
return functionApp;
|
|
140
151
|
}
|
|
@@ -8,4 +8,9 @@ export interface FunctionProps extends FunctionAppFunctionConfig {
|
|
|
8
8
|
export interface FunctionAppFlexConsumptionProps extends FunctionAppFlexConsumptionConfig {
|
|
9
9
|
sourceCodeHash: string;
|
|
10
10
|
deploySource: string;
|
|
11
|
+
alwaysReadyConfig: AlwaysReadyConfigProps[];
|
|
12
|
+
}
|
|
13
|
+
export interface AlwaysReadyConfigProps {
|
|
14
|
+
name: string;
|
|
15
|
+
instanceCount: number;
|
|
11
16
|
}
|
|
@@ -88,7 +88,7 @@ class CommonCloudflareStack extends cdktf_1.TerraformStack {
|
|
|
88
88
|
* - Primary use is to have layered config for each environment which is injected into the context
|
|
89
89
|
*/
|
|
90
90
|
determineStageContexts() {
|
|
91
|
-
const stage = this.node.tryGetContext('stage');
|
|
91
|
+
const stage = process.env.STAGE ?? this.node.tryGetContext('stage');
|
|
92
92
|
const stageContextPath = this.node.tryGetContext('stageContextPath') || 'cdkEnv';
|
|
93
93
|
const stageContextFilePath = path_1.default.join(app_root_path_1.default.path, stageContextPath, `${stage}.json`);
|
|
94
94
|
const debug = this.node.tryGetContext('debug');
|
package/package.json
CHANGED
|
@@ -104,7 +104,7 @@ export class CommonAzureStack extends TerraformStack {
|
|
|
104
104
|
* - Primary use is to have layered config for each environment which is injected into the context
|
|
105
105
|
*/
|
|
106
106
|
protected determineStageContexts() {
|
|
107
|
-
const stage = this.node.tryGetContext('stage')
|
|
107
|
+
const stage = process.env.STAGE ?? this.node.tryGetContext('stage')
|
|
108
108
|
const stageContextPath = this.node.tryGetContext('stageContextPath') || 'cdkEnv'
|
|
109
109
|
const stageContextFilePath = path.join(appRoot.path, stageContextPath, `${stage}.json`)
|
|
110
110
|
const debug = this.node.tryGetContext('debug')
|
|
@@ -127,6 +127,19 @@ export class AzureFunctionManager {
|
|
|
127
127
|
})
|
|
128
128
|
|
|
129
129
|
new Provider(scope, `${id}-local-exec-provider`)
|
|
130
|
+
|
|
131
|
+
// Temporary workaround until https://github.com/hashicorp/terraform-provider-azurerm/pull/29023 is made available
|
|
132
|
+
new LocalExec(scope, `${id}-function-app-always-ready`, {
|
|
133
|
+
triggers: {
|
|
134
|
+
hash: props.sourceCodeHash,
|
|
135
|
+
alwaysReadyConfigName: props.alwaysReadyConfig[0].name,
|
|
136
|
+
alwaysReadyConfigInstanceCount: props.alwaysReadyConfig[0].instanceCount.toString(),
|
|
137
|
+
},
|
|
138
|
+
command: `
|
|
139
|
+
az functionapp scale config always-ready set --name "${functionApp.name}" --resource-group "${resourceGroup.name}" --settings "${props.alwaysReadyConfig[0].name}"="${props.alwaysReadyConfig[0].instanceCount}"
|
|
140
|
+
`,
|
|
141
|
+
})
|
|
142
|
+
|
|
130
143
|
// Deploy function app zip package with up to 3 retry attempts.
|
|
131
144
|
// This handles transient issues like HTTP 503s returned from the Azure Kudu deployment endpoint.
|
|
132
145
|
new LocalExec(scope, `${id}-function-app-deploy`, {
|
|
@@ -134,20 +147,20 @@ export class AzureFunctionManager {
|
|
|
134
147
|
hash: props.sourceCodeHash,
|
|
135
148
|
},
|
|
136
149
|
command: `
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
set -e
|
|
151
|
+
MAX_RETRIES=3
|
|
152
|
+
RETRY_COUNT=0
|
|
153
|
+
until az functionapp deployment source config-zip --resource-group "${resourceGroup.name}" --name "${functionApp.name}" --src "${props.deploySource}"; do
|
|
154
|
+
RETRY_COUNT=$((RETRY_COUNT+1))
|
|
155
|
+
echo "Deployment attempt $RETRY_COUNT failed. Retrying in 10 seconds..."
|
|
156
|
+
if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
|
|
157
|
+
echo "Deployment failed after $MAX_RETRIES attempts."
|
|
158
|
+
exit 1
|
|
159
|
+
fi
|
|
160
|
+
sleep 10
|
|
161
|
+
done
|
|
162
|
+
echo "Deployment succeeded."
|
|
163
|
+
`,
|
|
151
164
|
})
|
|
152
165
|
|
|
153
166
|
return functionApp
|
|
@@ -9,4 +9,10 @@ export interface FunctionProps extends FunctionAppFunctionConfig {}
|
|
|
9
9
|
export interface FunctionAppFlexConsumptionProps extends FunctionAppFlexConsumptionConfig {
|
|
10
10
|
sourceCodeHash: string
|
|
11
11
|
deploySource: string
|
|
12
|
+
alwaysReadyConfig: AlwaysReadyConfigProps[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AlwaysReadyConfigProps {
|
|
16
|
+
name: string
|
|
17
|
+
instanceCount: number
|
|
12
18
|
}
|
|
@@ -97,7 +97,7 @@ export class CommonCloudflareStack extends TerraformStack {
|
|
|
97
97
|
* - Primary use is to have layered config for each environment which is injected into the context
|
|
98
98
|
*/
|
|
99
99
|
protected determineStageContexts() {
|
|
100
|
-
const stage = this.node.tryGetContext('stage')
|
|
100
|
+
const stage = process.env.STAGE ?? this.node.tryGetContext('stage')
|
|
101
101
|
const stageContextPath = this.node.tryGetContext('stageContextPath') || 'cdkEnv'
|
|
102
102
|
const stageContextFilePath = path.join(appRoot.path, stageContextPath, `${stage}.json`)
|
|
103
103
|
const debug = this.node.tryGetContext('debug')
|