@gradientedge/cdk-utils 10.7.0 → 10.8.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/app/api-destined-function/src/lib/lambda.d.ts +1 -0
- package/dist/app/api-destined-function/src/lib/lambda.d.ts.map +1 -0
- package/dist/app/api-destined-function/src/lib/lambda.js +1 -0
- package/dist/app/api-destined-function/src/lib/lambda.js.map +1 -0
- package/dist/app/api-destined-function/tsconfig.tsbuildinfo +1 -0
- package/dist/src/lib/aws/services/cloudwatch/main.d.ts +11 -11
- package/dist/src/lib/azure/common/constants.d.ts +74 -0
- package/dist/src/lib/azure/common/constants.js +77 -0
- package/dist/src/lib/azure/common/construct.d.ts +15 -3
- package/dist/src/lib/azure/common/construct.js +39 -3
- package/dist/src/lib/azure/common/stack.d.ts +3 -2
- package/dist/src/lib/azure/common/stack.js +25 -42
- package/dist/src/lib/azure/common/types.d.ts +13 -2
- package/dist/src/lib/azure/construct/event-handler/index.d.ts +2 -0
- package/dist/src/lib/azure/construct/event-handler/index.js +2 -0
- package/dist/src/lib/azure/construct/event-handler/main.d.ts +20 -0
- package/dist/src/lib/azure/construct/event-handler/main.js +139 -0
- package/dist/src/lib/azure/construct/event-handler/types.d.ts +35 -0
- package/dist/src/lib/azure/construct/event-handler/types.js +1 -0
- package/dist/src/lib/azure/construct/function-app/index.d.ts +2 -0
- package/dist/src/lib/azure/construct/function-app/index.js +2 -0
- package/dist/src/lib/azure/construct/function-app/main.d.ts +51 -0
- package/dist/src/lib/azure/construct/function-app/main.js +297 -0
- package/dist/src/lib/azure/construct/function-app/types.d.ts +33 -0
- package/dist/src/lib/azure/construct/function-app/types.js +1 -0
- package/dist/src/lib/azure/construct/index.d.ts +6 -0
- package/dist/src/lib/azure/construct/index.js +6 -0
- package/dist/src/lib/azure/construct/rest-api/index.d.ts +2 -0
- package/dist/src/lib/azure/construct/rest-api/index.js +2 -0
- package/dist/src/lib/azure/construct/rest-api/main.d.ts +20 -0
- package/dist/src/lib/azure/construct/rest-api/main.js +172 -0
- package/dist/src/lib/azure/construct/rest-api/types.d.ts +25 -0
- package/dist/src/lib/azure/construct/rest-api/types.js +1 -0
- package/dist/src/lib/azure/construct/rest-api-function/index.d.ts +2 -0
- package/dist/src/lib/azure/construct/rest-api-function/index.js +2 -0
- package/dist/src/lib/azure/construct/rest-api-function/main.d.ts +19 -0
- package/dist/src/lib/azure/construct/rest-api-function/main.js +255 -0
- package/dist/src/lib/azure/construct/rest-api-function/types.d.ts +29 -0
- package/dist/src/lib/azure/construct/rest-api-function/types.js +1 -0
- package/dist/src/lib/azure/construct/rest-api-with-cache/index.d.ts +2 -0
- package/dist/src/lib/azure/construct/rest-api-with-cache/index.js +2 -0
- package/dist/src/lib/azure/construct/rest-api-with-cache/main.d.ts +12 -0
- package/dist/src/lib/azure/construct/rest-api-with-cache/main.js +56 -0
- package/dist/src/lib/azure/construct/rest-api-with-cache/types.d.ts +13 -0
- package/dist/src/lib/azure/construct/rest-api-with-cache/types.js +1 -0
- package/dist/src/lib/azure/construct/site-with-webapp/index.d.ts +2 -0
- package/dist/src/lib/azure/construct/site-with-webapp/index.js +2 -0
- package/dist/src/lib/azure/construct/site-with-webapp/main.d.ts +19 -0
- package/dist/src/lib/azure/construct/site-with-webapp/main.js +135 -0
- package/dist/src/lib/azure/construct/site-with-webapp/types.d.ts +30 -0
- package/dist/src/lib/azure/construct/site-with-webapp/types.js +1 -0
- package/dist/src/lib/azure/index.d.ts +1 -0
- package/dist/src/lib/azure/index.js +1 -0
- package/dist/src/lib/azure/services/api-management/main.d.ts +83 -5
- package/dist/src/lib/azure/services/api-management/main.js +114 -148
- package/dist/src/lib/azure/services/api-management/types.d.ts +22 -1
- package/dist/src/lib/azure/services/app-configuration/main.d.ts +13 -1
- package/dist/src/lib/azure/services/app-configuration/main.js +21 -2
- package/dist/src/lib/azure/services/app-service/main.d.ts +5 -2
- package/dist/src/lib/azure/services/app-service/main.js +12 -4
- package/dist/src/lib/azure/services/application-insights/main.d.ts +15 -4
- package/dist/src/lib/azure/services/application-insights/main.js +27 -6
- package/dist/src/lib/azure/services/application-insights/types.d.ts +4 -1
- package/dist/src/lib/azure/services/authorisation/constants.d.ts +13 -0
- package/dist/src/lib/azure/services/authorisation/constants.js +14 -0
- package/dist/src/lib/azure/services/authorisation/index.d.ts +3 -0
- package/dist/src/lib/azure/services/authorisation/index.js +3 -0
- package/dist/src/lib/azure/services/authorisation/main.d.ts +84 -0
- package/dist/src/lib/azure/services/authorisation/main.js +120 -0
- package/dist/src/lib/azure/services/authorisation/types.d.ts +3 -0
- package/dist/src/lib/azure/services/authorisation/types.js +1 -0
- package/dist/src/lib/azure/services/cosmosdb/constants.d.ts +8 -0
- package/dist/src/lib/azure/services/cosmosdb/constants.js +10 -0
- package/dist/src/lib/azure/services/cosmosdb/index.d.ts +1 -0
- package/dist/src/lib/azure/services/cosmosdb/index.js +1 -0
- package/dist/src/lib/azure/services/cosmosdb/main.d.ts +47 -5
- package/dist/src/lib/azure/services/cosmosdb/main.js +77 -8
- package/dist/src/lib/azure/services/cosmosdb/types.d.ts +3 -1
- package/dist/src/lib/azure/services/dns/main.d.ts +9 -4
- package/dist/src/lib/azure/services/dns/main.js +12 -8
- package/dist/src/lib/azure/services/eventgrid/main.d.ts +12 -7
- package/dist/src/lib/azure/services/eventgrid/main.js +18 -19
- package/dist/src/lib/azure/services/function/main.d.ts +16 -3
- package/dist/src/lib/azure/services/function/main.js +122 -8
- package/dist/src/lib/azure/services/function/types.d.ts +3 -4
- package/dist/src/lib/azure/services/index.d.ts +3 -0
- package/dist/src/lib/azure/services/index.js +3 -0
- package/dist/src/lib/azure/services/key-vault/main.d.ts +22 -2
- package/dist/src/lib/azure/services/key-vault/main.js +28 -3
- package/dist/src/lib/azure/services/key-vault/types.d.ts +3 -2
- package/dist/src/lib/azure/services/monitor/main.d.ts +3 -1
- package/dist/src/lib/azure/services/monitor/main.js +3 -2
- package/dist/src/lib/azure/services/operational-insights/main.d.ts +13 -2
- package/dist/src/lib/azure/services/operational-insights/main.js +17 -3
- package/dist/src/lib/azure/services/operational-insights/types.d.ts +3 -1
- package/dist/src/lib/azure/services/portal/error.d.ts +5 -0
- package/dist/src/lib/azure/services/portal/error.js +10 -0
- package/dist/src/lib/azure/services/portal/index.d.ts +4 -0
- package/dist/src/lib/azure/services/portal/index.js +4 -0
- package/dist/src/lib/azure/services/portal/main.d.ts +33 -0
- package/dist/src/lib/azure/services/portal/main.js +51 -0
- package/dist/src/lib/azure/services/portal/renderer.d.ts +11 -0
- package/dist/src/lib/azure/services/portal/renderer.js +156 -0
- package/dist/src/lib/azure/services/portal/types.d.ts +40 -0
- package/dist/src/lib/azure/services/portal/types.js +1 -0
- package/dist/src/lib/azure/services/redis/main.d.ts +4 -2
- package/dist/src/lib/azure/services/redis/main.js +3 -2
- package/dist/src/lib/azure/services/redis/types.d.ts +1 -1
- package/dist/src/lib/azure/services/resource-group/main.d.ts +10 -1
- package/dist/src/lib/azure/services/resource-group/main.js +17 -3
- package/dist/src/lib/azure/services/security-center/index.d.ts +2 -0
- package/dist/src/lib/azure/services/security-center/index.js +2 -0
- package/dist/src/lib/azure/services/security-center/main.d.ts +31 -0
- package/dist/src/lib/azure/services/security-center/main.js +33 -0
- package/dist/src/lib/azure/services/security-center/types.d.ts +3 -0
- package/dist/src/lib/azure/services/security-center/types.js +1 -0
- package/dist/src/lib/azure/services/servicebus/main.d.ts +28 -22
- package/dist/src/lib/azure/services/servicebus/main.js +31 -26
- package/dist/src/lib/azure/services/servicebus/types.d.ts +4 -4
- package/dist/src/lib/azure/services/storage/main.d.ts +26 -5
- package/dist/src/lib/azure/services/storage/main.js +51 -9
- package/dist/src/lib/azure/services/storage/types.d.ts +7 -2
- package/dist/src/lib/cloudflare/common/stack.d.ts +2 -2
- package/dist/src/lib/cloudflare/common/stack.js +25 -25
- package/dist/src/lib/cloudflare/services/worker/main.js +8 -1
- package/dist/src/lib/cloudflare/services/worker/types.d.ts +1 -0
- package/package.json +26 -23
- package/src/lib/azure/common/constants.ts +83 -0
- package/src/lib/azure/common/construct.ts +49 -6
- package/src/lib/azure/common/stack.ts +26 -43
- package/src/lib/azure/common/types.ts +14 -2
- package/src/lib/azure/construct/event-handler/index.ts +2 -0
- package/src/lib/azure/construct/event-handler/main.ts +183 -0
- package/src/lib/azure/construct/event-handler/types.ts +49 -0
- package/src/lib/azure/construct/function-app/index.ts +2 -0
- package/src/lib/azure/construct/function-app/main.ts +410 -0
- package/src/lib/azure/construct/function-app/types.ts +45 -0
- package/src/lib/azure/construct/index.ts +6 -0
- package/src/lib/azure/construct/rest-api/index.ts +2 -0
- package/src/lib/azure/construct/rest-api/main.ts +205 -0
- package/src/lib/azure/construct/rest-api/types.ts +33 -0
- package/src/lib/azure/construct/rest-api-function/index.ts +2 -0
- package/src/lib/azure/construct/rest-api-function/main.ts +297 -0
- package/src/lib/azure/construct/rest-api-function/types.ts +39 -0
- package/src/lib/azure/construct/rest-api-with-cache/index.ts +2 -0
- package/src/lib/azure/construct/rest-api-with-cache/main.ts +75 -0
- package/src/lib/azure/construct/rest-api-with-cache/types.ts +15 -0
- package/src/lib/azure/construct/site-with-webapp/index.ts +2 -0
- package/src/lib/azure/construct/site-with-webapp/main.ts +160 -0
- package/src/lib/azure/construct/site-with-webapp/types.ts +33 -0
- package/src/lib/azure/index.ts +1 -0
- package/src/lib/azure/services/api-management/main.ts +168 -152
- package/src/lib/azure/services/api-management/types.ts +30 -1
- package/src/lib/azure/services/app-configuration/main.ts +29 -2
- package/src/lib/azure/services/app-service/main.ts +23 -4
- package/src/lib/azure/services/application-insights/main.ts +46 -7
- package/src/lib/azure/services/application-insights/types.ts +6 -2
- package/src/lib/azure/services/authorisation/constants.ts +13 -0
- package/src/lib/azure/services/authorisation/index.ts +3 -0
- package/src/lib/azure/services/authorisation/main.ts +202 -0
- package/src/lib/azure/services/authorisation/types.ts +3 -0
- package/src/lib/azure/services/cosmosdb/constants.ts +9 -0
- package/src/lib/azure/services/cosmosdb/index.ts +1 -0
- package/src/lib/azure/services/cosmosdb/main.ts +158 -8
- package/src/lib/azure/services/cosmosdb/types.ts +3 -0
- package/src/lib/azure/services/dns/main.ts +33 -8
- package/src/lib/azure/services/eventgrid/main.ts +41 -23
- package/src/lib/azure/services/function/main.ts +155 -9
- package/src/lib/azure/services/function/types.ts +3 -4
- package/src/lib/azure/services/index.ts +3 -0
- package/src/lib/azure/services/key-vault/main.ts +47 -4
- package/src/lib/azure/services/key-vault/types.ts +4 -4
- package/src/lib/azure/services/monitor/main.ts +5 -2
- package/src/lib/azure/services/operational-insights/main.ts +30 -4
- package/src/lib/azure/services/operational-insights/types.ts +3 -1
- package/src/lib/azure/services/portal/error.ts +12 -0
- package/src/lib/azure/services/portal/index.ts +4 -0
- package/src/lib/azure/services/portal/main.ts +81 -0
- package/src/lib/azure/services/portal/renderer.ts +182 -0
- package/src/lib/azure/services/portal/types.ts +45 -0
- package/src/lib/azure/services/redis/main.ts +10 -3
- package/src/lib/azure/services/redis/types.ts +1 -1
- package/src/lib/azure/services/resource-group/main.ts +34 -3
- package/src/lib/azure/services/security-center/index.ts +2 -0
- package/src/lib/azure/services/security-center/main.ts +42 -0
- package/src/lib/azure/services/security-center/types.ts +3 -0
- package/src/lib/azure/services/servicebus/main.ts +61 -30
- package/src/lib/azure/services/servicebus/types.ts +4 -4
- package/src/lib/azure/services/storage/main.ts +91 -9
- package/src/lib/azure/services/storage/types.ts +11 -2
- package/src/lib/cloudflare/common/stack.ts +25 -25
- package/src/lib/cloudflare/services/worker/main.ts +10 -1
- package/src/lib/cloudflare/services/worker/types.ts +8 -1
- package/dist/lib/lambda.d.ts +0 -17
- package/dist/lib/lambda.d.ts.map +0 -1
- package/dist/lib/lambda.js +0 -28
- package/dist/lib/lambda.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { HostnameType, LoggerType } from '@pulumi/azure-native/apimanagement/index.js';
|
|
2
|
+
import { getComponentOutput } from '@pulumi/azure-native/applicationinsights/index.js';
|
|
3
|
+
import { getVaultOutput } from '@pulumi/azure-native/keyvault/index.js';
|
|
4
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
5
|
+
import { CommonAzureConstruct } from '../../common/index.js';
|
|
6
|
+
import { RoleDefinitionId } from '../../services/index.js';
|
|
7
|
+
export class AzureRestApi extends CommonAzureConstruct {
|
|
8
|
+
props;
|
|
9
|
+
api;
|
|
10
|
+
applicationInsights;
|
|
11
|
+
constructor(id, props) {
|
|
12
|
+
super(id, props);
|
|
13
|
+
this.props = props;
|
|
14
|
+
this.id = id;
|
|
15
|
+
}
|
|
16
|
+
initResources() {
|
|
17
|
+
this.createResourceGroup();
|
|
18
|
+
this.resolveApiKeyVault();
|
|
19
|
+
this.resolveCommonLogAnalyticsWorkspace();
|
|
20
|
+
this.resolveApplicationInsights();
|
|
21
|
+
this.createApiManagement();
|
|
22
|
+
this.createNamespaceSecretRole();
|
|
23
|
+
this.createNamespaceSecret();
|
|
24
|
+
this.createSubscriptionKeySecret();
|
|
25
|
+
this.createApiManagementLogger();
|
|
26
|
+
this.createApiDiagnostic();
|
|
27
|
+
this.createDiagnosticLog();
|
|
28
|
+
}
|
|
29
|
+
resolveApiKeyVault() {
|
|
30
|
+
this.api.authKeyVault = getVaultOutput({
|
|
31
|
+
vaultName: this.props.apiAuthKeyVault.name,
|
|
32
|
+
resourceGroupName: this.props.apiAuthKeyVault.resourceGroupName,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
resolveApplicationInsights() {
|
|
36
|
+
if (!this.props.commonApplicationInsights || !this.props.commonApplicationInsights.resourceName)
|
|
37
|
+
return;
|
|
38
|
+
this.applicationInsights = getComponentOutput({
|
|
39
|
+
resourceName: this.props.commonApplicationInsights.resourceName,
|
|
40
|
+
resourceGroupName: this.props.commonApplicationInsights.resourceGroupName,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
createApiManagement() {
|
|
44
|
+
if (this.props.apiManagement.useExistingApiManagement) {
|
|
45
|
+
if (this.props.apiManagement.apiStackName) {
|
|
46
|
+
const apiStack = new pulumi.StackReference(this.props.apiManagement.apiStackName);
|
|
47
|
+
this.api.id = apiStack.getOutput('apiId');
|
|
48
|
+
this.api.name = apiStack.getOutput('apiName');
|
|
49
|
+
this.api.resourceGroupName = apiStack.getOutput('apiResourceGroupName');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
let hostnameConfigurations;
|
|
54
|
+
if (this.props.apiManagement.certificateKeyVaultId) {
|
|
55
|
+
hostnameConfigurations = [
|
|
56
|
+
{
|
|
57
|
+
hostName: `api-${this.props.locationConfig?.[this.props.location].name}.${this.props.domainName}`,
|
|
58
|
+
keyVaultId: this.props.apiManagement.certificateKeyVaultId,
|
|
59
|
+
type: HostnameType.Management,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
this.api.apim = this.apiManagementManager.createApiManagementService(this.id, this, {
|
|
64
|
+
...this.props.apiManagement,
|
|
65
|
+
serviceName: this.props.stackName,
|
|
66
|
+
location: this.resourceGroup.location,
|
|
67
|
+
resourceGroupName: this.resourceGroup.name,
|
|
68
|
+
hostnameConfigurations,
|
|
69
|
+
}, undefined, undefined, { protect: true });
|
|
70
|
+
this.api.id = this.api.apim.id;
|
|
71
|
+
this.api.name = this.api.apim.name;
|
|
72
|
+
this.api.resourceGroupName = this.resourceGroup.name;
|
|
73
|
+
if (this.props.apiManagement.certificateKeyVaultId) {
|
|
74
|
+
this.authorisationManager.createRoleAssignment(`${this.id}-kv-role`, this, {
|
|
75
|
+
principalId: this.api.apim.identity.apply(identity => identity?.principalId ?? ''),
|
|
76
|
+
roleDefinitionId: RoleDefinitionId.KEY_VAULT_CERTIFICATE_USER,
|
|
77
|
+
scope: this.props.apiManagement.certificateKeyVaultId,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.registerOutputs({
|
|
82
|
+
apiId: this.api.id,
|
|
83
|
+
apiName: this.api.name,
|
|
84
|
+
apiResourceGroupName: this.api.resourceGroupName,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
createNamespaceSecretRole() {
|
|
88
|
+
if (this.props.apiManagement.useExistingApiManagement)
|
|
89
|
+
return;
|
|
90
|
+
this.api.namedValueRoleAssignment = this.authorisationManager.createRoleAssignment(`${this.id}-key-vault-role-api-namespace`, this, {
|
|
91
|
+
principalId: this.api.apim.identity.apply(identity => identity?.principalId ?? ''),
|
|
92
|
+
roleDefinitionId: `/subscriptions/${this.props.subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/4633458b-17de-408a-b874-0445c86b69e6`,
|
|
93
|
+
scope: this.api.authKeyVault.id,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
createNamespaceSecret() {
|
|
97
|
+
if (this.props.apiManagement.useExistingApiManagement)
|
|
98
|
+
return;
|
|
99
|
+
this.api.namedValueSecret = this.keyVaultManager.createKeyVaultSecret(`${this.id}-key-vault-api-namespace-secret`, this, {
|
|
100
|
+
vaultName: this.api.authKeyVault.name,
|
|
101
|
+
secretName: `${this.applicationInsights.name}-${this.props.stackName}-key`,
|
|
102
|
+
resourceGroupName: this.resourceGroup.name,
|
|
103
|
+
properties: {
|
|
104
|
+
value: this.applicationInsights.instrumentationKey,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
createSubscriptionKeySecret() {
|
|
109
|
+
if (this.props.apiManagement.useExistingApiManagement)
|
|
110
|
+
return;
|
|
111
|
+
const apiManagementSubscription = this.apiManagementManager.createSubscription(this.id, this, {
|
|
112
|
+
serviceName: this.api.apim.name,
|
|
113
|
+
resourceGroupName: this.resourceGroup.name,
|
|
114
|
+
displayName: 'all-apis',
|
|
115
|
+
state: 'active',
|
|
116
|
+
allowTracing: false,
|
|
117
|
+
scope: '', // todo
|
|
118
|
+
});
|
|
119
|
+
this.keyVaultManager.createKeyVaultSecret(`${this.id}-key-vault-api-subscription-key-secret`, this, {
|
|
120
|
+
vaultName: this.api.authKeyVault.name,
|
|
121
|
+
secretName: `${this.props.stackName}-subscription-key`,
|
|
122
|
+
resourceGroupName: this.resourceGroup.name,
|
|
123
|
+
properties: {
|
|
124
|
+
value: apiManagementSubscription.primaryKey.apply(key => key ?? ''),
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
createApiManagementLogger() {
|
|
129
|
+
if (this.props.apiManagement.useExistingApiManagement)
|
|
130
|
+
return;
|
|
131
|
+
const apiAppNamedValue = this.apiManagementManager.createNamedValue(`${this.id}-am-nv`, this, {
|
|
132
|
+
displayName: this.applicationInsights.name,
|
|
133
|
+
resourceGroupName: this.resourceGroup.name,
|
|
134
|
+
serviceName: this.api.apim.name,
|
|
135
|
+
namedValueId: `${this.applicationInsights.name}-key`,
|
|
136
|
+
secret: true,
|
|
137
|
+
keyVault: {
|
|
138
|
+
secretIdentifier: this.api.namedValueSecret.id,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
this.api.logger = this.apiManagementManager.createLogger(`${this.id}-am-logger`, this, {
|
|
142
|
+
resourceGroupName: this.resourceGroup.name,
|
|
143
|
+
serviceName: this.api.apim.name,
|
|
144
|
+
resourceId: this.applicationInsights.id,
|
|
145
|
+
loggerType: LoggerType.ApplicationInsights,
|
|
146
|
+
credentials: {
|
|
147
|
+
instrumentationKey: `{{${apiAppNamedValue.displayName}}}`,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
createApiDiagnostic() {
|
|
152
|
+
if (this.props.apiManagement.useExistingApiManagement)
|
|
153
|
+
return;
|
|
154
|
+
this.apiManagementManager.createApiDiagnostic(`${this.id}-all-apis`, this, {
|
|
155
|
+
...this.props.apiManagementDiagnostic,
|
|
156
|
+
apiId: this.api.apim.id,
|
|
157
|
+
resourceGroupName: this.resourceGroup.name,
|
|
158
|
+
serviceName: this.api.apim.name,
|
|
159
|
+
loggerId: this.api.logger.id,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
createDiagnosticLog() {
|
|
163
|
+
if (this.props.apiManagement.useExistingApiManagement)
|
|
164
|
+
return;
|
|
165
|
+
this.monitorManager.createMonitorDiagnosticSettings(`${this.id}-apim-diagnostic`, this, {
|
|
166
|
+
...this.props.apiManagementDiagnosticSettings,
|
|
167
|
+
name: `${this.props.stackName}-api-management`,
|
|
168
|
+
resourceUri: this.api.apim.id,
|
|
169
|
+
workspaceId: this.commonLogAnalyticsWorkspace.id,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ApiManagementService, Logger } from '@pulumi/azure-native/apimanagement/index.js';
|
|
2
|
+
import { RoleAssignment } from '@pulumi/azure-native/authorization/index.js';
|
|
3
|
+
import { GetVaultResult, Secret } from '@pulumi/azure-native/keyvault/index.js';
|
|
4
|
+
import { Input, Output } from '@pulumi/pulumi';
|
|
5
|
+
import { ApiDiagnosticProps, ApiManagementProps, CommonAzureStackProps, MonitorDiagnosticSettingProps } from '../../index.js';
|
|
6
|
+
export interface ApiAuthKeyVault {
|
|
7
|
+
name: string;
|
|
8
|
+
resourceGroupName: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AzureRestApiProps extends CommonAzureStackProps {
|
|
11
|
+
apiAuthKeyVault: ApiAuthKeyVault;
|
|
12
|
+
apiManagement: ApiManagementProps;
|
|
13
|
+
apiManagementDiagnostic: ApiDiagnosticProps;
|
|
14
|
+
apiManagementDiagnosticSettings: MonitorDiagnosticSettingProps;
|
|
15
|
+
}
|
|
16
|
+
export interface AzureApi {
|
|
17
|
+
id: Input<string>;
|
|
18
|
+
name: Input<string>;
|
|
19
|
+
resourceGroupName: Input<string>;
|
|
20
|
+
authKeyVault: Output<GetVaultResult>;
|
|
21
|
+
apim: ApiManagementService;
|
|
22
|
+
namedValueSecret: Secret;
|
|
23
|
+
namedValueRoleAssignment: RoleAssignment;
|
|
24
|
+
logger: Logger;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ApiManagementApiOperationProps } from '../../services/index.js';
|
|
2
|
+
import { AzureFunctionApp } from '../function-app/index.js';
|
|
3
|
+
import { AzureApiFunction, AzureRestApiFunctionProps } from './types.js';
|
|
4
|
+
export declare class AzureRestApiFunction extends AzureFunctionApp {
|
|
5
|
+
props: AzureRestApiFunctionProps;
|
|
6
|
+
api: AzureApiFunction;
|
|
7
|
+
constructor(id: string, props: AzureRestApiFunctionProps);
|
|
8
|
+
initResources(): void;
|
|
9
|
+
protected resolveApiKeyVault(): void;
|
|
10
|
+
protected createNamespaceSecret(): void;
|
|
11
|
+
protected createApiManagement(): void;
|
|
12
|
+
protected createApiManagementNamespace(): void;
|
|
13
|
+
protected createApiManagementRoutes(): void;
|
|
14
|
+
protected createApiOperation(operation: ApiManagementApiOperationProps): void;
|
|
15
|
+
protected createApiOperationCachePolicy(operation: ApiManagementApiOperationProps): void;
|
|
16
|
+
protected createCorsPolicy(): void;
|
|
17
|
+
protected createApiPolicy(): void;
|
|
18
|
+
protected dashboardVariables(): Record<string, any>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { HostnameType, NamedValue } from '@pulumi/azure-native/apimanagement/index.js';
|
|
2
|
+
import { getVaultOutput } from '@pulumi/azure-native/keyvault/index.js';
|
|
3
|
+
import { listWebAppHostKeysOutput } from '@pulumi/azure-native/web/index.js';
|
|
4
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
import { RoleDefinitionId } from '../../services/index.js';
|
|
7
|
+
import { AzureFunctionApp } from '../function-app/index.js';
|
|
8
|
+
export class AzureRestApiFunction extends AzureFunctionApp {
|
|
9
|
+
props;
|
|
10
|
+
api;
|
|
11
|
+
constructor(id, props) {
|
|
12
|
+
super(id, props);
|
|
13
|
+
this.props = props;
|
|
14
|
+
this.id = id;
|
|
15
|
+
}
|
|
16
|
+
initResources() {
|
|
17
|
+
this.createResourceGroup();
|
|
18
|
+
this.resolveCommonLogAnalyticsWorkspace();
|
|
19
|
+
this.resolveApplicationInsights();
|
|
20
|
+
this.createAppServicePlan();
|
|
21
|
+
this.createdParsedAppConfigurations();
|
|
22
|
+
this.createAppConfiguration();
|
|
23
|
+
this.createAppConfigurations();
|
|
24
|
+
this.createStorageAccount();
|
|
25
|
+
this.createStorageDeploymentContainer();
|
|
26
|
+
this.createStorageContainer();
|
|
27
|
+
this.createDataStorageAccount();
|
|
28
|
+
this.createDataStorageContainer();
|
|
29
|
+
this.generateStorageContainerSas();
|
|
30
|
+
this.createFunctionHosts();
|
|
31
|
+
this.createCodePackage();
|
|
32
|
+
this.createFunctionAppSiteConfig();
|
|
33
|
+
this.createFunctionApp();
|
|
34
|
+
this.createRoleAssignments();
|
|
35
|
+
this.resolveApiKeyVault();
|
|
36
|
+
this.createNamespaceSecret();
|
|
37
|
+
this.createApiManagement();
|
|
38
|
+
this.createApiManagementNamespace();
|
|
39
|
+
this.createApiManagementRoutes();
|
|
40
|
+
this.createCorsPolicy();
|
|
41
|
+
this.createFunctionDashboard();
|
|
42
|
+
}
|
|
43
|
+
resolveApiKeyVault() {
|
|
44
|
+
this.api.authKeyVault = getVaultOutput({
|
|
45
|
+
vaultName: this.props.apiAuthKeyVault.name,
|
|
46
|
+
resourceGroupName: this.props.apiAuthKeyVault.resourceGroupName,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
createNamespaceSecret() {
|
|
50
|
+
if (!this.props.apiManagement.useExistingApiManagement)
|
|
51
|
+
return;
|
|
52
|
+
const functionDefaultKey = listWebAppHostKeysOutput({
|
|
53
|
+
name: this.app.name,
|
|
54
|
+
resourceGroupName: this.resourceGroup.name,
|
|
55
|
+
});
|
|
56
|
+
this.api.namedValueSecret = this.keyVaultManager.createKeyVaultSecret(`${this.id}-key-vault-api-namespace-secret`, this, {
|
|
57
|
+
vaultName: this.api.authKeyVault.name,
|
|
58
|
+
secretName: pulumi.interpolate `${this.app.name}key`,
|
|
59
|
+
resourceGroupName: this.resourceGroup.name,
|
|
60
|
+
properties: {
|
|
61
|
+
value: functionDefaultKey.functionKeys?.apply(keys => keys?.['default'] ?? ''),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
createApiManagement() {
|
|
66
|
+
if (this.props.apiManagement.useExistingApiManagement) {
|
|
67
|
+
if (this.props.apiManagement.apiStackName) {
|
|
68
|
+
const apiStack = new pulumi.StackReference(this.props.apiManagement.apiStackName);
|
|
69
|
+
this.api.id = apiStack.getOutput('apiId');
|
|
70
|
+
this.api.name = apiStack.getOutput('apiName');
|
|
71
|
+
this.api.resourceGroupName = apiStack.getOutput('apiResourceGroupName');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
let hostnameConfigurations;
|
|
76
|
+
if (this.props.apiManagement.certificateKeyVaultId) {
|
|
77
|
+
hostnameConfigurations = [
|
|
78
|
+
{
|
|
79
|
+
hostName: `api-${this.props.locationConfig?.[this.props.location].name}.${this.props.domainName}`,
|
|
80
|
+
keyVaultId: this.props.apiManagement.certificateKeyVaultId,
|
|
81
|
+
type: HostnameType.Management,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
this.api.apim = this.apiManagementManager.createApiManagementService(this.id, this, {
|
|
86
|
+
...this.props.apiManagement,
|
|
87
|
+
serviceName: this.props.stackName,
|
|
88
|
+
location: this.resourceGroup.location,
|
|
89
|
+
resourceGroupName: this.resourceGroup.name,
|
|
90
|
+
hostnameConfigurations,
|
|
91
|
+
}, undefined, undefined, { protect: true });
|
|
92
|
+
this.api.id = this.api.apim.id;
|
|
93
|
+
this.api.name = this.api.apim.name;
|
|
94
|
+
this.api.resourceGroupName = this.resourceGroup.name;
|
|
95
|
+
if (this.props.apiManagement.certificateKeyVaultId) {
|
|
96
|
+
this.authorisationManager.createRoleAssignment(`${this.id}-kv-role`, this, {
|
|
97
|
+
principalId: this.api.apim.identity.apply(identity => identity?.principalId ?? ''),
|
|
98
|
+
roleDefinitionId: RoleDefinitionId.KEY_VAULT_CERTIFICATE_USER,
|
|
99
|
+
scope: this.props.apiManagement.certificateKeyVaultId,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
createApiManagementNamespace() {
|
|
105
|
+
this.api.namedValue = new NamedValue(`${this.id}-am-nv`, {
|
|
106
|
+
displayName: this.app.name,
|
|
107
|
+
keyVault: {
|
|
108
|
+
secretIdentifier: this.api.namedValueSecret.id,
|
|
109
|
+
},
|
|
110
|
+
resourceGroupName: this.api.resourceGroupName,
|
|
111
|
+
secret: true,
|
|
112
|
+
serviceName: this.api.name,
|
|
113
|
+
});
|
|
114
|
+
this.api.backend = this.apiManagementManager.createBackend(this.id, this, {
|
|
115
|
+
...this.props.apiManagementBackend,
|
|
116
|
+
title: this.props.stackName,
|
|
117
|
+
resourceGroupName: this.api.resourceGroupName,
|
|
118
|
+
serviceName: this.api.name,
|
|
119
|
+
url: pulumi.interpolate `https://${this.app.name}.azurewebsites.net/${this.props.apiManagementBackend.backendUrlPath}`,
|
|
120
|
+
resourceId: pulumi.interpolate `https://management.azure.com/subscriptions/${this.props.subscriptionId}/resourceGroups/${this.resourceGroup.name}/providers/Microsoft.Web/sites/${this.app.name}`,
|
|
121
|
+
credentials: {
|
|
122
|
+
header: {
|
|
123
|
+
'x-functions-key': [`{{${this.api.namedValue.name}}}`],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
createApiManagementRoutes() {
|
|
129
|
+
this.api.managementApi = this.apiManagementManager.createApi(`${this.id}-apim-api`, this, {
|
|
130
|
+
...this.props.apiManagementApi,
|
|
131
|
+
displayName: this.props.apiManagementApi.displayName ?? this.props.stackName,
|
|
132
|
+
serviceName: this.api.name,
|
|
133
|
+
resourceGroupName: this.api.resourceGroupName,
|
|
134
|
+
isCurrent: this.props.apiManagementApi.isCurrent ?? true,
|
|
135
|
+
protocols: this.props.apiManagementApi.protocols ?? ['https'],
|
|
136
|
+
});
|
|
137
|
+
_.forEach(this.props.apiManagementApi.operations, operation => {
|
|
138
|
+
this.createApiOperation(operation);
|
|
139
|
+
this.createApiOperationCachePolicy(operation);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
createApiOperation(operation) {
|
|
143
|
+
this.api.apiOperations[operation.displayName.toString()] = this.apiManagementManager.createOperation(`${this.id}-apim-api-apim-api-operation-${operation.displayName}-${operation.method}`, this, {
|
|
144
|
+
operationId: `${operation.displayName}-${operation.method}`,
|
|
145
|
+
method: operation.method.toString().toUpperCase(),
|
|
146
|
+
serviceName: this.api.name,
|
|
147
|
+
resourceGroupName: this.api.resourceGroupName,
|
|
148
|
+
apiId: this.api.id,
|
|
149
|
+
displayName: operation.displayName,
|
|
150
|
+
urlTemplate: operation.urlTemplate,
|
|
151
|
+
templateParameters: operation.templateParameters,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
createApiOperationCachePolicy(operation) {
|
|
155
|
+
if (!operation.caching || !operation.caching.enableCacheSet)
|
|
156
|
+
return;
|
|
157
|
+
this.apiManagementManager.createOperationPolicy(`${this.id}-apim-api-operation-policy-${operation.displayName}-${operation.method}`, this, {
|
|
158
|
+
apiId: this.api.id,
|
|
159
|
+
resourceGroupName: this.api.resourceGroupName,
|
|
160
|
+
serviceName: this.api.name,
|
|
161
|
+
operationId: `${operation.displayName}-${operation.method}`,
|
|
162
|
+
value: `
|
|
163
|
+
<policies>
|
|
164
|
+
<policies>
|
|
165
|
+
<inbound>
|
|
166
|
+
<base />
|
|
167
|
+
${this.props.apiManagementApi.cacheSetInboundPolicy}
|
|
168
|
+
</inbound>
|
|
169
|
+
<backend>
|
|
170
|
+
<base />
|
|
171
|
+
</backend>
|
|
172
|
+
<outbound>
|
|
173
|
+
<base />
|
|
174
|
+
${this.props.apiManagementApi.cacheSetOutboundPolicy}
|
|
175
|
+
</outbound>
|
|
176
|
+
<on-error>
|
|
177
|
+
<base />
|
|
178
|
+
</on-error>
|
|
179
|
+
</policies>`.replace(/\n[ \t]*\n/g, '\n'), // move to utils
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
createCorsPolicy() {
|
|
183
|
+
if (!this.props.apiManagementCors?.enableCors)
|
|
184
|
+
return;
|
|
185
|
+
const allowedOrigins = [];
|
|
186
|
+
if (this.props.apiManagementCors.allowedOrigins) {
|
|
187
|
+
_.forEach(this.props.apiManagementCors.allowedOrigins, (origin) => {
|
|
188
|
+
allowedOrigins.push(`<origin>${origin}</origin>`);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else if (this.props.apiManagementCors.originSubdomain) {
|
|
192
|
+
_.forEach(this.props.locales, (locale) => {
|
|
193
|
+
allowedOrigins.push(`<origin>https://${this.props.apiManagementCors?.originSubdomain}-${locale}.${this.props.domainName}</origin>`);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const allowedHeaders = [];
|
|
197
|
+
_.forEach(this.props.apiManagementCors.allowedHeaders, (header) => {
|
|
198
|
+
allowedHeaders.push(`<header>${header}</header>`);
|
|
199
|
+
});
|
|
200
|
+
const allowedMethods = [];
|
|
201
|
+
_.forEach(this.props.apiManagementCors.allowedMethods, (method) => {
|
|
202
|
+
allowedMethods.push(`<method>${method}</method>`);
|
|
203
|
+
});
|
|
204
|
+
this.api.corsPolicyXmlContent = `
|
|
205
|
+
<cors allow-credentials="${this.props.apiManagementCors.allowCredentials}">
|
|
206
|
+
<allowed-origins>
|
|
207
|
+
${allowedOrigins.toString().replaceAll(',', '')}
|
|
208
|
+
</allowed-origins>
|
|
209
|
+
<allowed-methods>
|
|
210
|
+
${allowedMethods.toString().replaceAll(',', '')}
|
|
211
|
+
</allowed-methods>
|
|
212
|
+
<allowed-headers>
|
|
213
|
+
${allowedHeaders.toString().replaceAll(',', '')}
|
|
214
|
+
</allowed-headers>
|
|
215
|
+
</cors>`.replace(/\n[ \t]*\n/g, '\n'); // move to utils
|
|
216
|
+
}
|
|
217
|
+
createApiPolicy() {
|
|
218
|
+
const policyXmlContent = pulumi.interpolate `
|
|
219
|
+
<policies>
|
|
220
|
+
<inbound>
|
|
221
|
+
<base />
|
|
222
|
+
${this.api.corsPolicyXmlContent ?? ''}
|
|
223
|
+
<set-backend-service backend-id="${this.api.backend.name}" />
|
|
224
|
+
<set-header name="traceparent" exists-action="override">
|
|
225
|
+
<value>@(context.Request.Headers.GetValueOrDefault("traceparent", ""))</value>
|
|
226
|
+
</set-header>
|
|
227
|
+
</inbound>
|
|
228
|
+
<backend>
|
|
229
|
+
<base />
|
|
230
|
+
</backend>
|
|
231
|
+
<outbound>
|
|
232
|
+
<base />
|
|
233
|
+
<set-header name="traceparent" exists-action="override">
|
|
234
|
+
<value>@(context.Request.Headers.GetValueOrDefault("traceparent", ""))</value>
|
|
235
|
+
</set-header>
|
|
236
|
+
</outbound>
|
|
237
|
+
<on-error>
|
|
238
|
+
<base />
|
|
239
|
+
</on-error>
|
|
240
|
+
</policies>`;
|
|
241
|
+
this.apiManagementManager.createPolicy(`${this.id}-apim-api-policy`, this, {
|
|
242
|
+
serviceName: this.api.name,
|
|
243
|
+
apiId: this.api.id,
|
|
244
|
+
resourceGroupName: this.api.resourceGroupName,
|
|
245
|
+
value: policyXmlContent.apply(xml => xml.replace(/\n[ \t]*\n/g, '\n')),
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
dashboardVariables() {
|
|
249
|
+
const variables = super.dashboardVariables();
|
|
250
|
+
return {
|
|
251
|
+
...variables,
|
|
252
|
+
apimName: this.api.name,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Api, ApiOperation, Backend, NamedValue } from '@pulumi/azure-native/apimanagement/index.js';
|
|
2
|
+
import { ApiManagementApiProps, ApiManagementBackendProps, ApiManagementProps, ApplicationInsightsProps, AzureApi, AzureFunctionAppProps, AzureRestApiProps } from '../../index.js';
|
|
3
|
+
export interface ApiManagementRestApiProps extends ApiManagementProps {
|
|
4
|
+
useExistingApiManagement: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface ApiManagementCors {
|
|
7
|
+
enableCors: boolean;
|
|
8
|
+
allowCredentials: boolean;
|
|
9
|
+
allowedMethods: string[];
|
|
10
|
+
allowedHeaders: string[];
|
|
11
|
+
allowedOrigins?: string[];
|
|
12
|
+
originSubdomain?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AzureRestApiFunctionProps extends AzureRestApiProps, AzureFunctionAppProps {
|
|
15
|
+
apiManagementBackend: ApiManagementBackendProps;
|
|
16
|
+
apiManagementApi: ApiManagementApiProps;
|
|
17
|
+
apiManagementApplicationInsights?: ApplicationInsightsProps;
|
|
18
|
+
apiManagement: ApiManagementRestApiProps;
|
|
19
|
+
apiManagementCors?: ApiManagementCors;
|
|
20
|
+
}
|
|
21
|
+
export interface AzureApiFunction extends AzureApi {
|
|
22
|
+
corsPolicyXmlContent?: string;
|
|
23
|
+
apiOperations: {
|
|
24
|
+
[operation: string]: ApiOperation;
|
|
25
|
+
};
|
|
26
|
+
managementApi: Api;
|
|
27
|
+
backend: Backend;
|
|
28
|
+
namedValue: NamedValue;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AzureRestApi } from '../rest-api/main.js';
|
|
2
|
+
import { AzureApiWithCache, AzureRestApiWithCacheProps } from './types.js';
|
|
3
|
+
export declare class AzureRestApiWithCache extends AzureRestApi {
|
|
4
|
+
props: AzureRestApiWithCacheProps;
|
|
5
|
+
api: AzureApiWithCache;
|
|
6
|
+
constructor(id: string, props: AzureRestApiWithCacheProps);
|
|
7
|
+
initResources(): void;
|
|
8
|
+
protected createRedisCache(): void;
|
|
9
|
+
protected createRedisCacheSecret(): void;
|
|
10
|
+
protected createRedisCacheNamespace(): void;
|
|
11
|
+
protected createRedisCacheApiManagement(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AzureRestApi } from '../rest-api/main.js';
|
|
2
|
+
export class AzureRestApiWithCache extends AzureRestApi {
|
|
3
|
+
props;
|
|
4
|
+
constructor(id, props) {
|
|
5
|
+
super(id, props);
|
|
6
|
+
this.props = props;
|
|
7
|
+
this.id = id;
|
|
8
|
+
}
|
|
9
|
+
initResources() {
|
|
10
|
+
super.initResources();
|
|
11
|
+
this.createRedisCache();
|
|
12
|
+
this.createRedisCacheSecret();
|
|
13
|
+
this.createRedisCacheNamespace();
|
|
14
|
+
this.createRedisCacheApiManagement();
|
|
15
|
+
}
|
|
16
|
+
createRedisCache() {
|
|
17
|
+
this.api.redis = this.redisManager.createManagedRedis(this.id, this, {
|
|
18
|
+
...this.props.apiManagementManagedRedis,
|
|
19
|
+
name: this.props.stackName,
|
|
20
|
+
location: this.resourceGroup.location,
|
|
21
|
+
resourceGroupName: this.resourceGroup.name,
|
|
22
|
+
}, { ignoreChanges: ['location'] });
|
|
23
|
+
}
|
|
24
|
+
createRedisCacheSecret() {
|
|
25
|
+
this.api.redisNamedValueSecret = this.keyVaultManager.createKeyVaultSecret(`${this.id}-key-vault-redis-namespace-secret`, this, {
|
|
26
|
+
vaultName: this.api.authKeyVault.name,
|
|
27
|
+
secretName: `${this.api.redis.name}key`,
|
|
28
|
+
resourceGroupName: this.resourceGroup.name,
|
|
29
|
+
properties: {
|
|
30
|
+
value: `${this.api.redis.name}:10000,password=${this.api.redis.accessKeys.primaryKey},ssl=True,abortConnect=False`,
|
|
31
|
+
},
|
|
32
|
+
}, { dependsOn: [this.api.redis, this.api.namedValueRoleAssignment] });
|
|
33
|
+
}
|
|
34
|
+
createRedisCacheNamespace() {
|
|
35
|
+
this.api.redisNamedValue = this.apiManagementManager.createNamedValue(`${this.id}-redis-nv`, this, {
|
|
36
|
+
displayName: `${this.api.redis.name}key`,
|
|
37
|
+
resourceGroupName: this.resourceGroup.name,
|
|
38
|
+
serviceName: this.api.apim.name,
|
|
39
|
+
namedValueId: `${this.api.redis.name}key`,
|
|
40
|
+
secret: true,
|
|
41
|
+
keyVault: {
|
|
42
|
+
secretIdentifier: this.api.redisNamedValueSecret.id,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
createRedisCacheApiManagement() {
|
|
47
|
+
this.apiManagementManager.createCache(`${this.id}-am-redis-cache`, this, {
|
|
48
|
+
serviceName: this.api.apim.name,
|
|
49
|
+
connectionString: `{{${this.api.redisNamedValue.name}}}`,
|
|
50
|
+
cacheId: this.api.redis.id,
|
|
51
|
+
resourceGroupName: this.resourceGroup.name,
|
|
52
|
+
useFromLocation: this.api.redis.location,
|
|
53
|
+
description: `Redis cache for ${this.api.apim.name}`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NamedValue } from '@pulumi/azure-native/apimanagement/index.js';
|
|
2
|
+
import { Secret } from '@pulumi/azure-native/keyvault/index.js';
|
|
3
|
+
import { Redis } from '@pulumi/azure-native/redis/index.js';
|
|
4
|
+
import { RedisProps } from '../../index.js';
|
|
5
|
+
import { AzureApi, AzureRestApiProps } from '../index.js';
|
|
6
|
+
export interface AzureRestApiWithCacheProps extends AzureRestApiProps {
|
|
7
|
+
apiManagementManagedRedis: RedisProps;
|
|
8
|
+
}
|
|
9
|
+
export interface AzureApiWithCache extends AzureApi {
|
|
10
|
+
redis: Redis;
|
|
11
|
+
redisNamedValueSecret: Secret;
|
|
12
|
+
redisNamedValue: NamedValue;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GetComponentResult } from '@pulumi/azure-native/applicationinsights/index.js';
|
|
2
|
+
import { Output, ResourceOptions } from '@pulumi/pulumi';
|
|
3
|
+
import { CommonAzureConstruct } from '../../common/index.js';
|
|
4
|
+
import { Site, SiteWithWebAppProps } from './types.js';
|
|
5
|
+
export declare class SiteWithWebApp extends CommonAzureConstruct {
|
|
6
|
+
props: SiteWithWebAppProps;
|
|
7
|
+
applicationInsights: Output<GetComponentResult>;
|
|
8
|
+
site: Site;
|
|
9
|
+
constructor(id: string, props: SiteWithWebAppProps);
|
|
10
|
+
initResources(): void;
|
|
11
|
+
protected resolveApplicationInsights(): void;
|
|
12
|
+
protected createSiteAppServicePlan(): void;
|
|
13
|
+
protected createSiteStorageAccount(): void;
|
|
14
|
+
protected createSiteStorageContainer(): void;
|
|
15
|
+
protected createCodePackage(): void;
|
|
16
|
+
protected createWebAppSiteConfig(): void;
|
|
17
|
+
protected createWebApp(resourceOptions?: ResourceOptions): void;
|
|
18
|
+
protected createDiagnosticLog(): void;
|
|
19
|
+
}
|