@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,78 @@
|
|
|
1
|
+
import * as pulumi from '@pulumi/pulumi';
|
|
2
|
+
import { RESOURCES_TO_EXCLUDE_TAGS } from './constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* @summary Check if a resource type is taggable
|
|
5
|
+
* @param resourceType The Pulumi resource type (e.g., 'azure-native:resources:ResourceGroup')
|
|
6
|
+
* @returns True if the resource supports tags, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export function isTaggableResource(resourceType) {
|
|
9
|
+
// Extract the resource name from the type (e.g., 'ResourceGroup' from 'azure-native:resources:ResourceGroup')
|
|
10
|
+
const resourceName = resourceType.split(':').pop() || '';
|
|
11
|
+
// Check if this resource is in the exclusion list
|
|
12
|
+
if (RESOURCES_TO_EXCLUDE_TAGS.has(resourceName)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
// Most Azure resources support tags, but we can add more specific checks here if needed
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @summary Register a stack transformation to automatically apply tags to Azure resources
|
|
20
|
+
* @param defaultTags The default tags to apply to all resources
|
|
21
|
+
* @param tagsToIgnore Optional list of tag keys to ignore in lifecycle management
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* registerTagTransformation({ environment: 'production', team: 'platform' })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function registerTagTransformation(defaultTags, tagsToIgnore = []) {
|
|
28
|
+
pulumi.runtime.registerStackTransformation((args) => {
|
|
29
|
+
// Only process taggable resources
|
|
30
|
+
if (!isTaggableResource(args.type)) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
// Check if the resource has a tags property
|
|
34
|
+
if (!args.props || typeof args.props !== 'object') {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
// Merge default tags with resource-specific tags (resource tags take precedence)
|
|
38
|
+
const currentTags = args.props.tags || {};
|
|
39
|
+
const mergedTags = { ...defaultTags, ...currentTags };
|
|
40
|
+
// Apply the merged tags
|
|
41
|
+
const newProps = {
|
|
42
|
+
...args.props,
|
|
43
|
+
tags: mergedTags,
|
|
44
|
+
};
|
|
45
|
+
// Handle tag ignores via Pulumi's ignoreChanges option
|
|
46
|
+
let newOpts = args.opts;
|
|
47
|
+
if (tagsToIgnore.length > 0) {
|
|
48
|
+
const ignoreChanges = tagsToIgnore.map(tag => `tags.${tag}`);
|
|
49
|
+
newOpts = {
|
|
50
|
+
...args.opts,
|
|
51
|
+
ignoreChanges: [...(args.opts?.ignoreChanges || []), ...ignoreChanges],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
props: newProps,
|
|
56
|
+
opts: newOpts,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @summary Helper function to apply tags to a specific resource's properties
|
|
62
|
+
* @param props The resource properties
|
|
63
|
+
* @param defaultTags The default tags to merge with existing tags
|
|
64
|
+
* @returns The properties with merged tags
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const resourceGroupProps = applyTags(props, { environment: 'dev' })
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export function applyTags(props, defaultTags) {
|
|
71
|
+
return {
|
|
72
|
+
...props,
|
|
73
|
+
tags: {
|
|
74
|
+
...defaultTags,
|
|
75
|
+
...(props.tags || {}),
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { GetComponentOutputArgs } from '@pulumi/azure-native/applicationinsights/index.js';
|
|
2
|
+
import { GetWorkspaceOutputArgs } from '@pulumi/azure-native/operationalinsights/index.js';
|
|
3
|
+
import { BaseProps } from '@gradientedge/cdk-utils-common';
|
|
4
|
+
import { AzureLocation, AzureRemoteBackend } from './constants.js';
|
|
5
|
+
export interface AzureLocationConfig {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @interface CommonAzureStackProps
|
|
11
|
+
* @description Common properties for Azure stack configuration using Pulumi
|
|
12
|
+
*/
|
|
13
|
+
export interface CommonAzureStackProps extends BaseProps {
|
|
14
|
+
stackName?: string;
|
|
15
|
+
resourceGroupName?: string;
|
|
16
|
+
remoteBackend?: AzureRemoteBackendProps;
|
|
17
|
+
globalPrefix?: string;
|
|
18
|
+
globalSuffix?: string;
|
|
19
|
+
resourcePrefix?: string;
|
|
20
|
+
resourceSuffix?: string;
|
|
21
|
+
resourceNameOptions?: {
|
|
22
|
+
[key: string]: AzureResourceNameFormatterProps;
|
|
23
|
+
};
|
|
24
|
+
location: AzureLocation;
|
|
25
|
+
locationConfig?: Record<AzureLocation, AzureLocationConfig>;
|
|
26
|
+
locales?: string[];
|
|
27
|
+
defaultTags?: {
|
|
28
|
+
[key: string]: string;
|
|
29
|
+
};
|
|
30
|
+
commonLogAnalyticsWorkspace?: GetWorkspaceOutputArgs;
|
|
31
|
+
commonApplicationInsights?: GetComponentOutputArgs;
|
|
32
|
+
subscriptionId?: string;
|
|
33
|
+
tenantId?: string;
|
|
34
|
+
clientId?: string;
|
|
35
|
+
clientSecret?: string;
|
|
36
|
+
environment?: string;
|
|
37
|
+
useOidc?: boolean;
|
|
38
|
+
oidcRequestToken?: string;
|
|
39
|
+
oidcRequestUrl?: string;
|
|
40
|
+
useMsi?: boolean;
|
|
41
|
+
msiEndpoint?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface AzureRemoteBackendProps {
|
|
44
|
+
type: AzureRemoteBackend;
|
|
45
|
+
storageAccountName?: string;
|
|
46
|
+
containerName?: string;
|
|
47
|
+
resourceGroupName?: string;
|
|
48
|
+
subscriptionId?: string;
|
|
49
|
+
key?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface AzureResourceNameFormatterProps {
|
|
52
|
+
exclude?: boolean;
|
|
53
|
+
globalPrefix?: boolean;
|
|
54
|
+
globalSuffix?: boolean;
|
|
55
|
+
prefix?: string;
|
|
56
|
+
suffix?: string;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { GetTopicResult, Topic } from '@pulumi/azure-native/eventgrid/index.js';
|
|
2
|
+
import { Output } from '@pulumi/pulumi';
|
|
3
|
+
import { AzureFunctionApp } from '../function-app/index.js';
|
|
4
|
+
import { AzureEventHandlerProps, EventHandlerEventGridSubscription, EventHandlerServiceBus } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* @classdesc Provides a construct to create and deploy an Azure EventGrid Event Handler with Service Bus integration
|
|
7
|
+
* @example
|
|
8
|
+
* import { AzureEventHandler, AzureEventHandlerProps } from '@gradientedge/cdk-utils'
|
|
9
|
+
*
|
|
10
|
+
* class CustomConstruct extends AzureEventHandler {
|
|
11
|
+
* constructor(id: string, props: AzureEventHandlerProps) {
|
|
12
|
+
* super(id, props)
|
|
13
|
+
* this.props = props
|
|
14
|
+
* this.id = id
|
|
15
|
+
* this.initResources()
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export declare class AzureEventHandler extends AzureFunctionApp {
|
|
20
|
+
props: AzureEventHandlerProps;
|
|
21
|
+
eventGridEventSubscription: EventHandlerEventGridSubscription;
|
|
22
|
+
eventGridTopic: Topic | Output<GetTopicResult>;
|
|
23
|
+
serviceBus: EventHandlerServiceBus;
|
|
24
|
+
constructor(id: string, props: AzureEventHandlerProps);
|
|
25
|
+
/**
|
|
26
|
+
* @summary Initialise and provision resources
|
|
27
|
+
*/
|
|
28
|
+
initResources(): void;
|
|
29
|
+
/**
|
|
30
|
+
* @summary Method to create the dead-letter queue storage account for EventGrid subscriptions
|
|
31
|
+
*/
|
|
32
|
+
protected createEventGridSubscriptionDlqStorageAccount(): void;
|
|
33
|
+
/**
|
|
34
|
+
* @summary Method to create the dead-letter queue storage container for EventGrid subscriptions
|
|
35
|
+
*/
|
|
36
|
+
protected createEventGridSubscriptionDlqStorageContainer(): void;
|
|
37
|
+
/**
|
|
38
|
+
* @summary Method to create the Service Bus namespace
|
|
39
|
+
*/
|
|
40
|
+
protected createServiceBusNamespace(): void;
|
|
41
|
+
/**
|
|
42
|
+
* @summary Method to create the Service Bus queue
|
|
43
|
+
*/
|
|
44
|
+
protected createServiceBusQueue(): void;
|
|
45
|
+
/**
|
|
46
|
+
* @summary Method to create or resolve an existing EventGrid topic
|
|
47
|
+
*/
|
|
48
|
+
protected createEventGrid(): void;
|
|
49
|
+
/**
|
|
50
|
+
* @summary Method to create the EventGrid event subscription with Service Bus queue destination
|
|
51
|
+
*/
|
|
52
|
+
protected createEventGridEventSubscription(): void;
|
|
53
|
+
/**
|
|
54
|
+
* @summary Method to create diagnostic log settings for the Service Bus namespace
|
|
55
|
+
*/
|
|
56
|
+
protected createServiceBusDiagnosticLog(): void;
|
|
57
|
+
/**
|
|
58
|
+
* @summary Method to enable Microsoft Defender malware scanning on the data storage account
|
|
59
|
+
*/
|
|
60
|
+
protected enableMalwareScanningOnDataStorageAccount(): void;
|
|
61
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { Provider } from '@pulumi/azure-native';
|
|
2
|
+
import { getTopicOutput } from '@pulumi/azure-native/eventgrid/index.js';
|
|
3
|
+
import { AzureFunctionApp } from '../function-app/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides a construct to create and deploy an Azure EventGrid Event Handler with Service Bus integration
|
|
6
|
+
* @example
|
|
7
|
+
* import { AzureEventHandler, AzureEventHandlerProps } from '@gradientedge/cdk-utils'
|
|
8
|
+
*
|
|
9
|
+
* class CustomConstruct extends AzureEventHandler {
|
|
10
|
+
* constructor(id: string, props: AzureEventHandlerProps) {
|
|
11
|
+
* super(id, props)
|
|
12
|
+
* this.props = props
|
|
13
|
+
* this.id = id
|
|
14
|
+
* this.initResources()
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
export class AzureEventHandler extends AzureFunctionApp {
|
|
19
|
+
props;
|
|
20
|
+
eventGridEventSubscription;
|
|
21
|
+
eventGridTopic;
|
|
22
|
+
serviceBus;
|
|
23
|
+
constructor(id, props) {
|
|
24
|
+
super(id, props);
|
|
25
|
+
this.props = props;
|
|
26
|
+
this.id = id;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @summary Initialise and provision resources
|
|
30
|
+
*/
|
|
31
|
+
initResources() {
|
|
32
|
+
this.createResourceGroup();
|
|
33
|
+
this.resolveCommonLogAnalyticsWorkspace();
|
|
34
|
+
this.resolveApplicationInsights();
|
|
35
|
+
this.createEventGridSubscriptionDlqStorageAccount();
|
|
36
|
+
this.createEventGridSubscriptionDlqStorageContainer();
|
|
37
|
+
this.createServiceBusNamespace();
|
|
38
|
+
this.createServiceBusQueue();
|
|
39
|
+
this.createEventGrid();
|
|
40
|
+
this.createEventGridEventSubscription();
|
|
41
|
+
this.createServiceBusDiagnosticLog();
|
|
42
|
+
this.enableMalwareScanningOnDataStorageAccount();
|
|
43
|
+
super.initResources();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @summary Method to create the dead-letter queue storage account for EventGrid subscriptions
|
|
47
|
+
*/
|
|
48
|
+
createEventGridSubscriptionDlqStorageAccount() {
|
|
49
|
+
this.eventGridEventSubscription.dlqStorageAccount = this.storageManager.createStorageAccount(`${this.id}-eventgrid-subscription-dlq-storage-account`, this, {
|
|
50
|
+
...this.props.eventGridSubscription.dlqStorageAccount,
|
|
51
|
+
resourceGroupName: this.resourceGroup.name,
|
|
52
|
+
location: this.resourceGroup.location,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @summary Method to create the dead-letter queue storage container for EventGrid subscriptions
|
|
57
|
+
*/
|
|
58
|
+
createEventGridSubscriptionDlqStorageContainer() {
|
|
59
|
+
this.eventGridEventSubscription.dlqStorageContainer = this.storageManager.createStorageContainer(`${this.id}-eventgrid-subscription-dlq-container`, this, {
|
|
60
|
+
...this.props.eventGridSubscription.dlqStorageContainer,
|
|
61
|
+
accountName: this.eventGridEventSubscription.dlqStorageAccount.name,
|
|
62
|
+
containerName: 'eventgrid-subscription-dlq-container',
|
|
63
|
+
resourceGroupName: this.resourceGroup.name,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @summary Method to create the Service Bus namespace
|
|
68
|
+
*/
|
|
69
|
+
createServiceBusNamespace() {
|
|
70
|
+
this.serviceBus.namespace = this.serviceBusManager.createServiceBusNamespace(this.id, this, {
|
|
71
|
+
...this.props.serviceBus.namespace,
|
|
72
|
+
namespaceName: this.props.serviceBus.namespace.namespaceName ?? this.id,
|
|
73
|
+
resourceGroupName: this.resourceGroup.name,
|
|
74
|
+
}, { ignoreChanges: ['location'] });
|
|
75
|
+
this.registerOutputs({
|
|
76
|
+
serviceBusNamespaceId: this.serviceBus.namespace.id,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @summary Method to create the Service Bus queue
|
|
81
|
+
*/
|
|
82
|
+
createServiceBusQueue() {
|
|
83
|
+
this.serviceBus.queue = this.serviceBusManager.createServiceBusQueue(this.id, this, {
|
|
84
|
+
...this.props.serviceBus.queue,
|
|
85
|
+
queueName: this.props.serviceBus.queue.queueName ?? this.id,
|
|
86
|
+
namespaceName: this.serviceBus.namespace.name,
|
|
87
|
+
});
|
|
88
|
+
this.registerOutputs({
|
|
89
|
+
serviceBusQueueId: this.serviceBus.queue.id,
|
|
90
|
+
serviceBusQueueName: this.serviceBus.queue.name,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @summary Method to create or resolve an existing EventGrid topic
|
|
95
|
+
*/
|
|
96
|
+
createEventGrid() {
|
|
97
|
+
if (!this.props.eventGridTopic.useExistingTopic) {
|
|
98
|
+
this.eventGridTopic = this.eventgridManager.createEventgridTopic(this.id, this, {
|
|
99
|
+
...this.props.eventGridTopic,
|
|
100
|
+
topicName: this.props.eventGridTopic.topicName ?? this.id,
|
|
101
|
+
location: this.resourceGroup.location,
|
|
102
|
+
resourceGroupName: this.resourceGroup.name,
|
|
103
|
+
}, { protect: true, ignoreChanges: ['location'] });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const existingSubscriptionId = this.props.eventGridTopic.existingSubscriptionId;
|
|
107
|
+
const existingTopicName = this.props.eventGridTopic.existingTopicName;
|
|
108
|
+
const existingResourceGroupName = this.props.eventGridTopic.existingResourceGroupName;
|
|
109
|
+
let provider;
|
|
110
|
+
if (existingSubscriptionId) {
|
|
111
|
+
provider = new Provider(`${this.id}-${existingSubscriptionId}`, {
|
|
112
|
+
subscriptionId: existingSubscriptionId,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (existingResourceGroupName && existingTopicName) {
|
|
116
|
+
this.eventGridTopic = getTopicOutput({
|
|
117
|
+
topicName: existingTopicName,
|
|
118
|
+
resourceGroupName: existingResourceGroupName,
|
|
119
|
+
}, { provider });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @summary Method to create the EventGrid event subscription with Service Bus queue destination
|
|
124
|
+
*/
|
|
125
|
+
createEventGridEventSubscription() {
|
|
126
|
+
this.eventGridEventSubscription.eventSubscription = this.eventgridManager.createEventgridSubscription(this.id, this, {
|
|
127
|
+
...this.props.eventGridEventSubscription,
|
|
128
|
+
eventSubscriptionName: this.props.eventGridEventSubscription.eventSubscriptionName ?? this.id,
|
|
129
|
+
scope: this.eventGridTopic.id,
|
|
130
|
+
destination: {
|
|
131
|
+
endpointType: 'ServiceBusQueue',
|
|
132
|
+
resourceId: this.serviceBus.queue.id,
|
|
133
|
+
},
|
|
134
|
+
deadLetterDestination: {
|
|
135
|
+
blobContainerName: this.eventGridEventSubscription.dlqStorageContainer.name,
|
|
136
|
+
endpointType: 'StorageBlob',
|
|
137
|
+
resourceId: this.eventGridEventSubscription.dlqStorageAccount.id,
|
|
138
|
+
},
|
|
139
|
+
}, { dependsOn: [this.eventGridTopic] });
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @summary Method to create diagnostic log settings for the Service Bus namespace
|
|
143
|
+
*/
|
|
144
|
+
createServiceBusDiagnosticLog() {
|
|
145
|
+
this.monitorManager.createMonitorDiagnosticSettings(this.id, this, {
|
|
146
|
+
name: `${this.props.stackName}-servicebus`,
|
|
147
|
+
resourceUri: this.serviceBus.namespace.id,
|
|
148
|
+
workspaceId: this.commonLogAnalyticsWorkspace.id,
|
|
149
|
+
logAnalyticsDestinationType: 'Dedicated',
|
|
150
|
+
logs: [
|
|
151
|
+
{
|
|
152
|
+
categoryGroup: 'allLogs',
|
|
153
|
+
enabled: true,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
metrics: [
|
|
157
|
+
{
|
|
158
|
+
category: 'AllMetrics',
|
|
159
|
+
enabled: true,
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* @summary Method to enable Microsoft Defender malware scanning on the data storage account
|
|
166
|
+
*/
|
|
167
|
+
enableMalwareScanningOnDataStorageAccount() {
|
|
168
|
+
if (!this.props.defender)
|
|
169
|
+
return;
|
|
170
|
+
this.securityCentermanager.createDefenderForStorage(`${this.id}-data-storage-defender`, this, {
|
|
171
|
+
...this.props.defender,
|
|
172
|
+
resourceId: this.dataStorageAccount.id,
|
|
173
|
+
properties: {
|
|
174
|
+
malwareScanning: {
|
|
175
|
+
scanResultsEventGridTopicResourceId: this.eventGridTopic.id,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EventSubscription } from '@pulumi/azure-native/eventgrid/index.js';
|
|
2
|
+
import { Namespace, Queue } from '@pulumi/azure-native/servicebus/index.js';
|
|
3
|
+
import { BlobContainer, StorageAccount } from '@pulumi/azure-native/storage/index.js';
|
|
4
|
+
import { DefenderForStorageProps, EventgridEventSubscriptionProps, EventgridTopicProps, ServiceBusNamespaceProps, ServiceBusQueueProps, StorageAccountProps, StorageContainerProps } from '../../services/index.js';
|
|
5
|
+
import { AzureFunctionAppProps } from '../function-app/index.js';
|
|
6
|
+
export interface EventHandlerEventGridSubscriptionProps {
|
|
7
|
+
dlqStorageAccount: StorageAccountProps;
|
|
8
|
+
dlqStorageContainer: StorageContainerProps;
|
|
9
|
+
}
|
|
10
|
+
export interface EventHandlerEventGridSubscription {
|
|
11
|
+
dlqStorageAccount: StorageAccount;
|
|
12
|
+
dlqStorageContainer: BlobContainer;
|
|
13
|
+
eventSubscription: EventSubscription;
|
|
14
|
+
}
|
|
15
|
+
export interface EventHandlerServiceBusProps {
|
|
16
|
+
namespace: ServiceBusNamespaceProps;
|
|
17
|
+
queue: ServiceBusQueueProps;
|
|
18
|
+
}
|
|
19
|
+
export interface EventHandlerServiceBus {
|
|
20
|
+
namespace: Namespace;
|
|
21
|
+
queue: Queue;
|
|
22
|
+
}
|
|
23
|
+
export interface EventHandlerEventGridTopicProps extends EventgridTopicProps {
|
|
24
|
+
useExistingTopic: boolean;
|
|
25
|
+
existingSubscriptionId?: string;
|
|
26
|
+
existingTopicName?: string;
|
|
27
|
+
existingResourceGroupName?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface AzureEventHandlerProps extends AzureFunctionAppProps {
|
|
30
|
+
defender?: DefenderForStorageProps;
|
|
31
|
+
eventGridEventSubscription: EventgridEventSubscriptionProps;
|
|
32
|
+
eventGridSubscription: EventHandlerEventGridSubscriptionProps;
|
|
33
|
+
eventGridTopic: EventHandlerEventGridTopicProps;
|
|
34
|
+
serviceBus: EventHandlerServiceBusProps;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as archive from '@pulumi/archive';
|
|
2
|
+
import { ConfigurationStore, GetConfigurationStoreResult } from '@pulumi/azure-native/appconfiguration/index.js';
|
|
3
|
+
import { GetComponentResult } from '@pulumi/azure-native/applicationinsights/index.js';
|
|
4
|
+
import { Dashboard } from '@pulumi/azure-native/portal/index.js';
|
|
5
|
+
import { BlobContainer, StorageAccount } from '@pulumi/azure-native/storage/index.js';
|
|
6
|
+
import { AppServicePlan, WebApp } from '@pulumi/azure-native/web/index.js';
|
|
7
|
+
import { Output, ResourceOptions } from '@pulumi/pulumi';
|
|
8
|
+
import { CommonAzureConstruct } from '../../common/index.js';
|
|
9
|
+
import { AzureFunctionAppProps } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* @classdesc Provides a construct to create and deploy an Azure Function App with Flex Consumption hosting
|
|
12
|
+
* @example
|
|
13
|
+
* import { AzureFunctionApp, AzureFunctionAppProps } from '@gradientedge/cdk-utils'
|
|
14
|
+
*
|
|
15
|
+
* class CustomConstruct extends AzureFunctionApp {
|
|
16
|
+
* constructor(id: string, props: AzureFunctionAppProps) {
|
|
17
|
+
* super(id, props)
|
|
18
|
+
* this.props = props
|
|
19
|
+
* this.id = id
|
|
20
|
+
* this.initResources()
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
export declare class AzureFunctionApp extends CommonAzureConstruct {
|
|
25
|
+
props: AzureFunctionAppProps;
|
|
26
|
+
app: WebApp;
|
|
27
|
+
appServicePlan: AppServicePlan;
|
|
28
|
+
appEnvironmentVariables: Record<string, any>;
|
|
29
|
+
appStorageAccount: StorageAccount;
|
|
30
|
+
appDeploymentStorageContainer: BlobContainer;
|
|
31
|
+
appStorageContainer: BlobContainer;
|
|
32
|
+
appConfig: ConfigurationStore | Output<GetConfigurationStoreResult>;
|
|
33
|
+
appCodeArchiveFile: Output<archive.GetFileResult>;
|
|
34
|
+
appConfigHash: string;
|
|
35
|
+
appKeyVaultsByResourceGroup: Map<string, Set<string>>;
|
|
36
|
+
appConnectionStrings: any[];
|
|
37
|
+
appConfigPrefix?: string;
|
|
38
|
+
appConfigurationsParsedConfig: any;
|
|
39
|
+
appConfigurationsOriginalParsedConfig: any;
|
|
40
|
+
dataStorageAccount: StorageAccount;
|
|
41
|
+
dataStorageContainer: BlobContainer;
|
|
42
|
+
applicationInsights: Output<GetComponentResult>;
|
|
43
|
+
functionDashboard: Dashboard;
|
|
44
|
+
constructor(id: string, props: AzureFunctionAppProps);
|
|
45
|
+
/**
|
|
46
|
+
* @summary Initialise and provision resources
|
|
47
|
+
*/
|
|
48
|
+
initResources(): void;
|
|
49
|
+
/**
|
|
50
|
+
* @summary Method to resolve the Application Insights instance
|
|
51
|
+
*/
|
|
52
|
+
protected resolveApplicationInsights(): void;
|
|
53
|
+
/**
|
|
54
|
+
* @summary Method to create the App Service Plan for the function app
|
|
55
|
+
*/
|
|
56
|
+
protected createAppServicePlan(): void;
|
|
57
|
+
/**
|
|
58
|
+
* @summary Method to create parsed app configurations
|
|
59
|
+
* - To be implemented in the overriding method in the implementation class
|
|
60
|
+
*/
|
|
61
|
+
protected createdParsedAppConfigurations(): void;
|
|
62
|
+
/**
|
|
63
|
+
* @summary Method to create or resolve the App Configuration store
|
|
64
|
+
*/
|
|
65
|
+
protected createAppConfiguration(): void;
|
|
66
|
+
/**
|
|
67
|
+
* @summary Method to create app configurations
|
|
68
|
+
* - To be implemented in the overriding method in the implementation class
|
|
69
|
+
*/
|
|
70
|
+
protected createAppConfigurations(): void;
|
|
71
|
+
/**
|
|
72
|
+
* @summary Method to create the storage account for the function app
|
|
73
|
+
*/
|
|
74
|
+
protected createStorageAccount(): void;
|
|
75
|
+
/**
|
|
76
|
+
* @summary Method to create the storage deployment container for the function app
|
|
77
|
+
*/
|
|
78
|
+
protected createStorageDeploymentContainer(): void;
|
|
79
|
+
/**
|
|
80
|
+
* @summary Method to create the storage container for the function app
|
|
81
|
+
*/
|
|
82
|
+
protected createStorageContainer(): void;
|
|
83
|
+
/**
|
|
84
|
+
* @summary Method to create the data storage account
|
|
85
|
+
*/
|
|
86
|
+
protected createDataStorageAccount(): void;
|
|
87
|
+
/**
|
|
88
|
+
* @summary Method to create the data storage container
|
|
89
|
+
*/
|
|
90
|
+
protected createDataStorageContainer(): void;
|
|
91
|
+
/**
|
|
92
|
+
* @summary Method to generate a SAS token for the storage container and store it in Key Vault
|
|
93
|
+
*/
|
|
94
|
+
protected generateStorageContainerSas(): void;
|
|
95
|
+
/**
|
|
96
|
+
* @summary Method to create and configure the function host.json
|
|
97
|
+
*/
|
|
98
|
+
protected createFunctionHosts(): void;
|
|
99
|
+
/**
|
|
100
|
+
* @summary Method to create the code package archive for deployment
|
|
101
|
+
*/
|
|
102
|
+
protected createCodePackage(): void;
|
|
103
|
+
/**
|
|
104
|
+
* @summary Method to create the function app site configuration
|
|
105
|
+
* - To be implemented in the overriding method in the implementation class
|
|
106
|
+
*/
|
|
107
|
+
protected createFunctionAppSiteConfig(): void;
|
|
108
|
+
/**
|
|
109
|
+
* @summary Method to create the Azure Function App with Flex Consumption hosting
|
|
110
|
+
*/
|
|
111
|
+
protected createFunctionApp(resourceOptions?: ResourceOptions): void;
|
|
112
|
+
/**
|
|
113
|
+
* @summary Method to get the function app managed identity principal ID
|
|
114
|
+
*/
|
|
115
|
+
protected getFunctionAppPrincipalId(): Output<string>;
|
|
116
|
+
/**
|
|
117
|
+
* @summary Method to create role assignments for the function app identity
|
|
118
|
+
*/
|
|
119
|
+
protected createRoleAssignments(): void;
|
|
120
|
+
/**
|
|
121
|
+
* @summary Method to get the dashboard template variables
|
|
122
|
+
*/
|
|
123
|
+
protected dashboardVariables(): Record<string, any>;
|
|
124
|
+
/**
|
|
125
|
+
* @summary Method to create the Azure Portal dashboard for the function app
|
|
126
|
+
*/
|
|
127
|
+
protected createFunctionDashboard(): void;
|
|
128
|
+
}
|