babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-01-06T12:45:11.496600Z

We (@jeroenvandijk, @rahul080327, @valtteri and myself) are happy to announce the babashka aws pod! Access AWS directly from babashka scripts with virtually no startup time, accessing all the services that the Cognitect aws-api lib provides access to. https://github.com/babashka/pod-babashka-aws

6
🎉 11
2021-01-06T13:28:18.001400Z

Is there a way to launch a babashka .CLJ file like a normal bash file? ./my-clj-script.sh I'm asking because I would like to run a BB script in our TeamCity and you can enter some bash in the UI so that would make it easy to use there.

borkdude 2021-01-06T13:28:50.001800Z

@nha yes, use a shebang: #!/usr/bin/env bb

2021-01-06T13:29:11.002200Z

Nice! That should work :simple_smile: thanks

lukasz 2021-01-06T15:12:54.003400Z

@borkdude I assume aws pod doesn't support custom credential providers, right?

borkdude 2021-01-06T15:13:33.003800Z

@jeroenvandijk is working on that https://github.com/babashka/pod-babashka-aws/pull/16

2021-01-06T15:14:05.004500Z

@lukaszkorecki If you have specific examples please leave a comment with your usecase

lukasz 2021-01-06T15:17:45.006300Z

@jeroenvandijk We have 2 custom providers which I'm planning to open source at some point - AWS SSO profile and Fargate+ECS, neither are supported out of the box in aws-api, the implementation is fairly straightforward but since both reify CredentialsProvider, I'd assume it's not possible to pull off in BB (it might, I don't know)

borkdude 2021-01-06T15:18:26.006900Z

@lukaszkorecki Jeroen is adding a credentials_process provider, which lets you hook into a process which grabs the credentials for you, returned as json

borkdude 2021-01-06T15:18:30.007100Z

That might also help

lukasz 2021-01-06T15:22:59.007600Z

Ah, neat!

borkdude 2021-01-06T15:23:42.007900Z

which can be another bb script, possibly ;)

lukasz 2021-01-06T15:33:54.008400Z

it totally can - both providers are pretty simple (couple of HTTP requests and parsing JSON files)

2021-01-06T15:40:43.008800Z

Do you happen to use Okta @lukaszkorecki?

2021-01-06T15:41:31.009700Z

I started implementing support for reify CredentialsProvider but it’s a bit tricky so maybe not worth it if there are other options

lukasz 2021-01-06T15:42:29.010500Z

We delegate to G-Suite as the iDP, but it should be the same - credentials obtained via aws sso login are not dependent on the idp I think

2021-01-06T15:43:47.011100Z

Cool 🙂 I didn’t try aws sso yet. Was using Okta before sso came out, but I guess similar indeed

lukasz 2021-01-06T15:44:37.011600Z

When I set it up it was "just" SAML, so you can definitely use Okta

lukasz 2021-01-06T15:45:07.012200Z

it's pretty neat, as we have effectively stopped using aws credentials locally, don't have to use creds to login to the console

lukasz 2021-01-06T15:45:20.012600Z

and with some hackery even works with Terraform

lukasz 2021-01-06T15:45:32.013Z

BUT, most (if not all) AWS SDKs do not work with sso as the credential source

lukasz 2021-01-06T15:45:41.013200Z

(yet, I'm sure they will catch up)

2021-01-06T15:46:06.013600Z

even when wrapped in a credential_process?

lukasz 2021-01-06T15:46:28.014Z

if that provides credentials via standard env vars, then it should work as expected

lukasz 2021-01-06T15:46:40.014300Z

but, these expire within 15m to an hour (I think it's configurable)

lukasz 2021-01-06T15:46:46.014600Z

so you need something to constantly refresh them

2021-01-06T15:47:39.015300Z

aws-cli and aws-sdk seem to work properly with credential_process is my experience. I do have a custom wrapper to manage expirations

lukasz 2021-01-06T15:48:10.015600Z

here you go, extracted from our private lib: https://gist.github.com/lukaszkorecki/120008f7832e23702e94f4205b8e3df5

2021-01-06T15:48:34.016300Z

awesome thanks!

lukasz 2021-01-06T15:48:34.016400Z

assumes that aws cli v2 is configured, you can do aws sso login --profile=whatever and call the AWS APIs

borkdude 2021-01-06T15:49:32.016800Z

Does it make sense to make a thread for this discussion?

borkdude 2021-01-06T15:49:39.017100Z

(I personally don't mind)

lukasz 2021-01-06T15:49:57.017500Z

Sorry, yes! Also I thought this is #aws channel 🤦

borkdude 2021-01-06T15:50:28.017700Z

No worries. Let's continue here :)

borkdude 2021-01-06T15:50:33.017900Z

@jeroenvandijk

borkdude 2021-01-06T16:11:02.018100Z

Added you to our "babashka-aws" group discussion

2021-01-06T16:30:14.018900Z

What’s the recommended way to parse a date in Babashka e.g. “2021-01-06T17:27:27Z” in order to get #inst “2021-01-06T17:27:27Z”

borkdude 2021-01-06T16:30:47.019100Z

the java.time API

borkdude 2021-01-06T16:31:12.019400Z

I think?

2021-01-06T16:31:56.020Z

ah yeah, good one. was struggling with java.util.date 😅

borkdude 2021-01-06T16:37:05.020100Z

This also works:

user=> #inst "2021-01-06T17:27:27Z"
#inst "2021-01-06T17:27:27.000-00:00"
but only for literal strings

borkdude 2021-01-06T16:38:46.020300Z

Ah I see:

user=> (java.time.ZonedDateTime/parse "2021-01-06T17:27:27Z")
#object[java.time.ZonedDateTime 0x42c2631c "2021-01-06T17:27:27Z"]

2021-01-06T16:41:49.020500Z

thanks!

2021-01-06T17:07:07.020700Z

You might want java.time.Instant instead of java.time.ZonedDateTime. The latter carries around a timezone with it.

borkdude 2021-01-06T17:09:13.020900Z

$ bb -e '(java.time.Instant/parse "2021-01-06T17:27:27Z")'
#object[java.time.Instant 0x608e84f "2021-01-06T17:27:27Z"]

borkdude 2021-01-06T17:09:30.021100Z

yeah, works

borkdude 2021-01-06T17:20:05.021900Z

I made a dev channel for pod-babashka-aws-dev which is by invite, let me know if you're interested and I'll add you. This is only for dev discussions. Normal usage questions can go here.