green-analyst-32514
03/29/2023, 4:30 PMS3 access denied error when locally running a flow connected to a remote datastore:
Metaflow 2.8.1 executing SalaryTrainer for user:winstonvan
Validating your flow...
The graph looks good!
Running pylint...
Pylint is happy!
S3 access denied:
<s3://metaflow-datastore/metaflow/flow/342/_parameters/11645/0.attempt.json>
We’ve set up a IAM user policy to access the metaflow datastore bucket below:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:ListBucket",
"s3:ListBucketVersions",
"s3:GetBucketTagging",
"s3:GetBucketVersioning",
"s3:GetObject*",
"s3:PutObject",
"s3:DeleteObject"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::metaflow-datastore",
"arn:aws:s3:::metaflow-datastore/*"
]
}
]
}
Is there a permission that we’re missing to allow metaflow to access our S3 datastore bucket?ancient-application-36103
03/29/2023, 4:34 PMHeadObject as wellgreen-analyst-32514
03/29/2023, 5:00 PMs3:HeadObject isn’t a valid permission, but looking at this stackoverflow thread, it seems like the head operation requires ListBucket permission, along with specifying the bucket and the objects within the buckets for the target resources. I already have this, so I’m not sure why it’s not working 😕green-analyst-32514
03/29/2023, 5:01 PMaws s3api head-object with the credentials and it seemed to work finegreen-analyst-32514
03/29/2023, 5:02 PMancient-application-36103
03/29/2023, 5:03 PMancient-application-36103
03/29/2023, 5:05 PMgreen-analyst-32514
03/29/2023, 5:07 PMsquare-wire-39606
03/29/2023, 6:12 PMuser
03/29/2023, 6:55 PMuser
03/29/2023, 7:21 PMgreen-analyst-32514
03/29/2023, 7:48 PMKMS:GenerateDataKey permission, but after granting that permission, I’m now getting this 😭green-analyst-32514
03/29/2023, 7:51 PMMetaflow 2.8.1 executing flow for user:winstonvan
Validating your flow...
The graph looks good!
Running pylint...
Pylint is happy!
2023-03-29 13:41:17.895 Workflow starting (run-id 347):
2023-03-29 13:41:18.994 [347/start/11652 (pid 99949)] Task is starting.
2023-03-29 13:41:24.288 [347/start/11652 (pid 99949)] S3 access denied:
2023-03-29 13:41:24.289 [347/start/11652 (pid 99949)] <s3://metaflow-datastore/metaflow/flow/347/_parameters/11651/0.data.json>average-beach-28850
03/29/2023, 7:54 PMkms:* to verify that it works and then work backwards to narrow it down if neededaverage-beach-28850
03/29/2023, 7:56 PMaverage-beach-28850
03/29/2023, 7:57 PMgreen-analyst-32514
03/29/2023, 7:58 PMaverage-beach-28850
03/29/2023, 7:59 PMuser
03/29/2023, 8:01 PMuser
03/29/2023, 8:08 PMkms:* , still getting an S3 access denied error after the Pylint is happy! step (apparently on 0.attempt.json creation, before start step)user
03/29/2023, 8:10 PMgreen-analyst-32514
03/29/2023, 8:15 PMkms:GenerateDataKey , kms:Encrypt , and kms:Decrypt permissions and everything works now 😄!!
Without the GenerateDataKey permission, we get the s3 access denied before the start step, so it seems like it was necessary.
Here’s our policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetBucketTagging",
"kms:Decrypt",
"kms:Encrypt",
"s3:ListBucketVersions",
"kms:GenerateDataKey",
"s3:ListBucket",
"s3:GetBucketVersioning",
"s3:DeleteObject",
"s3:GetObject*"
],
"Resource": [
"arn:aws:s3:::metaflow-datastore/*",
"arn:aws:s3:::metaflow-datastore",
"arn:aws:kms:xxx"
]
}
]
}green-analyst-32514
03/29/2023, 8:15 PMuser
03/29/2023, 8:31 PMuser
03/30/2023, 9:58 PMhallowed-room-36044
03/31/2023, 4:55 PMAccess denied to URL: s3://[bucket_name]/metaflow/conda/conda.anaconda.org/conda-forge/linux-64/abseil-cpp-20210324.2-h9c3ff4c_0.tar.bz2/baa652d7d0da41d757a31d00b4ae2c38/abseil-cpp-20210324.2-h9c3ff4c_0.tar.bz2. I deployed all infra from the Terraform project and verified that the IAM batch step role was provisioned correctly, with the get/put/listbucket permissions for the bucket, kms permissions… bucket and Batch job are in the same region. I’ve relaxed IAM permissions, testing with stars for s3 and kms perms. I’ve even tried adding s3 permissions to the batch execution service role on the compute environment. I’ve searched here for MetaflowS3AccessDenied and followed all recommendations I believe, but no luck. My local flow steps run fine, it only fails on @batch. (abseil is apparently a C++ package, must be a dep of something in my conda base: @conda_base(python='3.9.7', libraries={'pandas': '1.4.4', 'boto3': '1.24.59', 'fsspec':'2022.10.0', 's3fs':'2022.10.0', 'botocore':'1.27.59', 'aiobotocore':'2.4.0','pyarrow':'8.0.0'})
The only other thing I can think of that could be a factor is I’m trying to use a custom image from ECR. When I try using a stock image with simple @resources, my job never starts because it doesn’t associate itself with a log group for some reason. But when I run with the custom image, it does pick up the correct log group. It runs but fails 14 seconds in consistently.
Super confused here because I’m able to run the batch step in Ch. 5 of the tutorials.average-beach-28850
03/31/2023, 6:27 PMhallowed-room-36044
03/31/2023, 7:58 PM@batch(image='[ECR image URI]') I was able to get my step running on a stock Python image without the error, so it must be something about the container that’s spun up on the image or a networking issue of some type around the task, where the privileges are stopping short of the task or container in this specific case.