@gradientedge/cdk-utils-azure 1.0.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/LICENSE +21 -0
- package/dist/src/common/constants.d.ts +83 -0
- package/dist/src/common/constants.js +87 -0
- package/dist/src/common/construct.d.ts +80 -0
- package/dist/src/common/construct.js +128 -0
- package/dist/src/common/index.d.ts +6 -0
- package/dist/src/common/index.js +6 -0
- package/dist/src/common/resource-name-formatter.d.ts +18 -0
- package/dist/src/common/resource-name-formatter.js +34 -0
- package/dist/src/common/stack.d.ts +46 -0
- package/dist/src/common/stack.js +120 -0
- package/dist/src/common/tagging.d.ts +29 -0
- package/dist/src/common/tagging.js +78 -0
- package/dist/src/common/types.d.ts +57 -0
- package/dist/src/common/types.js +1 -0
- package/dist/src/construct/event-handler/index.d.ts +2 -0
- package/dist/src/construct/event-handler/index.js +2 -0
- package/dist/src/construct/event-handler/main.d.ts +61 -0
- package/dist/src/construct/event-handler/main.js +180 -0
- package/dist/src/construct/event-handler/types.d.ts +35 -0
- package/dist/src/construct/event-handler/types.js +1 -0
- package/dist/src/construct/function-app/index.d.ts +2 -0
- package/dist/src/construct/function-app/index.js +2 -0
- package/dist/src/construct/function-app/main.d.ts +128 -0
- package/dist/src/construct/function-app/main.js +374 -0
- package/dist/src/construct/function-app/types.d.ts +33 -0
- package/dist/src/construct/function-app/types.js +1 -0
- package/dist/src/construct/index.d.ts +6 -0
- package/dist/src/construct/index.js +6 -0
- package/dist/src/construct/rest-api/index.d.ts +2 -0
- package/dist/src/construct/rest-api/index.js +2 -0
- package/dist/src/construct/rest-api/main.d.ts +64 -0
- package/dist/src/construct/rest-api/main.js +216 -0
- package/dist/src/construct/rest-api/types.d.ts +25 -0
- package/dist/src/construct/rest-api/types.js +1 -0
- package/dist/src/construct/rest-api-function/index.d.ts +2 -0
- package/dist/src/construct/rest-api-function/index.js +2 -0
- package/dist/src/construct/rest-api-function/main.d.ts +66 -0
- package/dist/src/construct/rest-api-function/main.js +302 -0
- package/dist/src/construct/rest-api-function/types.d.ts +29 -0
- package/dist/src/construct/rest-api-function/types.js +1 -0
- package/dist/src/construct/rest-api-with-cache/index.d.ts +2 -0
- package/dist/src/construct/rest-api-with-cache/index.js +2 -0
- package/dist/src/construct/rest-api-with-cache/main.d.ts +41 -0
- package/dist/src/construct/rest-api-with-cache/main.js +85 -0
- package/dist/src/construct/rest-api-with-cache/types.d.ts +13 -0
- package/dist/src/construct/rest-api-with-cache/types.js +1 -0
- package/dist/src/construct/site-with-webapp/index.d.ts +2 -0
- package/dist/src/construct/site-with-webapp/index.js +2 -0
- package/dist/src/construct/site-with-webapp/main.d.ts +60 -0
- package/dist/src/construct/site-with-webapp/main.js +176 -0
- package/dist/src/construct/site-with-webapp/types.d.ts +30 -0
- package/dist/src/construct/site-with-webapp/types.js +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +4 -0
- package/dist/src/services/api-management/index.d.ts +2 -0
- package/dist/src/services/api-management/index.js +2 -0
- package/dist/src/services/api-management/main.d.ts +143 -0
- package/dist/src/services/api-management/main.js +244 -0
- package/dist/src/services/api-management/types.d.ts +72 -0
- package/dist/src/services/api-management/types.js +1 -0
- package/dist/src/services/app-configuration/index.d.ts +2 -0
- package/dist/src/services/app-configuration/index.js +2 -0
- package/dist/src/services/app-configuration/main.d.ts +41 -0
- package/dist/src/services/app-configuration/main.js +71 -0
- package/dist/src/services/app-configuration/types.d.ts +3 -0
- package/dist/src/services/app-configuration/types.js +1 -0
- package/dist/src/services/app-service/index.d.ts +2 -0
- package/dist/src/services/app-service/index.js +2 -0
- package/dist/src/services/app-service/main.d.ts +40 -0
- package/dist/src/services/app-service/main.js +90 -0
- package/dist/src/services/app-service/types.d.ts +6 -0
- package/dist/src/services/app-service/types.js +1 -0
- package/dist/src/services/application-insights/index.d.ts +2 -0
- package/dist/src/services/application-insights/index.js +2 -0
- package/dist/src/services/application-insights/main.d.ts +40 -0
- package/dist/src/services/application-insights/main.js +68 -0
- package/dist/src/services/application-insights/types.d.ts +6 -0
- package/dist/src/services/application-insights/types.js +1 -0
- package/dist/src/services/authorisation/constants.d.ts +13 -0
- package/dist/src/services/authorisation/constants.js +14 -0
- package/dist/src/services/authorisation/index.d.ts +3 -0
- package/dist/src/services/authorisation/index.js +3 -0
- package/dist/src/services/authorisation/main.d.ts +84 -0
- package/dist/src/services/authorisation/main.js +120 -0
- package/dist/src/services/authorisation/types.d.ts +3 -0
- package/dist/src/services/authorisation/types.js +1 -0
- package/dist/src/services/cosmosdb/constants.d.ts +8 -0
- package/dist/src/services/cosmosdb/constants.js +10 -0
- package/dist/src/services/cosmosdb/index.d.ts +3 -0
- package/dist/src/services/cosmosdb/index.js +3 -0
- package/dist/src/services/cosmosdb/main.d.ts +87 -0
- package/dist/src/services/cosmosdb/main.js +162 -0
- package/dist/src/services/cosmosdb/types.d.ts +9 -0
- package/dist/src/services/cosmosdb/types.js +1 -0
- package/dist/src/services/dns/index.d.ts +2 -0
- package/dist/src/services/dns/index.js +2 -0
- package/dist/src/services/dns/main.d.ts +58 -0
- package/dist/src/services/dns/main.js +107 -0
- package/dist/src/services/dns/types.d.ts +9 -0
- package/dist/src/services/dns/types.js +1 -0
- package/dist/src/services/eventgrid/index.d.ts +2 -0
- package/dist/src/services/eventgrid/index.js +2 -0
- package/dist/src/services/eventgrid/main.d.ts +69 -0
- package/dist/src/services/eventgrid/main.js +136 -0
- package/dist/src/services/eventgrid/types.d.ts +11 -0
- package/dist/src/services/eventgrid/types.js +1 -0
- package/dist/src/services/function/index.d.ts +2 -0
- package/dist/src/services/function/index.js +2 -0
- package/dist/src/services/function/main.d.ts +60 -0
- package/dist/src/services/function/main.js +223 -0
- package/dist/src/services/function/types.d.ts +20 -0
- package/dist/src/services/function/types.js +1 -0
- package/dist/src/services/index.d.ts +18 -0
- package/dist/src/services/index.js +18 -0
- package/dist/src/services/key-vault/index.d.ts +2 -0
- package/dist/src/services/key-vault/index.js +2 -0
- package/dist/src/services/key-vault/main.d.ts +49 -0
- package/dist/src/services/key-vault/main.js +83 -0
- package/dist/src/services/key-vault/types.d.ts +5 -0
- package/dist/src/services/key-vault/types.js +1 -0
- package/dist/src/services/monitor/index.d.ts +2 -0
- package/dist/src/services/monitor/index.js +2 -0
- package/dist/src/services/monitor/main.d.ts +31 -0
- package/dist/src/services/monitor/main.js +36 -0
- package/dist/src/services/monitor/types.d.ts +3 -0
- package/dist/src/services/monitor/types.js +1 -0
- package/dist/src/services/operational-insights/index.d.ts +2 -0
- package/dist/src/services/operational-insights/index.js +2 -0
- package/dist/src/services/operational-insights/main.d.ts +40 -0
- package/dist/src/services/operational-insights/main.js +64 -0
- package/dist/src/services/operational-insights/types.d.ts +5 -0
- package/dist/src/services/operational-insights/types.js +1 -0
- package/dist/src/services/portal/error.d.ts +5 -0
- package/dist/src/services/portal/error.js +10 -0
- package/dist/src/services/portal/index.d.ts +4 -0
- package/dist/src/services/portal/index.js +4 -0
- package/dist/src/services/portal/main.d.ts +33 -0
- package/dist/src/services/portal/main.js +51 -0
- package/dist/src/services/portal/renderer.d.ts +11 -0
- package/dist/src/services/portal/renderer.js +156 -0
- package/dist/src/services/portal/types.d.ts +40 -0
- package/dist/src/services/portal/types.js +1 -0
- package/dist/src/services/redis/index.d.ts +2 -0
- package/dist/src/services/redis/index.js +2 -0
- package/dist/src/services/redis/main.d.ts +31 -0
- package/dist/src/services/redis/main.js +52 -0
- package/dist/src/services/redis/types.d.ts +3 -0
- package/dist/src/services/redis/types.js +1 -0
- package/dist/src/services/resource-group/index.d.ts +2 -0
- package/dist/src/services/resource-group/index.js +2 -0
- package/dist/src/services/resource-group/main.d.ts +38 -0
- package/dist/src/services/resource-group/main.js +53 -0
- package/dist/src/services/resource-group/types.d.ts +3 -0
- package/dist/src/services/resource-group/types.js +1 -0
- package/dist/src/services/security-center/index.d.ts +2 -0
- package/dist/src/services/security-center/index.js +2 -0
- package/dist/src/services/security-center/main.d.ts +31 -0
- package/dist/src/services/security-center/main.js +33 -0
- package/dist/src/services/security-center/types.d.ts +3 -0
- package/dist/src/services/security-center/types.js +1 -0
- package/dist/src/services/servicebus/index.d.ts +2 -0
- package/dist/src/services/servicebus/index.js +2 -0
- package/dist/src/services/servicebus/main.d.ts +67 -0
- package/dist/src/services/servicebus/main.js +127 -0
- package/dist/src/services/servicebus/types.d.ts +11 -0
- package/dist/src/services/servicebus/types.js +1 -0
- package/dist/src/services/storage/index.d.ts +2 -0
- package/dist/src/services/storage/index.js +2 -0
- package/dist/src/services/storage/main.d.ts +88 -0
- package/dist/src/services/storage/main.js +173 -0
- package/dist/src/services/storage/types.d.ts +20 -0
- package/dist/src/services/storage/types.js +1 -0
- package/dist/src/types/index.d.ts +4 -0
- package/dist/src/types/index.js +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AzureRestApi } from '../rest-api/main.js';
|
|
2
|
+
import { AzureApiWithCache, AzureRestApiWithCacheProps } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @classdesc Provides a construct to create and deploy an Azure API Management service with Redis cache integration
|
|
5
|
+
* @example
|
|
6
|
+
* import { AzureRestApiWithCache, AzureRestApiWithCacheProps } from '@gradientedge/cdk-utils'
|
|
7
|
+
*
|
|
8
|
+
* class CustomConstruct extends AzureRestApiWithCache {
|
|
9
|
+
* constructor(id: string, props: AzureRestApiWithCacheProps) {
|
|
10
|
+
* super(id, props)
|
|
11
|
+
* this.props = props
|
|
12
|
+
* this.id = id
|
|
13
|
+
* this.initResources()
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export declare class AzureRestApiWithCache extends AzureRestApi {
|
|
18
|
+
props: AzureRestApiWithCacheProps;
|
|
19
|
+
api: AzureApiWithCache;
|
|
20
|
+
constructor(id: string, props: AzureRestApiWithCacheProps);
|
|
21
|
+
/**
|
|
22
|
+
* @summary Initialise and provision resources
|
|
23
|
+
*/
|
|
24
|
+
initResources(): void;
|
|
25
|
+
/**
|
|
26
|
+
* @summary Method to create the managed Redis cache instance
|
|
27
|
+
*/
|
|
28
|
+
protected createRedisCache(): void;
|
|
29
|
+
/**
|
|
30
|
+
* @summary Method to create the Redis cache connection string secret in Key Vault
|
|
31
|
+
*/
|
|
32
|
+
protected createRedisCacheSecret(): void;
|
|
33
|
+
/**
|
|
34
|
+
* @summary Method to create the API Management named value for the Redis cache secret
|
|
35
|
+
*/
|
|
36
|
+
protected createRedisCacheNamespace(): void;
|
|
37
|
+
/**
|
|
38
|
+
* @summary Method to register the Redis cache with API Management
|
|
39
|
+
*/
|
|
40
|
+
protected createRedisCacheApiManagement(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { AzureRestApi } from '../rest-api/main.js';
|
|
2
|
+
/**
|
|
3
|
+
* @classdesc Provides a construct to create and deploy an Azure API Management service with Redis cache integration
|
|
4
|
+
* @example
|
|
5
|
+
* import { AzureRestApiWithCache, AzureRestApiWithCacheProps } from '@gradientedge/cdk-utils'
|
|
6
|
+
*
|
|
7
|
+
* class CustomConstruct extends AzureRestApiWithCache {
|
|
8
|
+
* constructor(id: string, props: AzureRestApiWithCacheProps) {
|
|
9
|
+
* super(id, props)
|
|
10
|
+
* this.props = props
|
|
11
|
+
* this.id = id
|
|
12
|
+
* this.initResources()
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
export class AzureRestApiWithCache extends AzureRestApi {
|
|
17
|
+
props;
|
|
18
|
+
constructor(id, props) {
|
|
19
|
+
super(id, props);
|
|
20
|
+
this.props = props;
|
|
21
|
+
this.id = id;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @summary Initialise and provision resources
|
|
25
|
+
*/
|
|
26
|
+
initResources() {
|
|
27
|
+
super.initResources();
|
|
28
|
+
this.createRedisCache();
|
|
29
|
+
this.createRedisCacheSecret();
|
|
30
|
+
this.createRedisCacheNamespace();
|
|
31
|
+
this.createRedisCacheApiManagement();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @summary Method to create the managed Redis cache instance
|
|
35
|
+
*/
|
|
36
|
+
createRedisCache() {
|
|
37
|
+
this.api.redis = this.redisManager.createManagedRedis(this.id, this, {
|
|
38
|
+
...this.props.apiManagementManagedRedis,
|
|
39
|
+
name: this.props.stackName,
|
|
40
|
+
location: this.resourceGroup.location,
|
|
41
|
+
resourceGroupName: this.resourceGroup.name,
|
|
42
|
+
}, { ignoreChanges: ['location'] });
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @summary Method to create the Redis cache connection string secret in Key Vault
|
|
46
|
+
*/
|
|
47
|
+
createRedisCacheSecret() {
|
|
48
|
+
this.api.redisNamedValueSecret = this.keyVaultManager.createKeyVaultSecret(`${this.id}-key-vault-redis-namespace-secret`, this, {
|
|
49
|
+
vaultName: this.api.authKeyVault.name,
|
|
50
|
+
secretName: `${this.api.redis.name}key`,
|
|
51
|
+
resourceGroupName: this.resourceGroup.name,
|
|
52
|
+
properties: {
|
|
53
|
+
value: `${this.api.redis.name}:10000,password=${this.api.redis.accessKeys.primaryKey},ssl=True,abortConnect=False`,
|
|
54
|
+
},
|
|
55
|
+
}, { dependsOn: [this.api.redis, this.api.namedValueRoleAssignment] });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @summary Method to create the API Management named value for the Redis cache secret
|
|
59
|
+
*/
|
|
60
|
+
createRedisCacheNamespace() {
|
|
61
|
+
this.api.redisNamedValue = this.apiManagementManager.createNamedValue(`${this.id}-redis-nv`, this, {
|
|
62
|
+
displayName: `${this.api.redis.name}key`,
|
|
63
|
+
resourceGroupName: this.resourceGroup.name,
|
|
64
|
+
serviceName: this.api.apim.name,
|
|
65
|
+
namedValueId: `${this.api.redis.name}key`,
|
|
66
|
+
secret: true,
|
|
67
|
+
keyVault: {
|
|
68
|
+
secretIdentifier: this.api.redisNamedValueSecret.id,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @summary Method to register the Redis cache with API Management
|
|
74
|
+
*/
|
|
75
|
+
createRedisCacheApiManagement() {
|
|
76
|
+
this.apiManagementManager.createCache(`${this.id}-am-redis-cache`, this, {
|
|
77
|
+
serviceName: this.api.apim.name,
|
|
78
|
+
connectionString: `{{${this.api.redisNamedValue.name}}}`,
|
|
79
|
+
cacheId: this.api.redis.id,
|
|
80
|
+
resourceGroupName: this.resourceGroup.name,
|
|
81
|
+
useFromLocation: this.api.redis.location,
|
|
82
|
+
description: `Redis cache for ${this.api.apim.name}`,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -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,60 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* @classdesc Provides a construct to create and deploy a site hosted with an Azure Linux Web App
|
|
7
|
+
* @example
|
|
8
|
+
* import { SiteWithWebApp, SiteWithWebAppProps } from '@gradientedge/cdk-utils'
|
|
9
|
+
*
|
|
10
|
+
* class CustomConstruct extends SiteWithWebApp {
|
|
11
|
+
* constructor(id: string, props: SiteWithWebAppProps) {
|
|
12
|
+
* super(id, props)
|
|
13
|
+
* this.props = props
|
|
14
|
+
* this.id = id
|
|
15
|
+
* this.initResources()
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export declare class SiteWithWebApp extends CommonAzureConstruct {
|
|
20
|
+
props: SiteWithWebAppProps;
|
|
21
|
+
applicationInsights: Output<GetComponentResult>;
|
|
22
|
+
site: Site;
|
|
23
|
+
constructor(id: string, props: SiteWithWebAppProps);
|
|
24
|
+
/**
|
|
25
|
+
* @summary Initialise and provision resources
|
|
26
|
+
*/
|
|
27
|
+
initResources(): void;
|
|
28
|
+
/**
|
|
29
|
+
* @summary Method to resolve the Application Insights instance
|
|
30
|
+
*/
|
|
31
|
+
protected resolveApplicationInsights(): void;
|
|
32
|
+
/**
|
|
33
|
+
* @summary Method to create the App Service Plan for the web app
|
|
34
|
+
*/
|
|
35
|
+
protected createSiteAppServicePlan(): void;
|
|
36
|
+
/**
|
|
37
|
+
* @summary Method to create the storage account for the web app
|
|
38
|
+
*/
|
|
39
|
+
protected createSiteStorageAccount(): void;
|
|
40
|
+
/**
|
|
41
|
+
* @summary Method to create the storage container for web app deployment
|
|
42
|
+
*/
|
|
43
|
+
protected createSiteStorageContainer(): void;
|
|
44
|
+
/**
|
|
45
|
+
* @summary Method to create the code package archive for deployment
|
|
46
|
+
*/
|
|
47
|
+
protected createCodePackage(): void;
|
|
48
|
+
/**
|
|
49
|
+
* @summary Method to create the web app site configuration with environment variables
|
|
50
|
+
*/
|
|
51
|
+
protected createWebAppSiteConfig(): void;
|
|
52
|
+
/**
|
|
53
|
+
* @summary Method to create the Azure Linux Web App
|
|
54
|
+
*/
|
|
55
|
+
protected createWebApp(resourceOptions?: ResourceOptions): void;
|
|
56
|
+
/**
|
|
57
|
+
* @summary Method to create the Monitor diagnostic log settings for the web app
|
|
58
|
+
*/
|
|
59
|
+
protected createDiagnosticLog(): void;
|
|
60
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import * as archive from '@pulumi/archive';
|
|
2
|
+
import { getComponentOutput } from '@pulumi/azure-native/applicationinsights/index.js';
|
|
3
|
+
import { writeFileSync } from 'fs';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { CommonAzureConstruct } from '../../common/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* @classdesc Provides a construct to create and deploy a site hosted with an Azure Linux Web App
|
|
9
|
+
* @example
|
|
10
|
+
* import { SiteWithWebApp, SiteWithWebAppProps } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends SiteWithWebApp {
|
|
13
|
+
* constructor(id: string, props: SiteWithWebAppProps) {
|
|
14
|
+
* super(id, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.id = id
|
|
17
|
+
* this.initResources()
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
export class SiteWithWebApp extends CommonAzureConstruct {
|
|
22
|
+
props;
|
|
23
|
+
applicationInsights;
|
|
24
|
+
site;
|
|
25
|
+
constructor(id, props) {
|
|
26
|
+
super(id, props);
|
|
27
|
+
this.props = props;
|
|
28
|
+
this.id = id;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @summary Initialise and provision resources
|
|
32
|
+
*/
|
|
33
|
+
initResources() {
|
|
34
|
+
this.createResourceGroup();
|
|
35
|
+
this.resolveCommonLogAnalyticsWorkspace();
|
|
36
|
+
this.resolveApplicationInsights();
|
|
37
|
+
this.createSiteAppServicePlan();
|
|
38
|
+
this.createSiteStorageAccount();
|
|
39
|
+
this.createSiteStorageContainer();
|
|
40
|
+
this.createCodePackage();
|
|
41
|
+
this.createWebAppSiteConfig();
|
|
42
|
+
this.createWebApp();
|
|
43
|
+
this.createDiagnosticLog();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @summary Method to resolve the Application Insights instance
|
|
47
|
+
*/
|
|
48
|
+
resolveApplicationInsights() {
|
|
49
|
+
if (!this.props.commonApplicationInsights || !this.props.commonApplicationInsights.resourceName)
|
|
50
|
+
return;
|
|
51
|
+
this.applicationInsights = getComponentOutput({
|
|
52
|
+
resourceName: this.props.commonApplicationInsights.resourceName,
|
|
53
|
+
resourceGroupName: this.props.commonApplicationInsights.resourceGroupName,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @summary Method to create the App Service Plan for the web app
|
|
58
|
+
*/
|
|
59
|
+
createSiteAppServicePlan() {
|
|
60
|
+
this.site.appServicePlan = this.appServiceManager.createAppServicePlan(`${this.id}-app-service-plan`, this, {
|
|
61
|
+
...this.props.site.appServicePlan,
|
|
62
|
+
location: this.resourceGroup.location,
|
|
63
|
+
resourceGroupName: this.resourceGroup.name,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @summary Method to create the storage account for the web app
|
|
68
|
+
*/
|
|
69
|
+
createSiteStorageAccount() {
|
|
70
|
+
this.site.storageAccount = this.storageManager.createStorageAccount(`${this.id}-storage-account`, this, {
|
|
71
|
+
...this.props.site.storageAccount,
|
|
72
|
+
location: this.resourceGroup.location,
|
|
73
|
+
resourceGroupName: this.resourceGroup.name,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @summary Method to create the storage container for web app deployment
|
|
78
|
+
*/
|
|
79
|
+
createSiteStorageContainer() {
|
|
80
|
+
this.site.storageContainer = this.storageManager.createStorageContainer(`${this.id}-storage-deployment-container`, this, {
|
|
81
|
+
...this.props.site.storageContainer,
|
|
82
|
+
accountName: this.site.storageAccount.id,
|
|
83
|
+
resourceGroupName: this.resourceGroup.name,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @summary Method to create the code package archive for deployment
|
|
88
|
+
*/
|
|
89
|
+
createCodePackage() {
|
|
90
|
+
const currentDirectory = path.resolve();
|
|
91
|
+
if (this.props.startCommand) {
|
|
92
|
+
const packageJson = {
|
|
93
|
+
description: 'Generated',
|
|
94
|
+
name: this.id,
|
|
95
|
+
private: true,
|
|
96
|
+
scripts: {
|
|
97
|
+
start: this.props.startCommand,
|
|
98
|
+
},
|
|
99
|
+
version: '1.0.0',
|
|
100
|
+
};
|
|
101
|
+
const packageJsonFile = `${currentDirectory}/${this.props.deploySource}/package.json`;
|
|
102
|
+
writeFileSync(packageJsonFile, JSON.stringify(packageJson));
|
|
103
|
+
}
|
|
104
|
+
this.site.codeArchiveFile = archive.getFileOutput({
|
|
105
|
+
...this.props.site.codeArchiveFile,
|
|
106
|
+
excludes: this.props.site.codeArchiveFile.excludes ?? ['*.zip'],
|
|
107
|
+
outputPath: `${currentDirectory}/${this.props.deploySource}/${this.props.packageName}`,
|
|
108
|
+
sourceDir: `${currentDirectory}/${this.props.deploySource}`,
|
|
109
|
+
type: this.props.site.codeArchiveFile.type ?? 'zip',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @summary Method to create the web app site configuration with environment variables
|
|
114
|
+
*/
|
|
115
|
+
createWebAppSiteConfig() {
|
|
116
|
+
this.site.environmentVariables = {
|
|
117
|
+
APPINSIGHTS_INSTRUMENTATIONKEY: this.applicationInsights.instrumentationKey,
|
|
118
|
+
APPLICATIONINSIGHTS_CONNECTION_STRING: this.applicationInsights.connectionString,
|
|
119
|
+
ApplicationInsightsAgent_EXTENSION_VERSION: '~3',
|
|
120
|
+
OTEL_SDK_DISABLED: 'false',
|
|
121
|
+
BUILD_VERSION: '0.0.0',
|
|
122
|
+
STAGE: this.props.stage,
|
|
123
|
+
NODE_OPTIONS: this.props.nodeOptions,
|
|
124
|
+
NODE_ENV: this.props.nodeEnv ?? 'production',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @summary Method to create the Azure Linux Web App
|
|
129
|
+
*/
|
|
130
|
+
createWebApp(resourceOptions) {
|
|
131
|
+
this.site.webApp = this.appServiceManager.createLinuxWebApp(`${this.id}-web-app`, this, {
|
|
132
|
+
...this.props.site.webApp,
|
|
133
|
+
location: this.resourceGroup.location,
|
|
134
|
+
resourceGroupName: this.resourceGroup.name,
|
|
135
|
+
serverFarmId: this.site.appServicePlan.id,
|
|
136
|
+
siteConfig: _.merge(this.props.site.webApp.siteConfig, {
|
|
137
|
+
appSettings: _.map(this.site.environmentVariables, (value, name) => ({ name, value })),
|
|
138
|
+
}),
|
|
139
|
+
}, { ...resourceOptions });
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @summary Method to create the Monitor diagnostic log settings for the web app
|
|
143
|
+
*/
|
|
144
|
+
createDiagnosticLog() {
|
|
145
|
+
this.monitorManager.createMonitorDiagnosticSettings(this.id, this, {
|
|
146
|
+
name: `${this.props.site.webApp.name}-webapp`,
|
|
147
|
+
resourceUri: this.site.webApp.id,
|
|
148
|
+
workspaceId: this.commonLogAnalyticsWorkspace.id,
|
|
149
|
+
logAnalyticsDestinationType: 'Dedicated',
|
|
150
|
+
logs: [
|
|
151
|
+
{
|
|
152
|
+
category: 'AppServiceAppLogs',
|
|
153
|
+
enabled: true,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
category: 'AppServiceConsoleLogs',
|
|
157
|
+
enabled: true,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
category: 'AppServiceHTTPLogs',
|
|
161
|
+
enabled: true,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
category: 'AppServicePlatformLogs',
|
|
165
|
+
enabled: true,
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
metrics: [
|
|
169
|
+
{
|
|
170
|
+
category: 'AllMetrics',
|
|
171
|
+
enabled: true,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as archive from '@pulumi/archive';
|
|
2
|
+
import { GetFileOutputArgs } from '@pulumi/archive';
|
|
3
|
+
import { BlobContainer, StorageAccount } from '@pulumi/azure-native/storage/index.js';
|
|
4
|
+
import { AppServicePlan, WebApp } from '@pulumi/azure-native/web/index.js';
|
|
5
|
+
import { Output } from '@pulumi/pulumi';
|
|
6
|
+
import { CommonAzureStackProps } from '../../common/index.js';
|
|
7
|
+
import { LinuxWebAppProps, ServicePlanProps, StorageAccountProps, StorageContainerProps } from '../../services/index.js';
|
|
8
|
+
export interface SiteProps {
|
|
9
|
+
appServicePlan: ServicePlanProps;
|
|
10
|
+
codeArchiveFile: GetFileOutputArgs;
|
|
11
|
+
storageAccount: StorageAccountProps;
|
|
12
|
+
storageContainer: StorageContainerProps;
|
|
13
|
+
webApp: LinuxWebAppProps;
|
|
14
|
+
}
|
|
15
|
+
export interface SiteWithWebAppProps extends CommonAzureStackProps {
|
|
16
|
+
deploySource: string;
|
|
17
|
+
nodeOptions: string;
|
|
18
|
+
nodeEnv?: string;
|
|
19
|
+
packageName: string;
|
|
20
|
+
site: SiteProps;
|
|
21
|
+
startCommand: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Site {
|
|
24
|
+
appServicePlan: AppServicePlan;
|
|
25
|
+
codeArchiveFile: Output<archive.GetFileResult>;
|
|
26
|
+
environmentVariables: Record<string, any>;
|
|
27
|
+
storageAccount: StorageAccount;
|
|
28
|
+
storageContainer: BlobContainer;
|
|
29
|
+
webApp: WebApp;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as redis from '@pulumi/azure-native/redis/index.js';
|
|
2
|
+
import { ResourceOptions } from '@pulumi/pulumi';
|
|
3
|
+
import { CommonAzureConstruct } from '../../common/index.js';
|
|
4
|
+
import { ApiDiagnosticProps, ApiManagementApiProps, ApiManagementBackendProps, ApiManagementCustomDomainProps, ApiManagementProps, ApiOperationPolicyProps, ApiOperationProps, ApiPolicyProps, ApiSubscriptionProps, CacheProps, LoggerProps, NamedValueProps, ResolveApiManagementProps } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* @classdesc Provides operations on Azure API Management using Pulumi
|
|
7
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
8
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
12
|
+
*
|
|
13
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
14
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
15
|
+
* super(name, props)
|
|
16
|
+
* this.props = props
|
|
17
|
+
* this.apiManagementManager.createApiManagement('MyApiManagement', this, props)
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class AzureApiManagementManager {
|
|
23
|
+
/**
|
|
24
|
+
* @summary Method to create a new API Management service
|
|
25
|
+
* @param id scoped id of the resource
|
|
26
|
+
* @param scope scope in which this resource is defined
|
|
27
|
+
* @param props API Management properties
|
|
28
|
+
* @param applicationInsightsKey Optional Application Insights instrumentation key for logging
|
|
29
|
+
* @param externalRedisCache Optional external Redis cache for API Management caching
|
|
30
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
31
|
+
* @see [Pulumi Azure Native API Management]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
|
|
32
|
+
*/
|
|
33
|
+
createApiManagementService(id: string, scope: CommonAzureConstruct, props: ApiManagementProps, applicationInsightsKey?: string, externalRedisCache?: redis.Redis, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/apiManagementService.js").ApiManagementService;
|
|
34
|
+
/**
|
|
35
|
+
* @summary Method to resolve an existing API Management service
|
|
36
|
+
* @param id scoped id of the resource
|
|
37
|
+
* @param scope scope in which this resource is defined
|
|
38
|
+
* @param props API Management lookup properties
|
|
39
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
40
|
+
* @see [Pulumi Azure Native API Management Lookup]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
|
|
41
|
+
*/
|
|
42
|
+
resolveApiManagementService(id: string, scope: CommonAzureConstruct, props: ResolveApiManagementProps, resourceOptions?: ResourceOptions): import("@pulumi/pulumi").Output<import("@pulumi/azure-native/apimanagement/getApiManagementService.js").GetApiManagementServiceResult>;
|
|
43
|
+
/**
|
|
44
|
+
* @summary Method to create a new API Management backend
|
|
45
|
+
* @param id scoped id of the resource
|
|
46
|
+
* @param scope scope in which this resource is defined
|
|
47
|
+
* @param props API Management backend properties
|
|
48
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
49
|
+
* @see [Pulumi Azure Native API Management Backend]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/backend/}
|
|
50
|
+
*/
|
|
51
|
+
createBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/backend.js").Backend;
|
|
52
|
+
/**
|
|
53
|
+
* @summary Method to create a new API Management API with operations and policies
|
|
54
|
+
* @param id scoped id of the resource
|
|
55
|
+
* @param scope scope in which this resource is defined
|
|
56
|
+
* @param props API Management API properties
|
|
57
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
58
|
+
* @see [Pulumi Azure Native API Management API]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/api/}
|
|
59
|
+
*/
|
|
60
|
+
createApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/api.js").Api;
|
|
61
|
+
/**
|
|
62
|
+
* @summary Method to create a new API Diagnostic
|
|
63
|
+
* @param id scoped id of the resource
|
|
64
|
+
* @param scope scope in which this resource is defined
|
|
65
|
+
* @param props API Disagnostic properties
|
|
66
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
67
|
+
* @see [Pulumi Azure Native API Management Diagnostic]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apidiagnostic/}
|
|
68
|
+
*/
|
|
69
|
+
createApiDiagnostic(id: string, scope: CommonAzureConstruct, props: ApiDiagnosticProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/apiDiagnostic.js").ApiDiagnostic;
|
|
70
|
+
/**
|
|
71
|
+
* @summary Method to create a new API Logger
|
|
72
|
+
* @param id scoped id of the resource
|
|
73
|
+
* @param scope scope in which this resource is defined
|
|
74
|
+
* @param props API Logger properties
|
|
75
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
76
|
+
* @see [Pulumi Azure Native API Management Logger]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/logger/}
|
|
77
|
+
*/
|
|
78
|
+
createLogger(id: string, scope: CommonAzureConstruct, props: LoggerProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/logger.js").Logger;
|
|
79
|
+
/**
|
|
80
|
+
* @summary Method to create a new API Named Value
|
|
81
|
+
* @param id scoped id of the resource
|
|
82
|
+
* @param scope scope in which this resource is defined
|
|
83
|
+
* @param props API Named Value properties
|
|
84
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
85
|
+
* @see [Pulumi Azure Native API Management Named Value]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/namedvalue/}
|
|
86
|
+
*/
|
|
87
|
+
createNamedValue(id: string, scope: CommonAzureConstruct, props: NamedValueProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/namedValue.js").NamedValue;
|
|
88
|
+
/**
|
|
89
|
+
* @summary Method to create a new API Subscription
|
|
90
|
+
* @param id scoped id of the resource
|
|
91
|
+
* @param scope scope in which this resource is defined
|
|
92
|
+
* @param props API Subscription properties
|
|
93
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
94
|
+
* @see [Pulumi Azure Native API Management Subscription]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/subscription/}
|
|
95
|
+
*/
|
|
96
|
+
createSubscription(id: string, scope: CommonAzureConstruct, props: ApiSubscriptionProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/subscription.js").Subscription;
|
|
97
|
+
/**
|
|
98
|
+
* @summary Method to create a new API cache
|
|
99
|
+
* @param id scoped id of the resource
|
|
100
|
+
* @param scope scope in which this resource is defined
|
|
101
|
+
* @param props API cache properties
|
|
102
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
103
|
+
* @see [Pulumi Azure Native API Management Cache]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/cache/}
|
|
104
|
+
*/
|
|
105
|
+
createCache(id: string, scope: CommonAzureConstruct, props: CacheProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/cache.js").Cache;
|
|
106
|
+
/**
|
|
107
|
+
* @summary Method to create a new API operation
|
|
108
|
+
* @param id scoped id of the resource
|
|
109
|
+
* @param scope scope in which this resource is defined
|
|
110
|
+
* @param props API operation properties
|
|
111
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
112
|
+
* @see [Pulumi Azure Native API Management Operation]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apioperation/}
|
|
113
|
+
*/
|
|
114
|
+
createOperation(id: string, scope: CommonAzureConstruct, props: ApiOperationProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/apiOperation.js").ApiOperation;
|
|
115
|
+
/**
|
|
116
|
+
* @summary Method to create a new API operation policy
|
|
117
|
+
* @param id scoped id of the resource
|
|
118
|
+
* @param scope scope in which this resource is defined
|
|
119
|
+
* @param props API operation policy properties
|
|
120
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
121
|
+
* @see [Pulumi Azure Native API Management Operation Policy]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apioperationpolicy/}
|
|
122
|
+
*/
|
|
123
|
+
createOperationPolicy(id: string, scope: CommonAzureConstruct, props: ApiOperationPolicyProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/apiOperationPolicy.js").ApiOperationPolicy;
|
|
124
|
+
/**
|
|
125
|
+
* @summary Method to create a new API policy
|
|
126
|
+
* @param id scoped id of the resource
|
|
127
|
+
* @param scope scope in which this resource is defined
|
|
128
|
+
* @param props API policy properties
|
|
129
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
130
|
+
* @see [Pulumi Azure Native API Management Policy]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apipolicy/}
|
|
131
|
+
*/
|
|
132
|
+
createPolicy(id: string, scope: CommonAzureConstruct, props: ApiPolicyProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/apimanagement/apiPolicy.js").ApiPolicy;
|
|
133
|
+
/**
|
|
134
|
+
* @summary Method to create a new API Management custom domain
|
|
135
|
+
* @param id scoped id of the resource
|
|
136
|
+
* @param scope scope in which this resource is defined
|
|
137
|
+
* @param props API Management custom domain properties
|
|
138
|
+
* @param resourceOptions Optional settings to control resource behaviour
|
|
139
|
+
* @note In Pulumi Azure Native, custom domains are configured as part of the API Management service resource,
|
|
140
|
+
* not as a separate resource. Use the hostnameConfigurations property when creating the service.
|
|
141
|
+
*/
|
|
142
|
+
createApiManagementCustomDomain(id: string, scope: CommonAzureConstruct, props: ApiManagementCustomDomainProps): void;
|
|
143
|
+
}
|