aws

http://status.aws.amazon.com/ https://www.expeditedssl.com/aws-in-plain-english
devn 2019-02-28T01:32:15.001900Z

i think the answer here is no, but: <https://docs.aws.amazon.com/cli/latest/reference/redshift/get-cluster-credentials.html> I saw cognitect.aws.credentials/auto-refreshing-credentials and wondered if there was anything I might reuse in there to have an atom containing up-to-date temporary credentials.

devn 2019-02-28T01:38:33.005200Z

I wrote a little (future (while true (reset! credentials (fetch-credentials ...)) (Thread/sleep ...))) thing, but having retry, backoff, etc. managed by the lib would be nice, since some of the sauce is already in the client API.

viesti 2019-02-28T11:17:14.001400Z

yeah, for STS temporary creds, there needs to be a refresh, on some interval or maybe even a HTTP lib middleware, which would check against the expiration time (given some buffer to cover cock drift)

viesti 2019-02-28T11:18:16.002300Z

AWS Java libs encompass this via a refresh() method that the user is required to call on the background: https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/AWSCredentialsProvider.html#refresh--

viesti 2019-02-28T11:18:46.002800Z

havenโ€™t really looked into what would be most suitable place for such in the aws-api

viesti 2019-02-28T11:19:22.003Z

on the AWS Java libs: > Forces this credentials provider to refresh its credentials. For many implementations of credentials provider, this method may simply be a no-op, such as any credentials provider implementation that vends static/non-changing credentials. For other implementations that vend different credentials through out their lifetime, this method should force the credentials provider to refresh its credentials.

viesti 2019-02-28T11:19:57.003500Z

Thinking that in this way, they push the refresh responsibility to the clients

viesti 2019-02-28T11:20:18.004Z

Iโ€™d kinda like to try the middleware approach

viesti 2019-02-28T11:20:34.004400Z

to check the creds expiration โ€œon the way outโ€

viesti 2019-02-28T11:20:46.004800Z

just that one would have to know the type of the creds then

viesti 2019-02-28T11:21:17.005300Z

how do people deal with these expiring credentials elsewhere? ๐Ÿ™‚

ghadi 2019-02-28T14:27:16.006Z

@devn @viesti

viesti 2019-02-28T14:54:07.006500Z

whoa โค๏ธ

viesti 2019-02-28T14:54:30.007200Z

damn, this has been thought out well :)

viesti 2019-02-28T14:55:04.007700Z

๐Ÿ™‡

devn 2019-02-28T15:47:44.009400Z

@ghadi nice, but this wouldn't really apply to the get-cluster-credentials call, right? it retrieves a DbPassword and DbUser, but maybe I'm missing something

ghadi 2019-02-28T15:48:30.009700Z

oh those are redshift creds, not AWS creds

devn 2019-02-28T15:52:02.010500Z

@ghadi yessir, which is why i assume it's not a covered case, but i wondered if there were enough versions of same floating around that something could be provided to handle autorefresh for me

ghadi 2019-02-28T15:52:26.011200Z

you can steal the skeleton from credentials.clj

devn 2019-02-28T15:53:21.012Z

word, yeah, gonna take that as a "not in my AWS API" ๐Ÿ˜„

viesti 2019-02-28T15:55:52.013200Z

hum, the Redshift jdbc driver is able to fetch credentials when establishing a connection

viesti 2019-02-28T15:56:35.014200Z

if you provide a suitable jdbc url that tells the cluster id

viesti 2019-02-28T15:59:49.017800Z

it's simple to just fetch new credentials when making a connection

viesti 2019-02-28T16:00:08.018200Z

no need to cache

devn 2019-02-28T16:14:03.020100Z

@viesti have a link to where you see that by any chance?

viesti 2019-02-28T16:23:29.023600Z

user name and groups to join and whether to create the user while connecting can be specified options in the jdbc url https://docs.aws.amazon.com/redshift/latest/mgmt/jdbc-and-odbc-options-for-database-credentials.html

viesti 2019-02-28T16:26:16.026Z

user creation and joining groups needs permissions that can be specified via policies attached to the role/user using the jdbc driver

viesti 2019-02-28T16:28:58.028700Z

one could call the redshift get-cluster-credentials api, but at least in our case, it's been easier to let the aws provided jdbc driver do so

viesti 2019-02-28T16:30:36.030700Z

although the driver seems to have a bug which prevents this working in a lambda (tried filing a support ticket but this never got fixed)

viesti 2019-02-28T16:36:14.031900Z

but in general, was thinking that redshift connections aren't probably made that often that credentials would need to be cached

devn 2019-02-28T17:42:48.032400Z

@viesti wow, can't believe i missed that. thank you!

viesti 2019-02-28T17:43:10.032800Z

๐Ÿ˜„

devn 2019-02-28T17:44:06.033500Z

I remember seeing autocreate=true and tossing it aside as something related to db or cluster creation