Determining whether you can access a directory bucket
The following Amazon SDK examples show how to use the HeadBucket API operation
        to determine if an Amazon S3 directory bucket exists and if you have permission to access it. 
The following Amazon SDK for Java 2.x example shows how to determine if a bucket exists and if you have permission to access it.
The following head-bucket example command shows how you can use the
                Amazon CLI to determine if a directory bucket exists and if you have permission to access
                it. To run this command, replace the user input placeholders with your own information.
aws s3api head-bucket --bucketbucket-base-name--zone-id--x-s3
For more information, see head-bucket