-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
84 lines (73 loc) · 2.22 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
import * as pulumi from "@pulumi/pulumi"
import * as random from "@pulumi/random"
import * as resources from "@pulumi/azure-native/resources"
import * as network from "@pulumi/azure-native/network"
import { mysql } from "@pulumi/azure"
const config = new pulumi.Config()
const username = config.get("username") || "pulumiadmin"
const password = config.get("password") || new random.RandomPassword("pw", {
length: 20,
special: true,
}).result
/******/
/* RG */
/******/
const resourceGroup = new resources.ResourceGroup("rg", {
location: 'EastUS'
})
/**************/
/* NETWORKING */
/**************/
const virtualNetwork = new network.VirtualNetwork("vnet", {
location: resourceGroup.location,
resourceGroupName: resourceGroup.name,
addressSpace: {
addressPrefixes: ["10.0.0.0/16"],
}
});
const dataSubnet = new network.Subnet("data", {
resourceGroupName: resourceGroup.name,
virtualNetworkName: virtualNetwork.name,
addressPrefix: "10.0.1.0/24",
serviceEndpoints: [{
service: "Microsoft.Storage"
}],
delegations: [{
name: "fs",
serviceName: "Microsoft.DBforMySQL/flexibleServers",
}],
});
const privateZone = new network.PrivateZone("privateZone", {
resourceGroupName: resourceGroup.name,
privateZoneName: "privatelink.mysql.database.azure.com",
location: "Global",
});
const virtualNetworkLink = new network.VirtualNetworkLink("vnetLink", {
location: "Global",
privateZoneName: privateZone.name,
registrationEnabled: false,
resourceGroupName: resourceGroup.name,
virtualNetwork: {
id: virtualNetwork.id,
},
virtualNetworkLinkName: "virtualNetworkLink1",
});
/*****************/
/* FlexibleMySQL */
/*****************/
const mysqlFlexibleServer = new mysql.FlexibleServer("mysql", {
resourceGroupName: resourceGroup.name,
location: resourceGroup.location,
administratorLogin: username,
administratorPassword: password,
backupRetentionDays: 7,
delegatedSubnetId: dataSubnet.id,
privateDnsZoneId: privateZone.id,
skuName: "B_Standard_B1ms",
}, {
dependsOn: [privateZone, virtualNetworkLink],
});
/***********/
/* OUTPUTS */
/***********/
export const mysqlFqdn = mysqlFlexibleServer.fqdn