AWS auto scaling group, multiple ec2 instances are running, how to set that only specific ec2 instance to access RDS?

126 views Asked by At

I created the AWS auto scaling group, in that multiple ec2 instances are running, how to set that only specific/particular ec2 instance to access/connect RDS? I am new to the AWS so can anyone please answer to my question?

1

There are 1 answers

0
anhhq On

Your case is unreasonable. But I will suggest my own way (tip) in this case. Suppose you have 3 instances running all the time, and can scale up to 10 instances.

  • Setup scale with min max desire number is 3 3 10 respectively
  • Set scale policy to "Newest instance"
  • Create an additional security group, allowing this SG from the RDS SG.
  • Attach this SG to your first scaled-out instance

In this case the first scaled instance will never be terminated unless it crashes. And you will again attach the allowed SG to another instance. Newer scaled instances will be deleted first.

But I think, if only 1 instance is allowed in RDS, leave it out of the autoscaling group, because it doesn't belong to the group.