Fork me on GitHub
#tools-deps
<
2021-06-25
>
Jakub Holý (HolyJak)12:06:58

Hi! Does deps check for and download new snapshots automatically or do I / can I tell it to do so? Searching for "snapshot" at https://clojure.org/reference/deps_and_cli#_resolve_deps does not find much. 🙏

Alex Miller (Clojure team)12:06:33

You can use -Sforce to force the cp to be recomputed

Alex Miller (Clojure team)12:06:01

It will use the default snapshot update policy which is daily

Alex Miller (Clojure team)12:06:08

If you want more new than that, you’ll need to remove portions of your local maven cache

Alex Miller (Clojure team)12:06:00

I believe we have an existing ticket to allow setting the snapshot policy or more control over this

delaguardo12:06:29

is it possible to configure update policy using global maven settings.xml?

Alex Miller (Clojure team)13:06:35

well tools.deps doesn't use that for this so won't matter

dharrigan13:06:13

Does deps have support for s3p:// repos, aka private s3 repositories?

dharrigan13:06:56

A lein plugin, which our company uses is this and I'm trying to convert a project.clj to deps.clj

rickmoynihan13:06:28

just drop the p from the end of the protocol and it should work out of the box… iirc s3p is an old deprecated protocol

Alex Miller (Clojure team)14:06:53

it's not deprecated, it's just specific to that leiningen plugin. that's not a "real" thing

👍 2
dharrigan13:06:13

I will retry that, for it failed when I did it

dharrigan13:06:58

hmmm, strange

dharrigan13:06:06

I have this in my deps.edn...

dharrigan13:06:25

:mvn/repos {"foo-releases" {:url ""}
             "foo-snapshots" {:url ""}}}

dharrigan13:06:34

but the resolution does this:

dharrigan13:06:36

Downloading: foo/components/0.2.0/components-0.2.0.pom from foo-releases
Downloading: foo/components/0.2.0/components-0.2.0.pom from foo-snapshots
Downloading: org/clojure/clojure/maven-metadata.xml from foo-snapshots
Downloading: org/clojure/clojure/maven-metadata.xml from foo-releases
Downloading: foo/components/0.2.0/components-0.2.0.jar from foo-releases
Downloading: foo/components/0.2.0/components-0.2.0.jar from foo-snapshots
Error building classpath. Could not find artifact foo:components:jar:0.2.0 in central ()

dharrigan13:06:59

Not sure what is going on at all, why is it calling out to maven central (no artifact has been downloaded)

rickmoynihan14:06:50

I’m pretty sure that’s just because it looks for the deps on all repos, which is why you’re seeing that

dharrigan14:06:06

Okay, a fallback. Fairy enough. However, it appears not to be able to download the artifact on s3.

Alex Miller (Clojure team)14:06:35

correct on the error message - it cycles through all repos and will report only the last error

dharrigan14:06:54

Ah, I think I've also discovered why it didn't download

dharrigan14:06:56

double checking

Alex Miller (Clojure team)14:06:56

is that a private s3 repo or public?

Alex Miller (Clojure team)14:06:09

and you provided auth ?

dharrigan14:06:20

that's what I'm double checking atm 🙂

dharrigan14:06:26

verifying my setup

Alex Miller (Clojure team)14:06:31

also important is that the AWS creds you use have a policy that allows s3 ops

dharrigan14:06:56

yup, all that works with lein, I'm doing a conversion to deps

Alex Miller (Clojure team)14:06:13

but your log snippet above shows it successfully downloading stuff from the repo

dharrigan14:06:37

No, it didn't

dharrigan14:06:48

it created the directories, but didn't download anything.

dharrigan14:06:56

so that message is misleading

dharrigan14:06:40

