'PutObject Access Denied when uploading csv file to S3
I am trying to use boto3 to upload csv file to s3, but I got "access denied" error. below is part of my code. My IAM role is only grant "PutObject" permission for "my_bucket/google" folder but not the bucket's root.
###
df_pandas = df_spark.toPandas()
bucket = "my_bucket"
path = "google/report.csv"
csv_buffer = StringIO()
df_pandas.to_csv(csv_buffer)
s3_client = boto3.client("s3")
s3_client.put_object(Body=csv_buffer.getvalue(), Bucket=bucket, Key=path)
part of role s3 access policy:
Action:
- "s3:PutObject"
- "s3:DeleteObject"
Resource:
- "arn:aws:s3:::my_bucket/google/*"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
