in hq/app/aws/support/TrustedAdvisorS3.scala [38:58]
private def addEncryptionStatus(bucket: BucketDetail, account: AwsAccount, clients: AwsClients[S3Client])(implicit ec: ExecutionContext): Attempt[Option[BucketDetail]] = {
val tryFindEncryptionStatus =
Try(Region.of(bucket.region)).map { regions =>
clients.get(account, regions).flatMap { clientWrapper =>
S3.getBucketEncryption(clientWrapper.client, bucket.bucketName)
}
}
tryFindEncryptionStatus match {
case Success(attempt) => attempt.map({
case Encrypted => Some(bucket.copy(isEncrypted = true))
case NotEncrypted => Some(bucket)
case BucketNotFound => None
})
case scala.util.Failure(_) => Attempt.Left(FailedAttempt(Failure(
s"Unrecognised region returned from Trusted Advisor for bucket ${bucket.bucketName}",
"Encryption status for this bucket was unable to be fetched due to an unrecognised region being provided by Trusted Advisor.",
500
)))
}
}