Is there the generate_db_auth_token in SOTO? #670
-
I am trying pet project to convert our tools to swift. One thing I have not been able to find is the ability to generate a db auth token that can be used to sign into RDS with a mysql client. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
No there isn't a version of this function, but it should be fairly easy to implement as it uses SIGV4 to create it. From what I can work out it creates a URL import SotoSignerV4
let url = "https://<_RDSHOSTNAME_>:<_RDSPORT_>/?Action=connect&DBUser=<username>"
let credentials: Credential = StaticCredential(
accessKeyId: "_MYACCESSKEY_",
secretAccessKey: "_MYSECRETACCESSKEY_"
)
let signer = AWSSigner(credentials: credentials, name: "rds-db", region: "_MYREGION_")
let signedURL = signer.signURL(
url: url,
method: .GET
)
// drop "https://"
let authToken = signedURL.absoluteString.dropFirst(8) You need to obviously replace the hostname, port, credentials and region in the code above. If you already have a AWSClient setup you can use This is completely untested code. I would most appreciate it if you replied whether it works for you or not, then I can stick it in the documentation. |
Beta Was this translation helpful? Give feedback.
-
Ah you beautiful person. Thank you tons! Here is my working code. You got pretty much all of it.
|
Beta Was this translation helpful? Give feedback.
Ah you beautiful person. Thank you tons! Here is my working code. You got pretty much all of it.