module Ecluse.Runtime.Aws.S3 (
buildS3Env,
) where
import Amazonka qualified as AWS
import Amazonka.S3 qualified as S3
buildS3Env :: Maybe (Bool, Text, Int) -> IO AWS.Env
buildS3Env :: Maybe (Bool, Text, Int) -> IO Env
buildS3Env Maybe (Bool, Text, Int)
mEndpoint = do
env <- (EnvNoAuth -> IO Env) -> IO Env
forall (m :: * -> *). MonadIO m => (EnvNoAuth -> m Env) -> m Env
AWS.newEnv EnvNoAuth -> IO Env
forall (m :: * -> *) (withAuth :: * -> *).
(MonadCatch m, MonadIO m, Foldable withAuth) =>
Env' withAuth -> m Env
AWS.discover
pure $ case mEndpoint of
Just (Bool, Text, Int)
endpoint -> Service -> Env -> Env
forall (withAuth :: * -> *).
Service -> Env' withAuth -> Env' withAuth
AWS.configureService ((Bool, Text, Int) -> Service
customS3Endpoint (Bool, Text, Int)
endpoint) Env
env
Maybe (Bool, Text, Int)
Nothing -> Env
env
customS3Endpoint :: (Bool, Text, Int) -> AWS.Service
customS3Endpoint :: (Bool, Text, Int) -> Service
customS3Endpoint (Bool
secure, Text
host, Int
port) =
(Bool -> ByteString -> Int -> Service -> Service
AWS.setEndpoint Bool
secure (Text -> ByteString
forall a b. ConvertUtf8 a b => a -> b
encodeUtf8 Text
host) Int
port Service
S3.defaultService)
{ AWS.s3AddressingStyle = AWS.S3AddressingStylePath
}