Open todokr opened 6 years ago
What kind environment is this (local, dev, prod)? It seems to me your key is getting expired. We do see similar behavior when accessing AWS dev account from local, what we have is profile based authentication but it is time based and if we are running long running task profile get expired and gets error that could not load profile from any chain.
@sfali Thanks for comment!
This happened in dev and prod. So our app accesses to S3 using IAM Role, provided credential may get expired while streaming as you mentioned.
So it can be avoided to generate S3Client
for every each starting of sub stream like below. I' ll try :D
val s3Client = new akka.stream.alpakka.s3.scaladsl.S3Client(settings)
s3Client.listBucket(bucketName, Some(s3Key)).filter(!_.key.endsWith("/"))
.flatMapConcat {
val clientForSubStream = new akka.stream.alpakka.s3.scaladsl.S3Client(settings)
s3Obj => clientForSubStream.download(bucketName, s3Obj.key)
}.via(someFlow)
.runWith(FileIO.toPath(path))
I've just come across this issue today and my problem was related the way I was creating the client:
private val settings = new S3Settings(
bufferType = MemoryBufferType,
proxy = None,
credentialsProvider = awsCredentialsProvider,
s3RegionProvider = regionProvider,
pathStyleAccess = false,
endpointUrl = None,
listBucketApiVersion = ListBucketVersion2
)
new S3Client(settings)(system, materializer)
Changing to the following, worked for me:
S3Client(awsCredentialsProvider, regionProvider)
We are also seeing this issue intermittently when we rely on IAM EC2 role based authentication. May be we should configure async refresh of credentials (also see aws/aws-sdk-java#884) which would then refresh the credential in the background.
It may be happening due to clock skew the default refresh logic may misfire (which happens on per access basis and also does a synchronized access). Would see if switching to that helps or not
The versions is below: akka-stream-alpakka-s3:
0.16
scala:2.11.7
JDK:1.8
I use S3 connector to stream 300 ~ 400 S3 objects at a time with flatMapConcat like this.
Usually it works well, but rarely fails to process due to absence of access key.
I have no idea why access key becomes absent occasionally. Is there any wrong in my code? Thank you!