forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyStack.cs
126 lines (114 loc) · 4.47 KB
/
MyStack.cs
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
using Pulumi;
using Pulumi.AzureNative.Authorization;
using Pulumi.AzureNative.Resources;
using Pulumi.AzureNative.Storage;
using Pulumi.AzureNative.Synapse;
using Pulumi.AzureNative.Synapse.Inputs;
using Pulumi.Random;
using ResourceIdentityType = Pulumi.AzureNative.Synapse.ResourceIdentityType;
using SkuArgs = Pulumi.AzureNative.Storage.Inputs.SkuArgs;
class MyStack : Stack
{
public MyStack()
{
var config = new Pulumi.Config();
var location = config.Get("location") ?? "WestUS";
var resourceGroup = new ResourceGroup("synapse-rg");
var storageAccount = new StorageAccount("synapsesa", new StorageAccountArgs
{
ResourceGroupName = resourceGroup.Name,
AccessTier = AccessTier.Hot,
EnableHttpsTrafficOnly = true,
IsHnsEnabled = true,
Kind = "StorageV2",
Sku = new SkuArgs
{
Name = "Standard_RAGRS"
},
});
var dataLakeStorageAccountUrl = Output.Format($"https://{storageAccount.Name}.dfs.core.windows.net");
var users = new BlobContainer("users", new BlobContainerArgs
{
ResourceGroupName = resourceGroup.Name,
AccountName = storageAccount.Name,
PublicAccess = PublicAccess.None
});
var workspacePwd = new RandomPassword("workspace-pwd", new RandomPasswordArgs
{
Length = 12,
});
var workspace = new Workspace("workspace", new WorkspaceArgs
{
ResourceGroupName = resourceGroup.Name,
DefaultDataLakeStorage = new DataLakeStorageAccountDetailsArgs
{
AccountUrl = dataLakeStorageAccountUrl,
Filesystem = "users"
},
Identity = new ManagedIdentityArgs
{
Type = ResourceIdentityType.SystemAssigned
},
SqlAdministratorLogin = "sqladminuser",
SqlAdministratorLoginPassword = workspacePwd.Result
});
var allowAll = new IpFirewallRule("allowAll", new IpFirewallRuleArgs
{
ResourceGroupName = resourceGroup.Name,
WorkspaceName = workspace.Name,
EndIpAddress = "255.255.255.255",
StartIpAddress = "0.0.0.0"
});
var subscriptionId = resourceGroup.Id.Apply(id => id.Split('/')[2]);
var roleDefinitionId = $"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe";
var storageAccess = new RoleAssignment("storageAccess", new RoleAssignmentArgs
{
RoleAssignmentName = new RandomUuid("roleName").Result,
Scope = storageAccount.Id,
PrincipalId = workspace.Identity.Apply(identity => identity.PrincipalId).Apply(v => v ?? "<preview>"),
PrincipalType = "ServicePrincipal",
RoleDefinitionId = roleDefinitionId
});
var clientConfig = Output.Create(GetClientConfig.InvokeAsync());
var userAccess = new RoleAssignment("userAccess", new RoleAssignmentArgs
{
RoleAssignmentName = new RandomUuid("userRoleName").Result,
Scope = storageAccount.Id,
PrincipalId = clientConfig.Apply(v => v.ObjectId),
PrincipalType = "User",
RoleDefinitionId = roleDefinitionId
});
var sqlPool = new SqlPool("SQLPOOL1", new SqlPoolArgs
{
ResourceGroupName = resourceGroup.Name,
WorkspaceName = workspace.Name,
Collation = "SQL_Latin1_General_CP1_CI_AS",
CreateMode = "Default",
Sku = new Pulumi.AzureNative.Synapse.Inputs.SkuArgs
{
Name = "DW100c"
},
});
var sparkPool = new BigDataPool("Spark1", new BigDataPoolArgs
{
ResourceGroupName = resourceGroup.Name,
WorkspaceName = workspace.Name,
AutoPause = new AutoPausePropertiesArgs
{
DelayInMinutes = 15,
Enabled = true,
},
AutoScale = new AutoScalePropertiesArgs
{
Enabled = true,
MaxNodeCount = 3,
MinNodeCount = 3,
},
NodeCount = 3,
NodeSize = "Small",
NodeSizeFamily = "MemoryOptimized",
SparkVersion = "2.4"
});
}
}