aws

http://status.aws.amazon.com/ https://www.expeditedssl.com/aws-in-plain-english
Joe 2021-05-22T10:31:23.004700Z

Is there is an idiot proof end-to-end guide to setting up an S3 bucket and accessing it with Clojure? I've set up the bucket, set up an IAM policy / user to access it, but am not having any luck.

Joe 2021-05-22T10:32:23.004800Z

IAM policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ListObjectsInBucket",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::snip"
            ]
        },
        {
            "Sid": "AllObjectActions",
            "Effect": "Allow",
            "Action": "s3:*Object",
            "Resource": [
                "arn:aws:s3:::snip/*"
            ]
        }
    ]
}

Joe 2021-05-22T10:32:52.005Z

Clojure code - this hangs on the list buckets op

(comment
  (def config (edn/read-string (slurp "resources/.secrets.edn")))
  (def s3 (aws/client {:api :s3
                       :credentials-provider (creds/default-credentials-provider (:s3 config))}))

  (aws/validate-requests s3 true)

  (aws/invoke s3 {:op :ListBuckets}))

Joe 2021-05-22T10:33:53.005200Z

The AWS docs are very sprawling, so I can't tell if it's the S3 side of things I'm messing up or the Clojure side (or both)

Joe 2021-05-22T10:35:31.005400Z

In particular I'm unclear on whether the IAM policy itself is sufficient, or whether I need to change the permissions on the Bucket itself also

nbardiuk 2021-05-22T10:45:06.005600Z

Try aws cli https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/ls.html Use it to test if policy setup is sufficient to do what you want. When you figure out policies you can reproduce aws cli commands in clojure

Joe 2021-05-22T10:47:12.005800Z

Thanks, I will give that a go

valtteri 2021-05-22T10:49:49.006Z

Iā€™m not sure if you can use wildcards like this "Action": "s3:*Object"

valtteri 2021-05-22T10:50:26.006200Z

I recommend trying with s3:* or by listing all the relevant operation names

jumar 2021-05-22T10:50:48.006400Z

This is the policy we use for dev buckets and it works

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:ListAllMyBuckets",
            "Resource": "arn:aws:s3:::*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetBucketLocation"
            ],
            "Resource": "arn:aws:s3:::dev-${aws:username}"
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:DeleteObject"
            ],
            "Resource": "arn:aws:s3:::dev-${aws:username}/*"
        }
    ]
}

Joe 2021-05-22T11:10:22.006600Z

Thanks, I got it figured - the cli wasn't able to ls because the IAM wasn't set up to allow it šŸ¤¦ Also I wasn't setting the environment variables (the region). Once i corrected those it worked!

šŸ‘ 2
1