(I wouldn't report it not downloading anything, without first checking if the directories actually contained stuff)

Alex Miller (Clojure team)14:06:03

do you have metadata files in there or are they literally empty?

dharrigan14:06:07

literally empty

dharrigan14:06:43

metadata would have indicated that it yes, downloaded something (then my question would have been different, i.e., why metadata but no jar...)

Alex Miller (Clojure team)14:06:04

can you try again with -Sforce ?

dharrigan14:06:09

That's what I have been using

dharrigan14:06:44

So, I got it to download now, like this:

Alex Miller (Clojure team)14:06:45

where are you putting AWS creds?

dharrigan14:06:31

in my .m2/settings.xml I had the the username/password set to my access key and secret access key (when I first attempted to verify that the conversion from project.clj to deps.clj was okay)

dharrigan14:06:39

(following the instructions on the link)

dharrigan14:06:49

that didn't work (see eyes passim)

dharrigan14:06:57

but then I removed the u/p combo

dharrigan14:06:01

and used this way

dharrigan14:06:16

aws-vault exec foo -- clj -Sforce

dharrigan14:06:38

then that worked

dharrigan14:06:22

it does stuff in the background to setup credentials and environment variables

dharrigan14:06:39

(but <shrug> I'm quite new to using it too, it's used at a company I've just joined)

Alex Miller (Clojure team)14:06:58

temporary ambient creds

dharrigan14:06:36

right, it has things like this

dharrigan14:06:41

aws-vault list

dharrigan14:06:56

aws-vault list
Profile                  Credentials              Sessions                      
=======                  ===========              ========                      
default                  -                        -                             
dharrigan                -                        -                             
foo                       foo                       sts.GetSessionToken:5h54m59s  
foo:staging               -                        -                             

Alex Miller (Clojure team)14:06:25

may be that whatever your ambient aws creds were were getting used over the user/pw creds

dharrigan14:06:15

I think it's the session credentials that should replace what was in the .m2/settings.xml, (I've removed the access key/secret key combo from the .m2/settings.xml)

dharrigan14:06:06

If I do this:

dharrigan14:06:09

❯ aws-vault exec foo -- env | rg AWS  
_=/usr/bin/aws-vault
AWS_VAULT=foo
AWS_DEFAULT_REGION=eu-west-1
AWS_REGION=eu-west-1
AWS_ACCESS_KEY_ID=wibble
AWS_SECRET_ACCESS_KEY=wobble
AWS_SESSION_TOKEN=wibble-session
AWS_SECURITY_TOKEN=wobble-sesion
AWS_SESSION_EXPIRATION=2021-06-25T20:08:23Z

dharrigan14:06:42

I can see that a lot of env variable are set, which I suppose the S3Transporter uses to successfully download the jar from.

dharrigan14:06:49

Should this be documented for those who come after me? A company that has a security policy like this, that requires that session tokens are gained and used, will affect anyone trying to download from s3 without this knowledge.

Alex Miller (Clojure team)14:06:39

should what be documented?

Alex Miller (Clojure team)14:06:24

s3 ambient creds are discussed in the docs

dharrigan14:06:34

The instructions on the for accessing private s3 repos do not take into account temporary session credentials

dharrigan14:06:52

I don't think this For authenticated repos, AWS credentials can be set in the ~/.m2/settings.xml on a per-server basis or will be loaded ambiently from the AWS credential chain (env vars, etc). is quite sufficient detail

dharrigan14:06:08

they certainly hint at it, but don't expound upon it

Alex Miller (Clojure team)14:06:41

I'm not sure what's special about the temporariness of the credentials

Alex Miller (Clojure team)14:06:00

this is the relevant part:

AWS S3 credentials can be set in the environment using one of these mechanisms:

    Set the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

    Create a default profile in the AWS credentials file ~/.aws/credentials (older ~/.aws/config also supported).

    Create a named profile in the AWS credentials file and set the environment variable AWS_PROFILE with its name.

    Amazon ECS container and instance profile credentials should also work, but have not been tested.

For more information, most of the advice in this AWS document describes how credentials are located. Note however that the Java system properties options will NOT work with the command line tools (but would work if using the tools.deps.alpha library directly).

Alex Miller (Clojure team)14:06:25

so, I think it does expound on it?

dharrigan15:06:17

It's missing information on the session tokens, which are used in tandem with the access key and secret access key - but only under specific circumstances, i.e., when there is an AssumeRole going on.

dharrigan15:06:04

(otherwise,the access key and secret access key, set in the .m2/settings.xml under username/password would have worked out-of-the-box)

dharrigan15:06:27

I'm highlighting a gap in the explanation that I came across. With the thought of being helpful to others in the future, who may encounter this too, I thought it would be beneficial to document it somewhere.

Alex Miller (Clojure team)15:06:25

so you're talking about user/pw being insufficient when using session tokens

dharrigan17:06:58

Hi, Sorry for the delay. Family and trying to reproduce the situation cleanly. On a clean OS, the only way I could get the artifacts to download from the private S3 repository was to ensure that there was no username/password set in the .m2/settings.xml and use aws-vault foo exec -- clj -Sforce to download the items. If I had the username/password set, it would not download (it would say it was downloading, create empty directories, but not actually download the items)

dharrigan17:06:22

So, yes, a full set of AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, AWS_SECURITY_TOKEN etc., are required.

dharrigan17:06:07

I think this comes into play when a role doesn't have the ability to download, and has to temporarily assume the role (by using aws-vault for example, to ensure the correct ENV variables are set)

dharrigan17:06:11

I hope that helps.

dharrigan15:06:57

I think so yes, it wasn't sufficent for me when I had them in the .m2/settings.xml. However, let me validate that again by doing another test. I'll report back 🙂