-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
65 lines (55 loc) · 1.7 KB
/
main.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
import { Construct } from 'constructs'
import { App, TerraformStack, Token } from 'cdktf'
import { DigitaloceanProvider, Droplet, Vpc} from './.gen/providers/digitalocean'
import { DatabaseCluster, DatabaseUser, DatabaseDb} from './.gen/providers/digitalocean'
import { Project, ProjectResources } from './.gen/providers/digitalocean'
class MyStack extends TerraformStack {
constructor(scope: Construct, name: string) {
super(scope, name)
new DigitaloceanProvider(this, 'digitalocean', {
token: Token.asString(process.env.DO_TOKEN)
})
const project = new Project(this, 'example-project', {
name: 'Example Rails Project'
})
const vpc = new Vpc(this, 'example-vpc', {
name: 'example-vpc',
region: 'sfo3'
})
const postgres = new DatabaseCluster(this, 'example-postgres', {
name: 'example-postgres',
engine: 'pg',
version: '13',
size: 'db-s-1vcpu-1gb',
region: 'sfo3',
nodeCount: 1,
privateNetworkUuid: vpc.id
})
new DatabaseUser(this, 'example-postgres-user', {
clusterId: `${postgres.id}`,
name: 'example'
})
new DatabaseDb(this, 'example-postgres-db', {
clusterId: `${postgres.id}`,
name: 'example-db'
})
const droplet = new Droplet(this, 'example-droplet', {
name: 'example-droplet',
size: 's-1vcpu-1gb',
region: 'sfo3',
image: 'ubuntu-20-04-x64',
vpcUuid: vpc.id
})
new ProjectResources(this, 'example-project-resources', {
project: project.id,
resources: [
postgres.urn,
droplet.urn
],
dependsOn: [ postgres, droplet ]
})
}
}
const app = new App()
new MyStack(app, 'cdk-do-example')
app.synth()