I have an AWS EC2 instance and a MySql RDS instance.
Now I want EC2 to connect to RDS using SSL.
I downloaded a RDS SSL certificate provided by Amazon. Then I uploaded the SSL certificate to the EC2, connected to EC2 through SSH and checked if SSL DB connection worked running something like
mysql --ssl-ca=path_to_cert.pem --ssl-mode=REQUIRED -h my_mysql_instance_url .......
Everything worked perfectly.
The goal is to automate this process of adding certificate to the EC2 when creating EC2 from AMI.
So, I see a few options:
- manually update the AMI itself to include the CA certificate file, so created EC2 instances have it too
- write a script on the AMI side which when running instances somehow downloads the CA certificate to their file system
- use any another method which doesn't require downloading CA certificate file
What is the best practice?