list-buckets s3api is not showing my bucket creation date?

Viewed 1087

I want to get my s3 bucket creation dates using s3api . But it is not showing the creation date that it is showing in aws console.

When i tried with cli the output is like this

C:\Users\hero>aws s3api list-buckets
{
    "Buckets": [
        {
            "CreationDate": "2018-09-12T11:32:04.000Z",
            "Name": "campaign-app-api-prod-serverlessdeploymentbucket-"
        },
        {
            "CreationDate": "2018-09-12T10:06:44.000Z",
            "Name": "s3-api-log-events"
        }
    ]
}

In console

this is the my aws console

Why am i getting different dates in s3api. Is my CreationDate interpretation of is wrong ?

Any help is appreciated.

Thanks

2 Answers

The Date Created field displayed in the web console is according to the actual creation date registered in us-east-1, while the AWS CLI and SDKs will display the creation date depending on the specified region (or the default region set in your configuration).

When using an endpoint other than us-east-1, the CreationDate you receive is actually the last modified time according to the bucket's last replication time in this region. This date can change when making changes to your bucket, such as editing its bucket policy.

So, to get the CreationDates of the buckets that are in s3 console then you need to give the region us-east-1 .

Try like this in aws cli aws s3api list-buckets --region "us-east-1"

Checkout this github issue

This python script:

import boto3

client=boto3.client('s3')

response=client.list_buckets()

returns the same dates as the AWS CLI and s3cmd. Therefore, it is not a bug in the CLI/s3cmd. Instead, it is different information coming from the Amazon S3 API call. So, I'm not sure where the console gets the 'correct' dates.

If there is a bug anywhere, it would be in the ListBuckets API call to AWS. This is best raised with AWS Support.

Related