@gradientedge/cdk-utils 9.54.0 → 9.55.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.
@@ -114,6 +114,22 @@ 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
+ alwaysReadyConfig: props.alwaysReadyConfig !== undefined
121
+ ? `${props.alwaysReadyConfig[0].name.toString()}:${props.alwaysReadyConfig[0].instanceCount.toString()}`
122
+ : 'undefined',
123
+ },
124
+ command: `
125
+ ALWAYS_READY_CONFIG="${props.alwaysReadyConfig !== undefined ? props.alwaysReadyConfig.toString() : 'undefined'}"
126
+ if [ "$ALWAYS_READY_CONFIG" == "undefined" ]; then
127
+ az functionapp scale config always-ready delete --name "${functionApp.name}" --resource-group "${resourceGroup.name}" --setting-names "http"
128
+ else
129
+ az functionapp scale config always-ready set --name "${functionApp.name}" --resource-group "${resourceGroup.name}" --settings "${props.alwaysReadyConfig === undefined ? '' : props.alwaysReadyConfig[0].name}"="${props.alwaysReadyConfig === undefined ? '' : props.alwaysReadyConfig[0].instanceCount}"
130
+ fi
131
+ `,
132
+ });
117
133
  // Deploy function app zip package with up to 3 retry attempts.
118
134
  // This handles transient issues like HTTP 503s returned from the Azure Kudu deployment endpoint.
119
135
  new cdktf_local_exec_1.LocalExec(scope, `${id}-function-app-deploy`, {
@@ -121,20 +137,20 @@ class AzureFunctionManager {
121
137
  hash: props.sourceCodeHash,
122
138
  },
123
139
  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
- `,
140
+ set -e
141
+ MAX_RETRIES=3
142
+ RETRY_COUNT=0
143
+ until az functionapp deployment source config-zip --resource-group "${resourceGroup.name}" --name "${functionApp.name}" --src "${props.deploySource}"; do
144
+ RETRY_COUNT=$((RETRY_COUNT+1))
145
+ echo "Deployment attempt $RETRY_COUNT failed. Retrying in 10 seconds..."
146
+ if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
147
+ echo "Deployment failed after $MAX_RETRIES attempts."
148
+ exit 1
149
+ fi
150
+ sleep 10
151
+ done
152
+ echo "Deployment succeeded."
153
+ `,
138
154
  });
139
155
  return functionApp;
140
156
  }
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.54.0",
3
+ "version": "9.55.1",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -127,6 +127,25 @@ 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
+ alwaysReadyConfig:
135
+ props.alwaysReadyConfig !== undefined
136
+ ? `${props.alwaysReadyConfig[0].name.toString()}:${props.alwaysReadyConfig[0].instanceCount.toString()}`
137
+ : 'undefined',
138
+ },
139
+ command: `
140
+ ALWAYS_READY_CONFIG="${props.alwaysReadyConfig !== undefined ? props.alwaysReadyConfig.toString() : 'undefined'}"
141
+ if [ "$ALWAYS_READY_CONFIG" == "undefined" ]; then
142
+ az functionapp scale config always-ready delete --name "${functionApp.name}" --resource-group "${resourceGroup.name}" --setting-names "http"
143
+ else
144
+ az functionapp scale config always-ready set --name "${functionApp.name}" --resource-group "${resourceGroup.name}" --settings "${props.alwaysReadyConfig === undefined ? '' : props.alwaysReadyConfig[0].name}"="${props.alwaysReadyConfig === undefined ? '' : props.alwaysReadyConfig[0].instanceCount}"
145
+ fi
146
+ `,
147
+ })
148
+
130
149
  // Deploy function app zip package with up to 3 retry attempts.
131
150
  // This handles transient issues like HTTP 503s returned from the Azure Kudu deployment endpoint.
132
151
  new LocalExec(scope, `${id}-function-app-deploy`, {
@@ -134,20 +153,20 @@ export class AzureFunctionManager {
134
153
  hash: props.sourceCodeHash,
135
154
  },
136
155
  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
- `,
156
+ set -e
157
+ MAX_RETRIES=3
158
+ RETRY_COUNT=0
159
+ until az functionapp deployment source config-zip --resource-group "${resourceGroup.name}" --name "${functionApp.name}" --src "${props.deploySource}"; do
160
+ RETRY_COUNT=$((RETRY_COUNT+1))
161
+ echo "Deployment attempt $RETRY_COUNT failed. Retrying in 10 seconds..."
162
+ if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
163
+ echo "Deployment failed after $MAX_RETRIES attempts."
164
+ exit 1
165
+ fi
166
+ sleep 10
167
+ done
168
+ echo "Deployment succeeded."
169
+ `,
151
170
  })
152
171
 
153
172
  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
  }