#4889 is a stab at this This is a duplicate of #4889  Hi @buchgr, on this project, is a PR normally considered a duplicate of the feature request which requests it? @buchgr would you consider reopening this issue? FYI -- elsewhere (issue #4789) I mentioned that S3's weak consistency model could pose problems depending on how the cache is accessed. This is no longer true as of last December: https://aws.amazon.com/blogs/aws/amazon-s3-update-strong-read-after-write-consistency/

Just wanted to cancel out any FUD I spread 😄  For anyone wanting this...

I set up a Cloudfront distribution in front of S3, with a Cloudfront Function doing basic auth (example: https://www.joshualyman.com/2022/01/add-http-basic-authentication-to-cloudfront-distributions/).

This provides both authentication and low latency. Pretty much an ideal solution, minus the normal complexity of doing anything in AWS. @pauldraper How is the S3 bucket populated with cache content?
remote/feature: support AWS S3 as a remote caching backend
We have heard from many users who want to use AWS S3 as a remote caching backend for Bazel just as they currently do with Google Cloud Storage. This is useful when running inside Travis or CircleCI (https://github.com/notnoopci/bazel-remote-proxy) as these SaaS products already run inside AWS.

From skimming over the AWS S3 API documentation it seems that the APIs are mostly compatible, except for authentication. So implementing this feature will likely just mean to add AWS authentication to Bazel.

cc: @davidstanke @alexeagle
src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java
src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java
index 4ef09ad268f260..2da0cc1203d446 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java
@@ -90,7 +90,7 @@ final class RemoteSpawnCache implements SpawnCache {
   @Override
   public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context)
       throws InterruptedException, IOException, ExecException {
-    if (!Spawns.mayBeCached(spawn)) {
+    if (!Spawns.mayBeCached(spawn) || !Spawns.mayBeExecutedRemotely(spawn)) {
       return SpawnCache.NO_RESULT_NO_STORE;
     }
     boolean checkCache = options.remoteAcceptCached;
