-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostgres_db.py
44 lines (37 loc) · 1.52 KB
/
postgres_db.py
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
import pulumi
import pulumi_aws as aws
class Database(pulumi.ComponentResource):
def __init__(self, name: str, username: str, password: str, security_group_id: str,private_subnets, opts=None):
super().__init__("custom:rds:DatabasePostgres", name, {}, opts)
# Instantiate an RDS ParameterGroup
self.parameter_group = aws.rds.ParameterGroup("csye6225-postgres-db-parameter-group",
family="postgres15",
description="CSYE6225 Postgres DB parameter group",
parameters=[
aws.rds.ParameterGroupParameterArgs(
name="application_name",
value="postgres_db_app"
),
],
opts=pulumi.ResourceOptions(parent=self)
)
self.db_subnet_group = aws.rds.SubnetGroup("db-subnet-group",
subnet_ids=[private_subnets[0].id, private_subnets[1].id],
)
# Create a new rds instance
self.rds_instance = aws.rds.Instance(
name,
engine="postgres",
engine_version="15.3",
instance_class="db.t3.micro",
allocated_storage=20,
storage_type="gp2",
username=username,
password=password,
vpc_security_group_ids=[security_group_id],
db_subnet_group_name=self.db_subnet_group.name,
parameter_group_name=self.parameter_group.id,
delete_automated_backups=True,
skip_final_snapshot = True,
deletion_protection=False,
)