cloudstorage icon indicating copy to clipboard operation
cloudstorage copied to clipboard

`creation_date` attribute is `None` for our S3 bucket, causing an exception in `_make_container` of S3 driver.

Open wallyhall opened this issue 2 years ago • 3 comments

Steps to reproduce:

We have an S3 bucket (which, if relevant, displays a created date in the AWS console) which we are simply trying to access via StorageCloud:

        container = s3_storage.get_container("s3_bucket_name")

This throws an exception, which appears to be due to boto3 returning None for the creation_date attribute on the bucket:

  File "C:\Users\xxx.xxx\.virtualenvs\xxx\lib\site-packages\cloudstorage\drivers\amazon.py", line 302, in get_container
    return self._make_container(bucket)
  File "C:\Users\xxx.xxx\.virtualenvs\xxx\lib\site-packages\cloudstorage\drivers\amazon.py", line 218, in _make_container
    created_at = bucket.creation_date.astimezone(tz=None)
AttributeError: 'NoneType' object has no attribute 'astimezone'

Debugging and stepping into CloudStorage confirms the creation_date returned by boto3 is None.

Is it possible to handle this more gracefully, perhaps by just copying the None rather than assuming it's a valid DateTime?

wallyhall avatar Jul 22 '21 17:07 wallyhall

i have the same problem this is my output : Driver name null or not found ('NoneType' object has no attribute 'astimezone') please tell me if you find solution

Nour-elislam avatar Aug 04 '21 12:08 Nour-elislam

I did locate the cause of boto3 not returning the creation_date. I wouldn't call it a fix per se - more of a workaround.

Granting additional permissions to the IAM made the symptom go away:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "xxxxxxxxxxxx",
            "Effect": "Allow",
            "Action": "s3:ListBucket",
            "Resource": "arn:aws:s3:::*"
        },
        {
            "Sid": "xxxxxxxxxxxx",
            "Effect": "Allow",
            "Action": "s3:ListAllMyBuckets",
            "Resource": "*"
        }
    ]
}

wallyhall avatar Aug 04 '21 13:08 wallyhall

thank you, that's work fine now 👍

Nour-elislam avatar Aug 05 '21 12:08 Nour-elislam