-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.ts
33 lines (26 loc) · 1.09 KB
/
database.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
import * as pulumi from "@pulumi/pulumi"
import * as awsx from "@pulumi/awsx";
import * as aws from "@pulumi/aws";
export class MinifluxDatabase {
public connectionString: pulumi.Output<string>;
constructor(username: string, password: string, databaseName: string) {
const vpc = awsx.ec2.Vpc.getDefault();
const cluster = new awsx.ecs.Cluster("cluster", { vpc });
let securityGroupIds = cluster.securityGroups.map(g => g.id);
let dbSubnets = new aws.rds.SubnetGroup("dbsubnets", {
subnetIds: vpc.publicSubnetIds,
});
const db = new aws.rds.Instance("db", {
engine: "postgres",
instanceClass: "db.t3.micro",
allocatedStorage: 10,
dbSubnetGroupName: dbSubnets.id,
vpcSecurityGroupIds: securityGroupIds,
name: databaseName,
username: username,
password: password,
skipFinalSnapshot: true,
});
this.connectionString = pulumi.interpolate `postgres://${username}:${password}@${db.endpoint}/miniflux?sslmode=disable`
}
}