-
Notifications
You must be signed in to change notification settings - Fork 880
/
index.ts
99 lines (85 loc) · 3.3 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
import * as pulumi from "@pulumi/pulumi";
import * as random from "@pulumi/random";
import * as authorization from "@pulumi/azure-native/authorization";
import * as resources from "@pulumi/azure-native/resources";
import * as storage from "@pulumi/azure-native/storage";
import * as synapse from "@pulumi/azure-native/synapse";
const resourceGroup = new resources.ResourceGroup("synapse-rg");
const storageAccount = new storage.StorageAccount("synapsesa", {
resourceGroupName: resourceGroup.name,
accessTier: storage.AccessTier.Hot,
enableHttpsTrafficOnly: true,
isHnsEnabled: true,
kind: storage.Kind.StorageV2,
sku: {
name: storage.SkuName.Standard_RAGRS,
},
});
const users = new storage.BlobContainer("users", {
resourceGroupName: resourceGroup.name,
accountName: storageAccount.name,
publicAccess: "None",
});
const dataLakeStorageAccountUrl = pulumi.interpolate`https://${storageAccount.name}.dfs.core.windows.net`;
const workspace = new synapse.Workspace("my-workspace", {
resourceGroupName: resourceGroup.name,
defaultDataLakeStorage: {
accountUrl: dataLakeStorageAccountUrl,
filesystem: "users",
},
identity: {
type: synapse.ResourceIdentityType.SystemAssigned,
},
sqlAdministratorLogin: "sqladminuser",
sqlAdministratorLoginPassword: new random.RandomPassword("workspacePwd", {length: 12 }).result,
});
const firewallRule = new synapse.IpFirewallRule("allowAll", {
resourceGroupName: resourceGroup.name,
workspaceName: workspace.name,
endIpAddress: "255.255.255.255",
startIpAddress: "0.0.0.0",
});
const subscriptionId = resourceGroup.id.apply(id => id.split("/")[2]);
const roleDefinitionId = pulumi.interpolate`/subscriptions/${subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe`;
const storageAccess = new authorization.RoleAssignment("storageAccess", {
roleAssignmentName: new random.RandomUuid("roleName").result,
scope: storageAccount.id,
principalId: workspace.identity.apply(i => i?.principalId).apply(id => id || "<preview>"),
principalType: authorization.PrincipalType.ServicePrincipal,
roleDefinitionId: roleDefinitionId,
});
const clientConfig = pulumi.output(authorization.getClientConfig());
const userAccess = new authorization.RoleAssignment("userAccess", {
roleAssignmentName: new random.RandomUuid("userRoleName").result,
scope: storageAccount.id,
principalId: clientConfig.objectId,
principalType: authorization.PrincipalType.User,
roleDefinitionId: roleDefinitionId,
});
const sqlPool = new synapse.SqlPool("SQLPOOL1", {
resourceGroupName: resourceGroup.name,
workspaceName: workspace.name,
collation: "SQL_Latin1_General_CP1_CI_AS",
createMode: "Default",
sku: {
name: "DW100c",
},
});
const sparkPool = new synapse.BigDataPool("Spark1", {
resourceGroupName: resourceGroup.name,
workspaceName: workspace.name,
autoPause: {
delayInMinutes: 15,
enabled: true,
},
autoScale: {
enabled: true,
maxNodeCount: 3,
minNodeCount: 3,
},
nodeCount: 3,
nodeSize: synapse.NodeSize.Small,
nodeSizeFamily: synapse.NodeSizeFamily.MemoryOptimized,
sparkVersion: "2.4",
});