@gradientedge/cdk-utils 9.51.0 → 9.52.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.
- package/dist/src/lib/azure/services/function/main.js +17 -1
- package/dist/src/lib/cloudflare/construct/pages-static-site/main.d.ts +9 -0
- package/dist/src/lib/cloudflare/construct/pages-static-site/main.js +25 -0
- package/package.json +1 -1
- package/src/lib/azure/services/function/main.ts +17 -1
- package/src/lib/cloudflare/construct/pages-static-site/main.ts +33 -0
|
@@ -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
|
}
|
|
@@ -64,6 +64,15 @@ export declare class CloudflarePagesStaticSite extends CommonCloudflareConstruct
|
|
|
64
64
|
* @returns the secret value
|
|
65
65
|
*/
|
|
66
66
|
protected resolveSecretFromAWS(secretName: string, secretKey: string): any;
|
|
67
|
+
/**
|
|
68
|
+
* @summary Resolve secrets from Azure Key Vault
|
|
69
|
+
*
|
|
70
|
+
* @param resourceGroupName the resource group name where the key vault is located
|
|
71
|
+
* @param keyVaultName the key vault name
|
|
72
|
+
* @param secretKey the secret key
|
|
73
|
+
* @returns the secret value
|
|
74
|
+
*/
|
|
75
|
+
protected resolveSecretFromAzure(resourceGroupName: string, keyVaultName: string, secretKey: string): string;
|
|
67
76
|
/**
|
|
68
77
|
* @summary Create the pages project
|
|
69
78
|
*/
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CloudflarePagesStaticSite = void 0;
|
|
4
4
|
const data_aws_secretsmanager_secret_1 = require("@cdktf/provider-aws/lib/data-aws-secretsmanager-secret");
|
|
5
5
|
const data_aws_secretsmanager_secret_version_1 = require("@cdktf/provider-aws/lib/data-aws-secretsmanager-secret-version");
|
|
6
|
+
const data_azurerm_key_vault_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-key-vault");
|
|
7
|
+
const data_azurerm_key_vault_secret_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-key-vault-secret");
|
|
6
8
|
const cdktf_1 = require("cdktf");
|
|
7
9
|
const common_1 = require("../../common");
|
|
8
10
|
/**
|
|
@@ -109,6 +111,29 @@ class CloudflarePagesStaticSite extends common_1.CommonCloudflareConstruct {
|
|
|
109
111
|
throw new Error(`Unable to resolve secret:${secretName}`);
|
|
110
112
|
return cdktf_1.Fn.lookup(cdktf_1.Fn.jsondecode(secretVersion.secretString), secretKey);
|
|
111
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* @summary Resolve secrets from Azure Key Vault
|
|
116
|
+
*
|
|
117
|
+
* @param resourceGroupName the resource group name where the key vault is located
|
|
118
|
+
* @param keyVaultName the key vault name
|
|
119
|
+
* @param secretKey the secret key
|
|
120
|
+
* @returns the secret value
|
|
121
|
+
*/
|
|
122
|
+
resolveSecretFromAzure(resourceGroupName, keyVaultName, secretKey) {
|
|
123
|
+
const keyVaultData = new data_azurerm_key_vault_1.DataAzurermKeyVault(this, `${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-vault`, {
|
|
124
|
+
resourceGroupName: resourceGroupName,
|
|
125
|
+
name: keyVaultName,
|
|
126
|
+
provider: this.azurermProvider,
|
|
127
|
+
});
|
|
128
|
+
const secretValueData = new data_azurerm_key_vault_secret_1.DataAzurermKeyVaultSecret(this, `${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-secret`, {
|
|
129
|
+
name: secretKey,
|
|
130
|
+
keyVaultId: keyVaultData.id,
|
|
131
|
+
provider: this.azurermProvider,
|
|
132
|
+
});
|
|
133
|
+
if (!secretValueData)
|
|
134
|
+
throw new Error(`Unable to resolve secret:${secretKey}`);
|
|
135
|
+
return secretValueData.value;
|
|
136
|
+
}
|
|
112
137
|
/**
|
|
113
138
|
* @summary Create the pages project
|
|
114
139
|
*/
|
package/package.json
CHANGED
|
@@ -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
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DataAwsSecretsmanagerSecret } from '@cdktf/provider-aws/lib/data-aws-secretsmanager-secret'
|
|
2
2
|
import { DataAwsSecretsmanagerSecretVersion } from '@cdktf/provider-aws/lib/data-aws-secretsmanager-secret-version'
|
|
3
|
+
import { DataAzurermKeyVault } from '@cdktf/provider-azurerm/lib/data-azurerm-key-vault'
|
|
4
|
+
import { DataAzurermKeyVaultSecret } from '@cdktf/provider-azurerm/lib/data-azurerm-key-vault-secret'
|
|
3
5
|
import { DataCloudflareZone } from '@cdktf/provider-cloudflare/lib/data-cloudflare-zone'
|
|
4
6
|
import { PagesDomain } from '@cdktf/provider-cloudflare/lib/pages-domain'
|
|
5
7
|
import { PagesProject } from '@cdktf/provider-cloudflare/lib/pages-project'
|
|
@@ -120,6 +122,37 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
|
|
|
120
122
|
return Fn.lookup(Fn.jsondecode(secretVersion.secretString), secretKey)
|
|
121
123
|
}
|
|
122
124
|
|
|
125
|
+
/**
|
|
126
|
+
* @summary Resolve secrets from Azure Key Vault
|
|
127
|
+
*
|
|
128
|
+
* @param resourceGroupName the resource group name where the key vault is located
|
|
129
|
+
* @param keyVaultName the key vault name
|
|
130
|
+
* @param secretKey the secret key
|
|
131
|
+
* @returns the secret value
|
|
132
|
+
*/
|
|
133
|
+
protected resolveSecretFromAzure(resourceGroupName: string, keyVaultName: string, secretKey: string) {
|
|
134
|
+
const keyVaultData = new DataAzurermKeyVault(
|
|
135
|
+
this,
|
|
136
|
+
`${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-vault`,
|
|
137
|
+
{
|
|
138
|
+
resourceGroupName: resourceGroupName,
|
|
139
|
+
name: keyVaultName,
|
|
140
|
+
provider: this.azurermProvider,
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
const secretValueData = new DataAzurermKeyVaultSecret(
|
|
144
|
+
this,
|
|
145
|
+
`${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-secret`,
|
|
146
|
+
{
|
|
147
|
+
name: secretKey,
|
|
148
|
+
keyVaultId: keyVaultData.id,
|
|
149
|
+
provider: this.azurermProvider,
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
if (!secretValueData) throw new Error(`Unable to resolve secret:${secretKey}`)
|
|
153
|
+
return secretValueData.value
|
|
154
|
+
}
|
|
155
|
+
|
|
123
156
|
/**
|
|
124
157
|
* @summary Create the pages project
|
|
125
158
|
*/
|