Jimmy Chen
Jimmy Chen

Reputation: 267

Creating AWS RDS Postgres with CDK and defining Security Groups

I'm using python CDK to create a Postgres DB and all is fine.

I'm using

newdatabase = rds.DatabaseCluster(

)

Unfortunately, I couldn't find a way to attach an existing security group to this cluster. Anyone know how I could do it with Python?

Upvotes: 0

Views: 1524

Answers (2)

Deepak
Deepak

Reputation: 105

Did you try calling the existing security group as shown below and then using the variable in the array. It worked for me.

security_group = _ec2.SecurityGroup.from_security_group_id(self, "imported-sg",security_group_id="sg-xxxxxxxx")
mydb= _rds.DatabaseInstance(self,
                              "mysql-rds",
                              security_groups=[security_group]
                            )

Upvotes: 0

Marcin
Marcin

Reputation: 238081

You set it using DatabaseClusterAttributes. Specifically using:

security_groups - The security groups of the database cluster. Default: - no security groups

Upvotes: 0

Related Questions