Create anonymous clients in the SDK for PHP - AWS SDK for PHP
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

Create anonymous clients in the SDK for PHP

In some cases, you might want to create a client that is not associated with any credentials. This enables you to make anonymous requests to a service.

For example, you can configure both Amazon S3 objects and Amazon CloudSearch domains to allow anonymous access.

To create an anonymous client, you set the 'credentials' option to false.

$s3Client = new S3Client([ 'version' => 'latest', 'region' => 'us-west-2', 'credentials' => false ]); // Makes an anonymous request. The object would need to be publicly // readable for this to succeed. $result = $s3Client->getObject([ 'Bucket' => 'amzn-s3-demo-bucket', 'Key' => 'my-key', ]);