@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.
@@ -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
- 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
- `,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.53.2",
3
+ "version": "9.55.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -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
- 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
- `,
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')