问题
I have an RDS MySQL persistant instance, and I am trying to run spot instances which are created once every 8 hours and then destroyed.
The issue I am having is that I don't understand how can I add those spot instances which have dynamic IPs to the security group of my RDS Instance in order to let them perform queries,etc.
Should I grab the IP as soon as the spot instance is created and the add it to the security group of the RDS instance each time a new spot instances is created? Also destroy it every time the spot instance is terminated?
Any tip on what approach to take will be much appreciated! Thanks!
回答1:
Assuming that both your spot instances and RDS are in the same region: when setting up an RDS security group, you can also allow machines in EC2 security groups to connect to your RDS machine. Simply add all your spot instances to a EC2 security group and grant access to RDS for this security group.
If your RDS and spot instances are in different regions, you could use the AWS API or an AWS API client like boto for Python to add the IPs automatically.
来源:https://stackoverflow.com/questions/12252862/adding-spot-instances-to-the-security-group-of-an-rds-instance