EastsideDev
EastsideDev

Reputation: 6639

Security group not properly set when calling RDS CreateDBInstance

I am trying to set the security group while creating an RDS instance, using the AWS RDS API. The RDS instance is created, but the security group is not properly set.

The call is:

$rds_client->CreateDBInstance(
    'DBSecurityGroups.DBSecurityGroupName.N' => ['office_sg'],
    ....
    ];

But when the RDS instance is created, it's assigned the default security group, and I am not getting any error messages as part of the result. It returns the following as part of the call return:

[DBInstance] => Array
    (
        [DBInstanceIdentifier] => officesupplies
        [DBInstanceClass] => db.t3.large
        [Engine] => mysql
        [DBInstanceStatus] => creating
        [MasterUsername] => officemaster
        [DBName] => officesupplies
        .....
        [DBSecurityGroups] => Array
            (
            )

When I look in the AWS dashboard for the security group, here's what I get:

name         security group id     security group name   vpc id
office_sg    sg-0787940c2b64n      office_sg             vpcbb2c7b1n5

Any ideas?

Upvotes: 0

Views: 142

Answers (1)

Marcin
Marcin

Reputation: 238637

DBSecurityGroups is for old-type RDS outside of VPC. These days you should use VpcSecurityGroups to set your security groups for RDS instance. You have to check what is the right parameter name for your programming language's SDK. Its not specified what you are programming in.

Upvotes: 2

Related Questions