-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
50 lines (44 loc) · 1.62 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
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";
import * as dbforpostgresql from "@pulumi/azure-native/dbforpostgresql/v20221201";
import * as random from "@pulumi/random";
const config = new pulumi.Config("example");
const zone = config.require("zone");
const postgresUserPassword = new random.RandomPassword("postgres", {
// NB must be between 8-128.
length: 16,
minLower: 1,
minUpper: 1,
minNumeric: 1,
minSpecial: 1,
});
const example = new azure.resources.ResourceGroup("example");
const postgres = new dbforpostgresql.Server("postgres", {
resourceGroupName: example.name,
location: example.location,
availabilityZone: zone,
version: "15",
administratorLogin: "postgres",
administratorLoginPassword: postgresUserPassword.result,
backup: {
backupRetentionDays: 7,
},
// see az postgres flexible-server list-skus --location northeurope
// see https://learn.microsoft.com/en-us/azure/templates/microsoft.dbforpostgresql/2022-12-01/flexibleservers#sku
// see https://azure.microsoft.com/en-us/pricing/details/postgresql/flexible-server/
sku: {
tier: "GeneralPurpose",
name: "Standard_D2ds_v4", // 2 vCore. 8 GiB RAM.
},
storage: {
storageSizeGB: 32,
}
});
new dbforpostgresql.FirewallRule("all", {
resourceGroupName: example.name,
serverName: postgres.name,
startIpAddress: "0.0.0.0",
endIpAddress: "255.255.255.255",
});
export const fqdn = postgres.fullyQualifiedDomainName;
export const password = postgresUserPassword.result;