1
votes

I'm trying to create an RDS instance in a non-default Security Group using REST API call. Just before the call, I've crated a custom DB Subnet Group with two subnets in two different AZ linked with the given VPC. The call succeeds but the created DB Instance is placed in the default VPC and the default Security Group. I don't understand why it's not placed into the given Security Group.

This is how I created the VPC, both subnets, security group, DB Subnet Group and the instance (all calls succeeded with no particular error):

https://ec2.ap-southeast-1.amazonaws.com?Action=CreateVpc&CidrBlock=172.31.0.0%2F16&Version=2016-11-15

https://ec2.ap-southeast-1.amazonaws.com?Action=CreateSubnet&AvailabilityZoneId=apse1-az1&CidrBlock=172.31.0.0%2F20&Version=2016-11-15&VpcId=vpc-09b39cdff293eaf1e

https://ec2.ap-southeast-1.amazonaws.com?Action=CreateSubnet&AvailabilityZoneId=apse1-az2&CidrBlock=172.31.20.0%2F20&Version=2016-11-15&VpcId=vpc-09b39cdff293eaf1e

https://rds.ap-southeast-1.amazonaws.com?Action=CreateDBSubnetGroup&DBSubnetGroupDescription=aosdb&DBSubnetGroupName=aos-db-group&SubnetIds.SubnetId

https://ec2.ap-southeast-1.amazonaws.com?Action=CreateSecurityGroup&GroupDescription=AOS_DB_TEST&GroupName=AOS_DB_TEST&Version=2016-11-15&VpcId=vpc-09b39cdff293eaf1e

https://rds.ap-southeast-1.amazonaws.com?Action=CreateDBInstance&AllocatedStorage=15&DBInstanceClass=db.t3.micro&DBInstanceIdentifier=aosDB8e5bb76e&DBSubnetGroupName=aos-db-group&Engine=postgres&EngineVersion=9.6.19&MasterUserPassword=Cloud_123&MasterUsername=postgres&VpcSecurityGroupIds.VpcSecurityGroupId.1=sg-0bd786e045265263f

Any idea what I'm doing wrong? I tried to do the last step (CreateDBInstance) in AWS CLI and the DB was created in my custom SG and VPC with no issues. Thanks, Petr

1

1 Answers

0
votes

Sorry, I haven't done much research but the suffix is it 1 or N?

VpcSecurityGroupIds.VpcSecurityGroupId.N

  • A list of Amazon EC2 VPC security groups to associate with this DB instance.

  • Default: The default EC2 VPC security group for the DB subnet group's VPC.

  • Type: Array of strings

  • Required: No

Just in case, other additional things to consider:

If DBSubnetGroupName is specified, and PubliclyAccessible isn't specified, the following applies:

From documentation:

  • If the subnets are part of a VPC that doesn’t have an Internet gateway attached to it, the DB instance is private.

  • If the subnets are part of a VPC that has an Internet gateway attached to it, the DB instance is public.

Type: Boolean

Required: No