@gradientedge/cdk-utils 10.1.0 → 10.2.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/src/lib/azure/common/constants.d.ts +3 -2
- package/dist/src/lib/azure/common/constants.js +2 -1
- package/dist/src/lib/azure/common/construct.d.ts +26 -12
- package/dist/src/lib/azure/common/construct.js +31 -45
- package/dist/src/lib/azure/common/resource-name-formatter.d.ts +9 -4
- package/dist/src/lib/azure/common/resource-name-formatter.js +9 -5
- package/dist/src/lib/azure/common/stack.d.ts +18 -32
- package/dist/src/lib/azure/common/stack.js +77 -74
- package/dist/src/lib/azure/common/tagging.d.ts +29 -8
- package/dist/src/lib/azure/common/tagging.js +72 -26
- package/dist/src/lib/azure/common/types.d.ts +19 -4
- package/dist/src/lib/azure/services/api-management/main.d.ts +29 -32
- package/dist/src/lib/azure/services/api-management/main.js +100 -121
- package/dist/src/lib/azure/services/api-management/types.d.ts +33 -18
- package/dist/src/lib/azure/services/app-configuration/main.d.ts +6 -7
- package/dist/src/lib/azure/services/app-configuration/main.js +23 -26
- package/dist/src/lib/azure/services/app-configuration/types.d.ts +2 -2
- package/dist/src/lib/azure/services/app-service/main.d.ts +10 -12
- package/dist/src/lib/azure/services/app-service/main.js +37 -49
- package/dist/src/lib/azure/services/app-service/types.d.ts +4 -4
- package/dist/src/lib/azure/services/application-insights/main.d.ts +7 -8
- package/dist/src/lib/azure/services/application-insights/main.js +20 -26
- package/dist/src/lib/azure/services/application-insights/types.d.ts +2 -4
- package/dist/src/lib/azure/services/cosmosdb/main.d.ts +12 -15
- package/dist/src/lib/azure/services/cosmosdb/main.js +42 -61
- package/dist/src/lib/azure/services/cosmosdb/types.d.ts +4 -6
- package/dist/src/lib/azure/services/dns/main.d.ts +13 -17
- package/dist/src/lib/azure/services/dns/main.js +33 -51
- package/dist/src/lib/azure/services/dns/types.d.ts +5 -8
- package/dist/src/lib/azure/services/eventgrid/main.d.ts +20 -22
- package/dist/src/lib/azure/services/eventgrid/main.js +61 -89
- package/dist/src/lib/azure/services/eventgrid/types.d.ts +7 -8
- package/dist/src/lib/azure/services/function/main.d.ts +15 -15
- package/dist/src/lib/azure/services/function/main.js +54 -59
- package/dist/src/lib/azure/services/function/types.d.ts +18 -6
- package/dist/src/lib/azure/services/index.d.ts +1 -1
- package/dist/src/lib/azure/services/index.js +1 -1
- package/dist/src/lib/azure/services/key-vault/main.d.ts +6 -7
- package/dist/src/lib/azure/services/key-vault/main.js +29 -28
- package/dist/src/lib/azure/services/key-vault/types.d.ts +3 -2
- package/dist/src/lib/azure/services/monitor/main.d.ts +7 -8
- package/dist/src/lib/azure/services/monitor/main.js +10 -15
- package/dist/src/lib/azure/services/monitor/types.d.ts +2 -2
- package/dist/src/lib/azure/services/operational-insights/main.d.ts +29 -0
- package/dist/src/lib/azure/services/operational-insights/main.js +50 -0
- package/dist/src/lib/azure/services/operational-insights/types.d.ts +3 -0
- package/dist/src/lib/azure/services/redis/main.d.ts +8 -9
- package/dist/src/lib/azure/services/redis/main.js +24 -26
- package/dist/src/lib/azure/services/redis/types.d.ts +2 -2
- package/dist/src/lib/azure/services/resource-group/main.d.ts +6 -7
- package/dist/src/lib/azure/services/resource-group/main.js +9 -14
- package/dist/src/lib/azure/services/resource-group/types.d.ts +2 -2
- package/dist/src/lib/azure/services/servicebus/main.d.ts +17 -22
- package/dist/src/lib/azure/services/servicebus/main.js +47 -70
- package/dist/src/lib/azure/services/servicebus/types.d.ts +6 -10
- package/dist/src/lib/azure/services/storage/main.d.ts +24 -27
- package/dist/src/lib/azure/services/storage/main.js +70 -88
- package/dist/src/lib/azure/services/storage/types.d.ts +10 -8
- package/dist/src/lib/azure/types/index.d.ts +2 -1
- package/dist/src/lib/azure/utils/index.d.ts +19 -3
- package/dist/src/lib/azure/utils/index.js +19 -13
- package/dist/src/lib/cloudflare/common/stack.js +1 -1
- package/package.json +2 -1
- package/src/lib/azure/common/constants.ts +2 -1
- package/src/lib/azure/common/construct.ts +32 -48
- package/src/lib/azure/common/resource-name-formatter.ts +10 -6
- package/src/lib/azure/common/stack.ts +78 -78
- package/src/lib/azure/common/tagging.ts +78 -29
- package/src/lib/azure/common/types.ts +21 -4
- package/src/lib/azure/services/api-management/main.ts +172 -169
- package/src/lib/azure/services/api-management/types.ts +39 -16
- package/src/lib/azure/services/app-configuration/main.ts +33 -31
- package/src/lib/azure/services/app-configuration/types.ts +2 -2
- package/src/lib/azure/services/app-service/main.ts +61 -62
- package/src/lib/azure/services/app-service/types.ts +4 -4
- package/src/lib/azure/services/application-insights/main.ts +29 -30
- package/src/lib/azure/services/application-insights/types.ts +2 -5
- package/src/lib/azure/services/cosmosdb/main.ts +78 -77
- package/src/lib/azure/services/cosmosdb/types.ts +10 -6
- package/src/lib/azure/services/dns/main.ts +65 -72
- package/src/lib/azure/services/dns/types.ts +9 -9
- package/src/lib/azure/services/eventgrid/main.ts +120 -122
- package/src/lib/azure/services/eventgrid/types.ts +13 -8
- package/src/lib/azure/services/function/main.ts +75 -72
- package/src/lib/azure/services/function/types.ts +21 -6
- package/src/lib/azure/services/index.ts +1 -1
- package/src/lib/azure/services/key-vault/main.ts +38 -32
- package/src/lib/azure/services/key-vault/types.ts +4 -2
- package/src/lib/azure/services/monitor/main.ts +17 -21
- package/src/lib/azure/services/monitor/types.ts +2 -2
- package/src/lib/azure/services/operational-insights/main.ts +61 -0
- package/src/lib/azure/services/operational-insights/types.ts +3 -0
- package/src/lib/azure/services/redis/main.ts +30 -30
- package/src/lib/azure/services/redis/types.ts +2 -2
- package/src/lib/azure/services/resource-group/main.ts +20 -20
- package/src/lib/azure/services/resource-group/types.ts +2 -2
- package/src/lib/azure/services/servicebus/main.ts +103 -94
- package/src/lib/azure/services/servicebus/types.ts +17 -11
- package/src/lib/azure/services/storage/main.ts +113 -114
- package/src/lib/azure/services/storage/types.ts +16 -8
- package/src/lib/azure/types/index.ts +2 -1
- package/src/lib/azure/utils/index.ts +20 -22
- package/src/lib/cloudflare/common/stack.ts +1 -1
- package/dist/src/lib/azure/services/log-analytics-workspace/main.d.ts +0 -30
- package/dist/src/lib/azure/services/log-analytics-workspace/main.js +0 -55
- package/dist/src/lib/azure/services/log-analytics-workspace/types.d.ts +0 -3
- package/src/lib/azure/services/log-analytics-workspace/main.ts +0 -61
- package/src/lib/azure/services/log-analytics-workspace/types.ts +0 -3
- /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.d.ts +0 -0
- /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.js +0 -0
- /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/types.js +0 -0
- /package/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.ts +0 -0
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
AppServicePlan,
|
|
3
|
+
ManagedServiceIdentityType,
|
|
4
|
+
SupportedTlsVersions,
|
|
5
|
+
WebApp,
|
|
6
|
+
} from '@pulumi/azure-native/web/index.js'
|
|
4
7
|
import { CommonAzureConstruct } from '../../common/index.js'
|
|
5
|
-
import { createAzureTfOutput } from '../../utils/index.js'
|
|
6
8
|
import { LinuxWebAppProps, ServicePlanProps } from './types.js'
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
* @classdesc Provides operations on Azure App Service
|
|
11
|
+
* @classdesc Provides operations on Azure App Service using Pulumi
|
|
10
12
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
11
13
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
12
14
|
* @example
|
|
13
|
-
* ```
|
|
15
|
+
* ```typescript
|
|
14
16
|
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
15
17
|
*
|
|
16
18
|
* class CustomConstruct extends CommonAzureConstruct {
|
|
17
|
-
* constructor(
|
|
18
|
-
* super(
|
|
19
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
20
|
+
* super(name, props)
|
|
19
21
|
* this.props = props
|
|
20
|
-
* this.appServiceManager.
|
|
22
|
+
* this.appServiceManager.createAppServicePlan('MyAppService', this, props)
|
|
21
23
|
* }
|
|
22
24
|
* }
|
|
23
25
|
* ```
|
|
@@ -28,78 +30,75 @@ export class AzureAppServiceManager {
|
|
|
28
30
|
* @param id scoped id of the resource
|
|
29
31
|
* @param scope scope in which this resource is defined
|
|
30
32
|
* @param props app service plan properties
|
|
31
|
-
* @see [
|
|
33
|
+
* @see [Pulumi Azure Native App Service Plan]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/web/appserviceplan/}
|
|
32
34
|
*/
|
|
33
35
|
public createAppServicePlan(id: string, scope: CommonAzureConstruct, props: ServicePlanProps) {
|
|
34
36
|
if (!props) throw `Props undefined for ${id}`
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
38
|
+
// Get resource group name
|
|
39
|
+
const resourceGroupName = scope.props.resourceGroupName
|
|
40
|
+
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
41
|
+
: props.resourceGroupName
|
|
41
42
|
|
|
42
|
-
if (!
|
|
43
|
+
if (!resourceGroupName) throw `Resource group name undefined for ${id}`
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
return new AppServicePlan(
|
|
46
|
+
`${id}-as`,
|
|
47
|
+
{
|
|
48
|
+
...props,
|
|
49
|
+
name: scope.resourceNameFormatter.format(
|
|
50
|
+
props.name?.toString(),
|
|
51
|
+
scope.props.resourceNameOptions?.appServicePlan
|
|
52
|
+
),
|
|
53
|
+
resourceGroupName: resourceGroupName,
|
|
54
|
+
location: props.location ?? scope.props.location,
|
|
55
|
+
tags: props.tags ?? {
|
|
56
|
+
environment: scope.props.stage,
|
|
57
|
+
},
|
|
50
58
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
createAzureTfOutput(`${id}-appServicePlanName`, scope, appServicePlan.name)
|
|
54
|
-
createAzureTfOutput(`${id}-appServicePlanFriendlyUniqueId`, scope, appServicePlan.friendlyUniqueId)
|
|
55
|
-
createAzureTfOutput(`${id}-appServicePlanId`, scope, appServicePlan.id)
|
|
56
|
-
|
|
57
|
-
return appServicePlan
|
|
59
|
+
{ parent: scope }
|
|
60
|
+
)
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
/**
|
|
61
|
-
* @summary Method to create a new web app
|
|
64
|
+
* @summary Method to create a new Linux web app
|
|
62
65
|
* @param id scoped id of the resource
|
|
63
66
|
* @param scope scope in which this resource is defined
|
|
64
67
|
* @param props web app properties
|
|
65
|
-
* @see [
|
|
68
|
+
* @see [Pulumi Azure Native Web App]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/web/webapp/}
|
|
66
69
|
*/
|
|
67
70
|
public createLinuxWebApp(id: string, scope: CommonAzureConstruct, props: LinuxWebAppProps) {
|
|
68
71
|
if (!props) throw `Props undefined for ${id}`
|
|
69
72
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
73
|
+
// Get resource group name
|
|
74
|
+
const resourceGroupName = scope.props.resourceGroupName
|
|
75
|
+
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
76
|
+
: props.resourceGroupName
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
...props,
|
|
80
|
-
name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.linuxWebApp),
|
|
81
|
-
resourceGroupName: resourceGroup.name,
|
|
82
|
-
httpsOnly: props.httpsOnly ?? true,
|
|
78
|
+
if (!resourceGroupName) throw `Resource group name undefined for ${id}`
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
return new WebApp(
|
|
81
|
+
`${id}-lwa`,
|
|
82
|
+
{
|
|
83
|
+
...props,
|
|
84
|
+
name: scope.resourceNameFormatter.format(props.name?.toString(), scope.props.resourceNameOptions?.linuxWebApp),
|
|
85
|
+
resourceGroupName: resourceGroupName,
|
|
86
|
+
location: props.location ?? scope.props.location,
|
|
87
|
+
httpsOnly: props.httpsOnly ?? true,
|
|
88
|
+
kind: props.kind ?? 'app,linux',
|
|
89
|
+
identity: props.identity ?? {
|
|
90
|
+
type: ManagedServiceIdentityType.SystemAssigned,
|
|
91
|
+
},
|
|
92
|
+
siteConfig: props.siteConfig ?? {
|
|
93
|
+
alwaysOn: true,
|
|
94
|
+
linuxFxVersion: 'NODE|22-lts',
|
|
95
|
+
minTlsVersion: SupportedTlsVersions.SupportedTlsVersions_1_3,
|
|
96
|
+
},
|
|
97
|
+
tags: props.tags ?? {
|
|
98
|
+
environment: scope.props.stage,
|
|
99
|
+
},
|
|
86
100
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
alwaysOn: props.siteConfig.alwaysOn ?? true,
|
|
90
|
-
applicationStack: props.siteConfig.applicationStack ?? { nodeVersion: '22-lts' },
|
|
91
|
-
minimumTlsVersion: props.siteConfig.minimumTlsVersion ?? '1.3',
|
|
92
|
-
},
|
|
93
|
-
tags: props.tags ?? {
|
|
94
|
-
environment: scope.props.stage,
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
createAzureTfOutput(`${id}-linuxWebAppName`, scope, linuxWebApp.name)
|
|
99
|
-
createAzureTfOutput(`${id}-linuxWebAppFriendlyUniqueId`, scope, linuxWebApp.friendlyUniqueId)
|
|
100
|
-
createAzureTfOutput(`${id}-linuxWebAppId`, scope, linuxWebApp.id)
|
|
101
|
-
createAzureTfOutput(`${id}-linuxWebAppDefaultHostname`, scope, linuxWebApp.defaultHostname)
|
|
102
|
-
|
|
103
|
-
return linuxWebApp
|
|
101
|
+
{ parent: scope }
|
|
102
|
+
)
|
|
104
103
|
}
|
|
105
104
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AppServicePlanArgs } from '@pulumi/azure-native/web/index.js'
|
|
2
|
+
import { WebAppArgs } from '@pulumi/azure-native/web/index.js'
|
|
3
3
|
|
|
4
|
-
export interface ServicePlanProps extends
|
|
4
|
+
export interface ServicePlanProps extends AppServicePlanArgs {}
|
|
5
5
|
|
|
6
|
-
export interface LinuxWebAppProps extends
|
|
6
|
+
export interface LinuxWebAppProps extends WebAppArgs {}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js'
|
|
1
|
+
import { ApplicationType, Component } from '@pulumi/azure-native/applicationinsights/index.js'
|
|
3
2
|
import { CommonAzureConstruct } from '../../common/index.js'
|
|
4
|
-
import { createAzureTfOutput } from '../../utils/index.js'
|
|
5
3
|
import { ApplicationInsightsProps } from './types.js'
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
|
-
* @classdesc Provides operations on Azure Application Insights
|
|
6
|
+
* @classdesc Provides operations on Azure Application Insights using Pulumi
|
|
9
7
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
10
8
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
11
9
|
* @example
|
|
12
|
-
* ```
|
|
10
|
+
* ```typescript
|
|
13
11
|
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
14
12
|
*
|
|
15
13
|
* class CustomConstruct extends CommonAzureConstruct {
|
|
16
|
-
* constructor(
|
|
17
|
-
* super(
|
|
14
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
15
|
+
* super(name, props)
|
|
18
16
|
* this.props = props
|
|
19
|
-
* this.
|
|
17
|
+
* this.applicationInsightsManager.createApplicationInsights('MyApplicationInsights', this, props)
|
|
20
18
|
* }
|
|
21
19
|
* }
|
|
22
20
|
* ```
|
|
@@ -27,33 +25,34 @@ export class AzureApplicationInsightsManager {
|
|
|
27
25
|
* @param id scoped id of the resource
|
|
28
26
|
* @param scope scope in which this resource is defined
|
|
29
27
|
* @param props application insights properties
|
|
30
|
-
* @see [
|
|
28
|
+
* @see [Pulumi Azure Native Application Insights Component]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/insights/component/}
|
|
31
29
|
*/
|
|
32
|
-
public
|
|
30
|
+
public createComponent(id: string, scope: CommonAzureConstruct, props: ApplicationInsightsProps) {
|
|
33
31
|
if (!props) throw `Props undefined for ${id}`
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
33
|
+
// Get resource group name
|
|
34
|
+
const resourceGroupName = scope.props.resourceGroupName
|
|
35
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
36
|
+
: props.resourceGroupName
|
|
40
37
|
|
|
41
|
-
if (!
|
|
38
|
+
if (!resourceGroupName) throw `Resource group name undefined for ${id}`
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
return new Component(
|
|
41
|
+
`${id}-ai`,
|
|
42
|
+
{
|
|
43
|
+
...props,
|
|
44
|
+
resourceName: scope.resourceNameFormatter.format(
|
|
45
|
+
props.resourceName?.toString(),
|
|
46
|
+
scope.props.resourceNameOptions?.applicationInsights
|
|
47
|
+
),
|
|
48
|
+
resourceGroupName: resourceGroupName,
|
|
49
|
+
applicationType: (props.applicationType as any) ?? ApplicationType.Web,
|
|
50
|
+
kind: props.kind ?? 'web',
|
|
51
|
+
tags: props.tags ?? {
|
|
52
|
+
environment: scope.props.stage,
|
|
53
|
+
},
|
|
50
54
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
createAzureTfOutput(`${id}-applicationInsightsName`, scope, applicationInsights.name)
|
|
54
|
-
createAzureTfOutput(`${id}-applicationInsightsFriendlyUniqueId`, scope, applicationInsights.friendlyUniqueId)
|
|
55
|
-
createAzureTfOutput(`${id}-applicationInsightsId`, scope, applicationInsights.id)
|
|
56
|
-
|
|
57
|
-
return applicationInsights
|
|
55
|
+
{ parent: scope }
|
|
56
|
+
)
|
|
58
57
|
}
|
|
59
58
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentArgs } from '@pulumi/azure-native/applicationinsights/index.js'
|
|
2
2
|
|
|
3
|
-
export interface ApplicationInsightsProps extends
|
|
4
|
-
name?: string | undefined
|
|
5
|
-
applicationType?: string | undefined
|
|
6
|
-
}
|
|
3
|
+
export interface ApplicationInsightsProps extends ComponentArgs {}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
DatabaseAccount,
|
|
3
|
+
ResourceIdentityType,
|
|
4
|
+
SqlResourceSqlContainer,
|
|
5
|
+
SqlResourceSqlDatabase,
|
|
6
|
+
} from '@pulumi/azure-native/cosmosdb/index.js'
|
|
5
7
|
import { CommonAzureConstruct } from '../../common/index.js'
|
|
6
|
-
import { createAzureTfOutput } from '../../utils/index.js'
|
|
7
8
|
import { CosmosdbAccountProps, CosmosdbSqlContainerProps, CosmosdbSqlDatabaseProps } from './types.js'
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* @classdesc Provides operations on Azure CosmosDB
|
|
11
|
+
* @classdesc Provides operations on Azure CosmosDB using Pulumi
|
|
11
12
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
12
13
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
13
14
|
* @example
|
|
14
|
-
* ```
|
|
15
|
+
* ```typescript
|
|
15
16
|
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
16
17
|
*
|
|
17
18
|
* class CustomConstruct extends CommonAzureConstruct {
|
|
18
|
-
* constructor(
|
|
19
|
-
* super(
|
|
19
|
+
* constructor(name: string, props: CommonAzureStackProps) {
|
|
20
|
+
* super(name, props)
|
|
20
21
|
* this.props = props
|
|
21
|
-
* this.CosmosDbManager.
|
|
22
|
+
* this.CosmosDbManager.createCosmosDbAccount('MyCosmosDb', this, props)
|
|
22
23
|
* }
|
|
23
24
|
* }
|
|
24
25
|
* ```
|
|
@@ -29,68 +30,68 @@ export class AzureCosmosDbManager {
|
|
|
29
30
|
* @param id scoped id of the resource
|
|
30
31
|
* @param scope scope in which this resource is defined
|
|
31
32
|
* @param props cosmosdb account properties
|
|
32
|
-
* @see [
|
|
33
|
+
* @see [Pulumi Azure Native CosmosDB Account]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/databaseaccount/}
|
|
33
34
|
*/
|
|
34
35
|
public createCosmosDbAccount(id: string, scope: CommonAzureConstruct, props: CosmosdbAccountProps) {
|
|
35
36
|
if (!props) throw `Props undefined for ${id}`
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
// Get resource group name
|
|
39
|
+
const resourceGroupName = scope.props.resourceGroupName
|
|
40
|
+
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
41
|
+
: props.resourceGroupName
|
|
42
|
+
|
|
43
|
+
if (!resourceGroupName) throw `Resource group name undefined for ${id}`
|
|
44
|
+
|
|
45
|
+
return new DatabaseAccount(
|
|
46
|
+
`${id}-ca`,
|
|
47
|
+
{
|
|
48
|
+
...props,
|
|
49
|
+
accountName: scope.resourceNameFormatter.format(
|
|
50
|
+
props.accountName?.toString(),
|
|
51
|
+
scope.props.resourceNameOptions?.cosmosDbAccount
|
|
52
|
+
),
|
|
53
|
+
location: props.location ?? scope.props.location,
|
|
54
|
+
resourceGroupName: resourceGroupName,
|
|
55
|
+
tags: props.tags ?? {
|
|
56
|
+
environment: scope.props.stage,
|
|
57
|
+
},
|
|
58
|
+
identity: props.identity ?? {
|
|
59
|
+
type: ResourceIdentityType.SystemAssigned,
|
|
60
|
+
},
|
|
52
61
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
createAzureTfOutput(`${id}-cosmosdbAccountName`, scope, cosmosdbAccount.name)
|
|
59
|
-
createAzureTfOutput(`${id}-cosmosdbAccountFriendlyUniqueId`, scope, cosmosdbAccount.friendlyUniqueId)
|
|
60
|
-
createAzureTfOutput(`${id}-cosmosdbAccountId`, scope, cosmosdbAccount.id)
|
|
61
|
-
|
|
62
|
-
return cosmosdbAccount
|
|
62
|
+
{ parent: scope }
|
|
63
|
+
)
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* @summary Method to create a new cosmosdb database
|
|
67
68
|
* @param id scoped id of the resource
|
|
68
69
|
* @param scope scope in which this resource is defined
|
|
69
|
-
* @param props cosmosdb
|
|
70
|
-
* @see [
|
|
70
|
+
* @param props cosmosdb database properties
|
|
71
|
+
* @see [Pulumi Azure Native CosmosDB SQL Database]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqldatabase/}
|
|
71
72
|
*/
|
|
72
73
|
public createCosmosDbDatabase(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlDatabaseProps) {
|
|
73
74
|
if (!props) throw `Props undefined for ${id}`
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
76
|
+
// Get resource group name
|
|
77
|
+
const resourceGroupName = scope.props.resourceGroupName
|
|
78
|
+
? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
|
|
79
|
+
: props.resourceGroupName
|
|
80
|
+
|
|
81
|
+
if (!resourceGroupName) throw `Resource group name undefined for ${id}`
|
|
82
|
+
|
|
83
|
+
return new SqlResourceSqlDatabase(
|
|
84
|
+
`${id}-cd`,
|
|
85
|
+
{
|
|
86
|
+
...props,
|
|
87
|
+
databaseName: scope.resourceNameFormatter.format(
|
|
88
|
+
props.databaseName?.toString(),
|
|
89
|
+
scope.props.resourceNameOptions?.cosmosDbSqlDatabase
|
|
90
|
+
),
|
|
91
|
+
resourceGroupName: resourceGroupName,
|
|
92
|
+
},
|
|
93
|
+
{ parent: scope }
|
|
94
|
+
)
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
/**
|
|
@@ -98,29 +99,29 @@ export class AzureCosmosDbManager {
|
|
|
98
99
|
* @param id scoped id of the resource
|
|
99
100
|
* @param scope scope in which this resource is defined
|
|
100
101
|
* @param props cosmosdb container properties
|
|
101
|
-
* @see [
|
|
102
|
+
* @see [Pulumi Azure Native CosmosDB SQL Container]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqlcontainer/}
|
|
102
103
|
*/
|
|
103
104
|
public createCosmosDbContainer(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlContainerProps) {
|
|
104
105
|
if (!props) throw `Props undefined for ${id}`
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
// Get resource group name
|
|
108
|
+
const resourceGroupName = scope.props.resourceGroupName
|
|
109
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
110
|
+
: props.resourceGroupName
|
|
111
|
+
|
|
112
|
+
if (!resourceGroupName) throw `Resource group name undefined for ${id}`
|
|
113
|
+
|
|
114
|
+
return new SqlResourceSqlContainer(
|
|
115
|
+
`${id}-cc`,
|
|
116
|
+
{
|
|
117
|
+
...props,
|
|
118
|
+
containerName: scope.resourceNameFormatter.format(
|
|
119
|
+
props.containerName?.toString(),
|
|
120
|
+
scope.props.resourceNameOptions?.cosmosDbSqlContainer
|
|
121
|
+
),
|
|
122
|
+
resourceGroupName: resourceGroupName,
|
|
123
|
+
},
|
|
124
|
+
{ parent: scope }
|
|
125
|
+
)
|
|
125
126
|
}
|
|
126
127
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
DatabaseAccountArgs,
|
|
3
|
+
SqlResourceSqlContainerArgs,
|
|
4
|
+
SqlResourceSqlDatabaseArgs,
|
|
5
|
+
} from '@pulumi/azure-native/cosmosdb/index.js'
|
|
4
6
|
|
|
5
|
-
export interface CosmosdbAccountProps extends
|
|
6
|
-
|
|
7
|
-
export interface
|
|
7
|
+
export interface CosmosdbAccountProps extends DatabaseAccountArgs {}
|
|
8
|
+
|
|
9
|
+
export interface CosmosdbSqlDatabaseProps extends SqlResourceSqlDatabaseArgs {}
|
|
10
|
+
|
|
11
|
+
export interface CosmosdbSqlContainerProps extends SqlResourceSqlContainerArgs {}
|