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?
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
To allow your EC2 instance to be able to access an AWS service (like RDS) create an IAM role with the desired permissions and assign it to your EC2 instance.
About EC2 instance profiles
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html
All your auto scaling group members should be identical in terms of compute resources and permissions, AWS will increase or decrease the number of instances in your auto scaling group based on policies and parameters (min, max, desired instances, and scaling policy).
With Auto Scaling Groups (ASG) you first define a Launch Template which specifies the hardware and os that your EC2 instances in your ASG should run, and specify the min, max, desired number of instances in the group and a set of rules which AWS will use to add/remove instances from your ASG.
About AWS Auto Scaling
https://aws.amazon.com/ec2/autoscaling/?sc_channel=ba&sc_campaign=autoscaling-ec2-button&sc_medium=button&sc_country=global&sc_geo=global&sc_outcome=aware
hope that was useful
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.
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.