When developing a microservice that accesses an AWS RDS database, securing the connection with IAM is useful. Amazon provides a driver wrapper that adds the authentication methods, but it requires a number of jars on the classpath. This project provides a Maven pom that downloads all of these so they can be added to the static javaclasspath.
Usage:
- copy the file pom.xml to a directory and cd to the directory
- mvn dependency:copy-dependencies (This will download all of the jars to the directory target/dependency)
- find "$(cd target/dependency;pwd)" -type f > $(matlab -batch "fprintf('%s', fullfile(prefdir,'javaclasspath.txt'))") (This gets a listing of all files in that directory and writes it to a file. The filename is generated by calling matlab to get the prefdir location)
- start matlab and call openRDSdb.m, supplying credentials directly, or by specifying an AWS profile.
I've tested this on Mac and Linux. It should work on Windows if you have Maven installed and can figure out how to make step 3 work in Windows. Note that in a production environment (meaning deploying a Docker container on AWS), you should attach a policy to the service that grants the service permission to access the database, but during development using a profile is useful.
引用格式
Jeff Mandel (2025). Open database connection to AWS RDS with IAM (https://ww2.mathworks.cn/matlabcentral/fileexchange/180330-open-database-connection-to-aws-rds-with-iam), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
创建方式
R2024b
兼容任何版本
平台兼容性
Windows macOS Linux标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!| 版本 | 已发布 | 发行说明 | |
|---|---|---|---|
| 1.0.0 |
