Assign RDS to a VPC using AWS CLI

Viewed 660

I am creating an RDS using

create-db-instance

How do I assign it to VPC group? I don't see any tag to achieve that. It is picking default VPC group and assigning to the RDS.

Here is the script I am using to create the RDS (I am passing variable in the tags which are defined in the bash script).>>

aws rds create-db-instance \
--db-name WIND \
--vpc-security-group-ids $sgGroup_id \
--db-instance-identifier $Instance_Identifier \
--allocated-storage 100 \
--copy-tags-to-snapshot \
--db-instance-class ${arrDbClass[$iDbClass]} \
--engine oracle-ee \
--engine-version ${arrEngVer[$iEngVer]} \
--license-model bring-your-own-license \
--master-username oraadmin \
--master-user-password $oraadminPassword \
--no-auto-minor-version-upgrade \
--no-publicly-accessible \
--backup-retention-period $backup_Retention_Period \
--no-storage-encrypted \
--storage-type gp2 \
--no-enable-iam-database-authentication \
  $multi_Az \
1 Answers

Use --db-subnet-group-name to point to a DBSubnetGroup, which contains a list of subnets where the database is permitted to launch.

The subnets belong to a VPC.

Therefore, the order is:

  • Create a DBSubnetGroup pointing to subnets in your VPC
  • Launch the RDS Instance into the DBSubnetGroup
Related