libZSamazonkaZSamazonka
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka

Description

This module provides simple Env and IO-based operations which can be performed against remote Amazon Web Services APIs, for use with the types supplied by the various amazonka-* libraries.

Synopsis

Usage

The key functions dealing with the request/response lifecycle are:

These functions have constraints that types from the amazonka-* libraries satisfy. To utilise these, you will need to specify what Region you wish to operate in and your Amazon credentials for AuthN/AuthZ purposes.

Credentials can be supplied in a number of ways. Either via explicit keys, via session profiles, or have Amazonka retrieve the credentials from an underlying IAM Role/Profile.

As a basic example, you might wish to store an object in an S3 bucket using amazonka-s3:

{-# LANGUAGE OverloadedStrings #-}

import qualified Amazonka as AWS
import qualified Amazonka.S3 as S3
import qualified System.IO as IO

example :: IO S3.PutObjectResponse
example = do
    -- A new Logger to replace the default noop logger is created, with the logger
    -- set to print debug information and errors to stdout:
    logger <- AWS.newLogger AWS.Debug IO.stdout

    -- To specify configuration preferences, newEnv is used to create a new
    -- configuration environment. The Credentials parameter is used to specify
    -- mechanism for supplying or retrieving AuthN/AuthZ information.
    -- In this case Discover will cause the library to try a number of options such
    -- as default environment variables, or an instance's IAM Profile and identity document:
    discover <- AWS.newEnv AWS.Discover

    let env =
            discover
                { AWS._envLogger = logger
                , AWS._envRegion = AWS.Frankfurt
                }

    -- The payload (and hash) for the S3 object is retrieved from a FilePath,
    -- either hashedFile or chunkedFile can be used, with the latter ensuring
    -- the contents of the file is enumerated exactly once, during send:
    body <- AWS.chunkedFile AWS.defaultChunkSize "local/path/to/object-payload"

    -- We now run the AWS computation with the overriden logger, performing the
    -- PutObject request. $sel:_envRegion:Env or within can be used to set the
    -- remote AWS Region:
    AWS.runResourceT $
        AWS.send env (S3.newPutObject "bucket-name" "object-key" body)

Authentication and Environment

data Env' withAuth Source #

The environment containing the parameters required to make AWS requests.

This type tracks whether or not we have credentials at the type level, to avoid "presigning" requests when we lack auth information.

Instances

Instances details
Generic (Env' withAuth) Source # 
Instance details

Defined in Amazonka.Auth

Associated Types

type Rep (Env' withAuth) :: Type -> Type #

Methods

from :: Env' withAuth -> Rep (Env' withAuth) x #

to :: Rep (Env' withAuth) x -> Env' withAuth #

type Rep (Env' withAuth) Source # 
Instance details

Defined in Amazonka.Auth

newEnv Source #

Arguments

:: MonadIO m 
=> Credentials

Credential discovery mechanism.

-> m Env 

Creates a new environment with a new Manager without debug logging and uses getAuth to expand/discover the supplied Credentials. Lenses can be used to further configure the resulting Env.

Since: 1.5.0 - The region is now retrieved from the AWS_REGION environment variable (identical to official SDKs), or defaults to us-east-1. You can override the Env region by using envRegion, or the current operation's region by using within.

Since: 1.3.6 - The default logic for retrying HttpExceptions now uses retryConnectionFailure to retry specific connection failure conditions up to 3 times. Previously only service specific errors were automatically retried. This can be reverted to the old behaviour by resetting the Env using envRetryCheck lens to (\_ _ -> False).

Throws AuthError when environment variables or IAM profiles cannot be read.

See: newEnvWith.

newEnvNoAuth :: MonadIO m => m EnvNoAuth Source #

Generate an environment without credentials, which may only make unsigned requests.

This is useful for the STS AssumeRoleWithWebIdentity operation, which needs to make an unsigned request to pass the token from an identity provider.

newEnvWith :: Manager -> EnvNoAuth Source #

Construct a default EnvNoAuth from a HTTP Manager.

envAuthMaybe :: Foldable withAuth => Env' withAuth -> Maybe Auth Source #

Get "the" Auth from an Env', if we can.

Service Configuration

When a request is sent, various values such as the endpoint, retry strategy, timeout and error handlers are taken from the associated Service for a request. For example, DynamoDB will use the defaultService configuration when sending PutItem, Query and all other operations.

You can modify a specific Service's default configuration by using configure or reconfigure. To modify all configurations simultaneously, see override.

An example of how you might alter default configuration using these mechanisms is demonstrated below. Firstly, the default dynamoDB service is configured to use non-SSL localhost as the endpoint:

import qualified Amazonka as AWS
import qualified Amazonka.DynamoDB as Dynamo

let dynamo :: AWS.Service
    dynamo = AWS.setEndpoint False "localhost" 8000 DynamoDB.defaultService

The updated configuration is then passed to the Env during setup:

env <- AWS.configure dynamo <$> AWS.newEnv AWS.Discover

AWS.runResourceT $ do
    -- This S3 operation will communicate with remote AWS APIs.
    x <- AWS.send env newListBuckets

    -- DynamoDB operations will communicate with localhost:8000.
    y <- AWS.send env Dynamo.newListTables

    -- Any operations for services other than DynamoDB, are not affected.
    ...

You can also scope the service configuration modifications to specific actions:

env <- AWS.newEnv AWS.Discover

AWS.runResourceT $ do
    -- Service operations here will communicate with AWS, even remote DynamoDB.
    x <- AWS.send env Dynamo.newListTables

    -- Here DynamoDB operations will communicate with localhost:8000.
    y <- AWS.send (AWS.configure dynamo env) Dynamo.newListTables

Functions such as within, once, and timeout can also be used to modify service configuration for all (or specific) requests.

authenticate Source #

Arguments

:: (MonadIO m, Foldable withAuth) 
=> Credentials

Credential discovery mechanism.

-> Env' withAuth

Previous environment.

-> m Env 

See: newEnv

Throws AuthError when environment variables or IAM profiles cannot be read.

override :: (Service -> Service) -> Env -> Env Source #

Provide a function which will be added to the existing stack of overrides applied to all service configurations.

configure :: Service -> Env -> Env Source #

Configure a specific service. All requests belonging to the supplied service will use this configuration instead of the default.

It's suggested you modify the default service configuration, such as Amazonka.DynamoDB.dynamoDB.

within :: Region -> Env -> Env Source #

Scope an action within the specific Region.

once :: Env -> Env Source #

Scope an action such that any retry logic for the Service is ignored and any requests will at most be sent once.

timeout :: Seconds -> Env -> Env Source #

Scope an action such that any HTTP response will use this timeout value.

Default timeouts are chosen by considering:

Lenses

envAuth :: Lens (Env' withAuth) (Env' withAuth') (withAuth Auth) (withAuth' Auth) Source #

Running AWS Actions

runResourceT :: MonadUnliftIO m => ResourceT m a -> m a #

Unwrap a ResourceT transformer, and call all registered release actions.

Note that there is some reference counting involved due to resourceForkIO. If multiple threads are sharing the same collection of resources, only the last call to runResourceT will deallocate the resources.

NOTE Since version 1.2.0, this function will throw a ResourceCleanupException if any of the cleanup functions throw an exception.

Since: resourcet-0.3.0

Credential Discovery

newtype AccessKey #

An access key ID.

For example: AKIAIOSFODNN7EXAMPLE

See: Understanding and Getting Your Security Credentials.

Constructors

AccessKey ByteString 

Instances

Instances details
Eq AccessKey 
Instance details

Defined in Amazonka.Types

Read AccessKey 
Instance details

Defined in Amazonka.Types

Show AccessKey 
Instance details

Defined in Amazonka.Types

IsString AccessKey 
Instance details

Defined in Amazonka.Types

Generic AccessKey 
Instance details

Defined in Amazonka.Types

Associated Types

type Rep AccessKey :: Type -> Type #

NFData AccessKey 
Instance details

Defined in Amazonka.Types

Methods

rnf :: AccessKey -> () #

Hashable AccessKey 
Instance details

Defined in Amazonka.Types

ToJSON AccessKey 
Instance details

Defined in Amazonka.Types

FromJSON AccessKey 
Instance details

Defined in Amazonka.Types

ToLog AccessKey 
Instance details

Defined in Amazonka.Types

ToQuery AccessKey 
Instance details

Defined in Amazonka.Types

FromXML AccessKey 
Instance details

Defined in Amazonka.Types

ToXML AccessKey 
Instance details

Defined in Amazonka.Types

Methods

toXML :: AccessKey -> XML #

ToByteString AccessKey 
Instance details

Defined in Amazonka.Types

Methods

toBS :: AccessKey -> ByteString #

FromText AccessKey 
Instance details

Defined in Amazonka.Types

ToText AccessKey 
Instance details

Defined in Amazonka.Types

Methods

toText :: AccessKey -> Text #

type Rep AccessKey 
Instance details

Defined in Amazonka.Types

type Rep AccessKey = D1 ('MetaData "AccessKey" "Amazonka.Types" "libZSamazonka-coreZSamazonka-core" 'True) (C1 ('MetaCons "AccessKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

newtype SecretKey #

Secret access key credential.

For example: wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKE

See: Understanding and Getting Your Security Credentials.

Constructors

SecretKey ByteString 

Instances

Instances details
Eq SecretKey 
Instance details

Defined in Amazonka.Types

IsString SecretKey 
Instance details

Defined in Amazonka.Types

Generic SecretKey 
Instance details

Defined in Amazonka.Types

Associated Types

type Rep SecretKey :: Type -> Type #

NFData SecretKey 
Instance details

Defined in Amazonka.Types

Methods

rnf :: SecretKey -> () #

Hashable SecretKey 
Instance details

Defined in Amazonka.Types

ToJSON SecretKey 
Instance details

Defined in Amazonka.Types

FromJSON SecretKey 
Instance details

Defined in Amazonka.Types

FromXML SecretKey 
Instance details

Defined in Amazonka.Types

ToXML SecretKey 
Instance details

Defined in Amazonka.Types

Methods

toXML :: SecretKey -> XML #

ToByteString SecretKey 
Instance details

Defined in Amazonka.Types

Methods

toBS :: SecretKey -> ByteString #

FromText SecretKey 
Instance details

Defined in Amazonka.Types

ToText SecretKey 
Instance details

Defined in Amazonka.Types

Methods

toText :: SecretKey -> Text #

type Rep SecretKey 
Instance details

Defined in Amazonka.Types

type Rep SecretKey = D1 ('MetaData "SecretKey" "Amazonka.Types" "libZSamazonka-coreZSamazonka-core" 'True) (C1 ('MetaCons "SecretKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

newtype SessionToken #

A session token used by STS to temporarily authorise access to an AWS resource.

See: Temporary Security Credentials.

Constructors

SessionToken ByteString 

Instances

Instances details
Eq SessionToken 
Instance details

Defined in Amazonka.Types

IsString SessionToken 
Instance details

Defined in Amazonka.Types

Generic SessionToken 
Instance details

Defined in Amazonka.Types

Associated Types

type Rep SessionToken :: Type -> Type #

NFData SessionToken 
Instance details

Defined in Amazonka.Types

Methods

rnf :: SessionToken -> () #

Hashable SessionToken 
Instance details

Defined in Amazonka.Types

ToJSON SessionToken 
Instance details

Defined in Amazonka.Types

FromJSON SessionToken 
Instance details

Defined in Amazonka.Types

FromXML SessionToken 
Instance details

Defined in Amazonka.Types

ToXML SessionToken 
Instance details

Defined in Amazonka.Types

Methods

toXML :: SessionToken -> XML #

ToByteString SessionToken 
Instance details

Defined in Amazonka.Types

FromText SessionToken 
Instance details

Defined in Amazonka.Types

ToText SessionToken 
Instance details

Defined in Amazonka.Types

Methods

toText :: SessionToken -> Text #

type Rep SessionToken 
Instance details

Defined in Amazonka.Types

type Rep SessionToken = D1 ('MetaData "SessionToken" "Amazonka.Types" "libZSamazonka-coreZSamazonka-core" 'True) (C1 ('MetaCons "SessionToken" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

data Credentials Source #

Determines how AuthN/AuthZ information is retrieved.

Constructors

FromKeys AccessKey SecretKey

Explicit access and secret keys. See fromKeys.

FromSession AccessKey SecretKey SessionToken

Explicit access key, secret key and a session token. See fromSession.

FromEnv Text Text (Maybe Text) (Maybe Text)

Lookup specific environment variables for access key, secret key, an optional session token, and an optional region, respectively.

FromProfile Text

An IAM Profile name to lookup from the local EC2 instance-data. Environment variables to lookup for the access key, secret key and optional session token.

FromFile Text FilePath FilePath

A credentials profile name (the INI section), the path to the AWS credentials file, and the path to the ~.awsconfig file.

FromWebIdentity

Obtain credentials using STS:AssumeRoleWithWebIdentity See About web identity federation in the AWS documentation for more information.

FromContainer

Obtain credentials by attempting to contact the ECS container agent at http://169.254.170.2 using the path in envContainerCredentialsURI. See IAM Roles for Tasks in the AWS documentation for more information.

Discover

Attempt credentials discovery via the following steps:

  • Read the envAccessKey, envSecretKey, and envRegion from the environment if they are set.
  • Read the credentials file if credFile exists.
  • Try to exchange a Web Identity for AWS credentials using sts:AssumeRoleWithWebIdentity.
  • Obtain credentials from the ECS container agent if envContainerCredentialsURI is set.
  • Retrieve the first available IAM profile and read the Region from the instance identity document, if running on EC2.

An attempt is made to resolve http://instance-data rather than directly retrieving http://169.254.169.254 for IAM profile information. This assists in ensuring the DNS lookup terminates promptly if not running on EC2.

Instances

Instances details
Eq Credentials Source # 
Instance details

Defined in Amazonka.Auth

Show Credentials Source # 
Instance details

Defined in Amazonka.Auth

Generic Credentials Source # 
Instance details

Defined in Amazonka.Auth

Associated Types

type Rep Credentials :: Type -> Type #

ToLog Credentials Source # 
Instance details

Defined in Amazonka.Auth

type Rep Credentials Source # 
Instance details

Defined in Amazonka.Auth

type Rep Credentials = D1 ('MetaData "Credentials" "Amazonka.Auth" "libZSamazonkaZSamazonka" 'False) (((C1 ('MetaCons "FromKeys" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 AccessKey) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SecretKey)) :+: C1 ('MetaCons "FromSession" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 AccessKey) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SecretKey) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SessionToken)))) :+: (C1 ('MetaCons "FromEnv" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)))) :+: C1 ('MetaCons "FromProfile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)))) :+: ((C1 ('MetaCons "FromFile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 FilePath) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 FilePath))) :+: C1 ('MetaCons "FromWebIdentity" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "FromContainer" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Discover" 'PrefixI 'False) (U1 :: Type -> Type))))

AuthN/AuthZ information is handled similarly to other AWS SDKs. You can read some of the options available here.

When running on an EC2 instance and using FromProfile or Discover, a thread is forked which transparently handles the expiry and subsequent refresh of IAM profile information. See fromProfileName for more information.

Supported Regions

newtype Region #

The available AWS regions.

Constructors

Region' 

Fields

Bundled Patterns

pattern Mumbai :: Region 
pattern Sydney :: Region 
pattern Singapore :: Region 
pattern Osaka :: Region 
pattern Seoul :: Region 
pattern Tokyo :: Region 
pattern HongKong :: Region 
pattern Ningxia :: Region 
pattern Beijing :: Region 
pattern CapeTown :: Region 
pattern Bahrain :: Region 
pattern Stockholm :: Region 
pattern Paris :: Region 
pattern Milan :: Region 
pattern London :: Region 
pattern Ireland :: Region 
pattern Frankfurt :: Region 
pattern SaoPaulo :: Region 
pattern Montreal :: Region 
pattern GovCloudEast :: Region 
pattern GovCloudWest :: Region 
pattern Oregon :: Region 
pattern NorthCalifornia :: Region 
pattern Ohio :: Region 
pattern NorthVirginia :: Region 

Instances

Instances details
Eq Region 
Instance details

Defined in Amazonka.Types

Methods

(==) :: Region -> Region -> Bool #

(/=) :: Region -> Region -> Bool #

Ord Region 
Instance details

Defined in Amazonka.Types

Read Region 
Instance details

Defined in Amazonka.Types

Show Region 
Instance details

Defined in Amazonka.Types

IsString Region 
Instance details

Defined in Amazonka.Types

Methods

fromString :: String -> Region #

Generic Region 
Instance details

Defined in Amazonka.Types

Associated Types

type Rep Region :: Type -> Type #

Methods

from :: Region -> Rep Region x #

to :: Rep Region x -> Region #

NFData Region 
Instance details

Defined in Amazonka.Types

Methods

rnf :: Region -> () #

Hashable Region 
Instance details

Defined in Amazonka.Types

Methods

hashWithSalt :: Int -> Region -> Int #

hash :: Region -> Int #

ToJSON Region 
Instance details

Defined in Amazonka.Types

FromJSON Region 
Instance details

Defined in Amazonka.Types

ToLog Region 
Instance details

Defined in Amazonka.Types

ToQuery Region 
Instance details

Defined in Amazonka.Types

FromXML Region 
Instance details

Defined in Amazonka.Types

ToXML Region 
Instance details

Defined in Amazonka.Types

Methods

toXML :: Region -> XML #

ToByteString Region 
Instance details

Defined in Amazonka.Types

Methods

toBS :: Region -> ByteString #

FromText Region 
Instance details

Defined in Amazonka.Types

ToText Region 
Instance details

Defined in Amazonka.Types

Methods

toText :: Region -> Text #

type Rep Region 
Instance details

Defined in Amazonka.Types

type Rep Region = D1 ('MetaData "Region" "Amazonka.Types" "libZSamazonka-coreZSamazonka-core" 'True) (C1 ('MetaCons "Region'" 'PrefixI 'True) (S1 ('MetaSel ('Just "fromRegion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

Service Endpoints

data Endpoint #

Instances

Instances details
Eq Endpoint 
Instance details

Defined in Amazonka.Types

Show Endpoint 
Instance details

Defined in Amazonka.Types

setEndpoint #

Arguments

:: Bool

Whether to use HTTPS (ie. SSL).

-> ByteString

The hostname to connect to.

-> Int

The port number to connect to.

-> Service

The service configuration to override.

-> Service 

A convenience function for overriding the Service Endpoint.

See: serviceEndpoint.

Sending Requests

To send a request you need to create a value of the desired operation type using the relevant constructor, as well as any further modifications of default/optional parameters using the appropriate lenses. This value can then be sent using send or paginate and the library will take care of serialisation/authentication and so forth.

The default Service configuration for a request contains retry configuration that is used to determine if a request can safely be retried and what kind of back off/on strategy should be used. (Usually exponential.) Typically services define retry strategies that handle throttling, general server errors and transport errors. Streaming requests are never retried.

send :: (MonadResource m, AWSRequest a) => Env -> a -> m (AWSResponse a) Source #

Send a request, returning the associated response if successful.

Errors are thrown in IO.

See sendEither.

sendEither :: (MonadResource m, AWSRequest a) => Env -> a -> m (Either Error (AWSResponse a)) Source #

Send a request, returning the associated response if successful.

See send.

Pagination

Some AWS operations return results that are incomplete and require subsequent requests in order to obtain the entire result set. The process of sending subsequent requests to continue where a previous request left off is called pagination. For example, the ListObjects operation of Amazon S3 returns up to 1000 objects at a time, and you must send subsequent requests with the appropriate Marker in order to retrieve the next page of results.

Operations that have an AWSPager instance can transparently perform subsequent requests, correctly setting Markers and other request facets to iterate through the entire result set of a truncated API operation. Operations which support this have an additional note in the documentation.

Many operations have the ability to filter results on the server side. See the individual operation parameters for details.

paginate :: (MonadResource m, AWSPager a) => Env -> a -> ConduitM () (AWSResponse a) m () Source #

Repeatedly send a request, automatically setting markers and performing pagination. Exits on the first encountered error.

Errors are thrown in IO.

See paginateEither.

paginateEither :: (MonadResource m, AWSPager a) => Env -> a -> ConduitM () (AWSResponse a) m (Either Error ()) Source #

Repeatedly send a request, automatically setting markers and performing pagination.

Exits on the first encountered error.

See paginate.

Waiters

Waiters poll by repeatedly sending a request until some remote success condition configured by the Wait specification is fulfilled. The Wait specification determines how many attempts should be made, in addition to delay and retry strategies. Error conditions that are not handled by the Wait configuration will be thrown, or the first successful response that fulfills the success condition will be returned.

Wait specifications can be found under the Amazonka.{ServiceName}.Waiters namespace for services which support await.

await :: (MonadResource m, AWSRequest a) => Env -> Wait a -> a -> m Accept Source #

Poll the API with the supplied request until a specific Wait condition is fulfilled.

Errors are thrown in IO.

See awaitEither.

awaitEither :: (MonadResource m, AWSRequest a) => Env -> Wait a -> a -> m (Either Error Accept) Source #

Poll the API with the supplied request until a specific Wait condition is fulfilled.

See await.

Streaming

Streaming comes in two flavours. HashedBody represents a request that requires a precomputed SHA256 hash, or a ChunkedBody type for those services that can perform incremental signing and do not require the entire payload to be hashed (such as S3). The type signatures for request smart constructors advertise which respective body type is required, denoting the underlying signing capabilities.

ToHashedBody and ToBody typeclass instances are available to construct the streaming bodies, automatically calculating any hash or size as needed for types such as Text, ByteString, or Aeson's Value type. To read files and other IO primitives, functions such as hashedFile, chunkedFile, or hashedBody should be used.

For responses that contain streaming bodies (such as GetObject), you can use sinkBody to connect the response body to a conduit-compatible sink.

class ToBody a where #

Anything that can be converted to a streaming request Body.

Minimal complete definition

Nothing

Methods

toBody :: a -> RequestBody #

Convert a value to a request body.

Instances

Instances details
ToBody String 
Instance details

Defined in Amazonka.Data.Body

Methods

toBody :: String -> RequestBody #

ToBody ByteString 
Instance details

Defined in Amazonka.Data.Body

ToBody Text 
Instance details

Defined in Amazonka.Data.Body

Methods

toBody :: Text -> RequestBody #

ToBody Value 
Instance details

Defined in Amazonka.Data.Body

Methods

toBody :: Value -> RequestBody #

ToBody Element 
Instance details

Defined in Amazonka.Data.Body

ToBody Base64 
Instance details

Defined in Amazonka.Data.Base64

Methods

toBody :: Base64 -> RequestBody #

ToBody ChunkedBody 
Instance details

Defined in Amazonka.Data.Body

ToBody HashedBody 
Instance details

Defined in Amazonka.Data.Body

ToBody RequestBody 
Instance details

Defined in Amazonka.Data.Body

ToBody QueryString 
Instance details

Defined in Amazonka.Data.Body

ToBody TextLazy 
Instance details

Defined in Amazonka.Data.Body

ToBody ByteStringLazy 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody a => ToBody (Maybe a) 
Instance details

Defined in Amazonka.Data.Body

Methods

toBody :: Maybe a -> RequestBody #

ToBody a => ToBody (Sensitive a) 
Instance details

Defined in Amazonka.Data.Sensitive

Methods

toBody :: Sensitive a -> RequestBody #

ToBody (HashMap Text Value) 
Instance details

Defined in Amazonka.Data.Body

data RequestBody #

Invariant: only services that support _both_ standard and chunked signing expose RequestBody as a parameter.

Instances

Instances details
Show RequestBody 
Instance details

Defined in Amazonka.Data.Body

IsString RequestBody 
Instance details

Defined in Amazonka.Data.Body

ToBody RequestBody 
Instance details

Defined in Amazonka.Data.Body

newtype ResponseBody #

A streaming, exception safe response body.

Constructors

ResponseBody 

Instances

Instances details
Show ResponseBody 
Instance details

Defined in Amazonka.Data.Body

Hashed Request Bodies

class ToHashedBody a where #

Anything that can be safely converted to a HashedBody.

Methods

toHashed :: a -> HashedBody #

Convert a value to a hashed request body.

Instances

Instances details
ToHashedBody String 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody ByteString 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody Text 
Instance details

Defined in Amazonka.Data.Body

Methods

toHashed :: Text -> HashedBody #

ToHashedBody Value 
Instance details

Defined in Amazonka.Data.Body

Methods

toHashed :: Value -> HashedBody #

ToHashedBody Element 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody Base64 
Instance details

Defined in Amazonka.Data.Base64

ToHashedBody HashedBody 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody QueryString 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody TextLazy 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody ByteStringLazy 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody (HashMap Text Value) 
Instance details

Defined in Amazonka.Data.Body

data HashedBody #

An opaque request body containing a SHA256 hash.

Instances

Instances details
Show HashedBody 
Instance details

Defined in Amazonka.Data.Body

IsString HashedBody 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody HashedBody 
Instance details

Defined in Amazonka.Data.Body

ToBody HashedBody 
Instance details

Defined in Amazonka.Data.Body

hashedFile #

Arguments

:: MonadIO m 
=> FilePath

The file path to read.

-> m HashedBody 

Construct a HashedBody from a FilePath, calculating the SHA256 hash and file size.

Note: While this function will perform in constant space, it will enumerate the entirety of the file contents _twice_. Firstly to calculate the SHA256 and lastly to stream the contents to the socket during sending.

See: ToHashedBody.

hashedFileRange #

Arguments

:: MonadIO m 
=> FilePath

The file path to read.

-> Integer

The byte offset at which to start reading.

-> Integer

The maximum number of bytes to read.

-> m HashedBody 

Construct a HashedBody from a FilePath, specifying the range of bytes to read. This can be useful for constructing multiple requests from a single file, say for S3 multipart uploads.

See: hashedFile, sourceFileRange.

hashedBody #

Arguments

:: Digest SHA256

A SHA256 hash of the file contents.

-> Integer

The size of the stream in bytes.

-> ConduitM () ByteString (ResourceT IO) () 
-> HashedBody 

Construct a HashedBody from a Source, manually specifying the SHA256 hash and file size. It's left up to the caller to calculate these correctly, otherwise AWS will return signing errors.

See: ToHashedBody.

Chunked Request Bodies

data ChunkedBody #

An opaque request body which will be transmitted via Transfer-Encoding: chunked.

Invariant: Only services that support chunked encoding can accept a ChunkedBody. (Currently S3.) This is enforced by the type signatures emitted by the generator.

Instances

Instances details
Show ChunkedBody 
Instance details

Defined in Amazonka.Data.Body

ToBody ChunkedBody 
Instance details

Defined in Amazonka.Data.Body

newtype ChunkSize #

Specifies the transmitted size of the 'Transfer-Encoding' chunks.

See: defaultChunk.

Constructors

ChunkSize Int 

Instances

Instances details
Enum ChunkSize 
Instance details

Defined in Amazonka.Data.Body

Eq ChunkSize 
Instance details

Defined in Amazonka.Data.Body

Integral ChunkSize 
Instance details

Defined in Amazonka.Data.Body

Num ChunkSize 
Instance details

Defined in Amazonka.Data.Body

Ord ChunkSize 
Instance details

Defined in Amazonka.Data.Body

Real ChunkSize 
Instance details

Defined in Amazonka.Data.Body

Show ChunkSize 
Instance details

Defined in Amazonka.Data.Body

ToLog ChunkSize 
Instance details

Defined in Amazonka.Data.Body

defaultChunkSize :: ChunkSize #

The default chunk size of 128 KB. The minimum chunk size accepted by AWS is 8 KB, unless the entirety of the request is below this threshold.

A chunk size of 64 KB or higher is recommended for performance reasons.

chunkedFile :: MonadIO m => ChunkSize -> FilePath -> m RequestBody #

Construct a ChunkedBody from a FilePath, where the contents will be read and signed incrementally in chunks if the target service supports it.

Will intelligently revert to HashedBody if the file is smaller than the specified ChunkSize.

See: ToBody.

chunkedFileRange #

Arguments

:: MonadIO m 
=> ChunkSize

The idealized size of chunks that will be yielded downstream.

-> FilePath

The file path to read.

-> Integer

The byte offset at which to start reading.

-> Integer

The maximum number of bytes to read.

-> m RequestBody 

Construct a ChunkedBody from a FilePath, specifying the range of bytes to read. This can be useful for constructing multiple requests from a single file, say for S3 multipart uploads.

See: chunkedFile.

unsafeChunkedBody #

Arguments

:: ChunkSize

The idealized size of chunks that will be yielded downstream.

-> Integer

The size of the stream in bytes.

-> ConduitM () ByteString (ResourceT IO) () 
-> RequestBody 

Unsafely construct a ChunkedBody.

This function is marked unsafe because it does nothing to enforce the chunk size. Typically for conduit IO functions, it's whatever ByteString's defaultBufferSize is, around 32 KB. If the chunk size is less than 8 KB, the request will error. 64 KB or higher chunk size is recommended for performance reasons.

Note that it will always create a chunked body even if the request is too small.

See: ToBody.

Response Bodies

sinkBody :: MonadIO m => ResponseBody -> ConduitM ByteString Void (ResourceT IO) a -> m a #

Connect a Sink to a response stream.

File Size and MD5/SHA256

getFileSize :: MonadIO m => FilePath -> m Integer #

Convenience function for obtaining the size of a file.

sinkMD5 :: forall (m :: Type -> Type) o. Monad m => ConduitM ByteString o m (Digest MD5) #

Incrementally calculate a MD5 Digest.

sinkSHA256 :: forall (m :: Type -> Type) o. Monad m => ConduitM ByteString o m (Digest SHA256) #

Incrementally calculate a SHA256 Digest.

Presigning Requests

Presigning requires the Service signer to be an instance of AWSPresigner. Not all signing algorithms support this.

presignURL Source #

Arguments

:: (MonadIO m, AWSRequest a) 
=> Env 
-> UTCTime

Signing time.

-> Seconds

Expiry time.

-> a

Request to presign.

-> m ByteString 

Presign an URL that is valid from the specified time until the number of seconds expiry has elapsed.

presign Source #

Arguments

:: (MonadIO m, AWSRequest a) 
=> Env 
-> UTCTime

Signing time.

-> Seconds

Expiry time.

-> a

Request to presign.

-> m ClientRequest 

Presign an HTTP request that is valid from the specified time until the number of seconds expiry has elapsed.

EC2 Instance Metadata

Metadata can be retrieved from the underlying host assuming that you're running the code on an EC2 instance or have a compatible instance-data endpoint available.

data Dynamic Source #

Constructors

FWS

Value showing whether the customer has enabled detailed one-minute monitoring in CloudWatch.

Valid values: enabled | disabled.

Document

JSON containing instance attributes, such as instance-id, private IP address, etc. See: identity, InstanceDocument.

PKCS7

Used to verify the document's authenticity and content against the signature.

Signature 

Instances

Instances details
Eq Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

(==) :: Dynamic -> Dynamic -> Bool #

(/=) :: Dynamic -> Dynamic -> Bool #

Ord Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Show Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Generic Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Associated Types

type Rep Dynamic :: Type -> Type #

Methods

from :: Dynamic -> Rep Dynamic x #

to :: Rep Dynamic x -> Dynamic #

ToText Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

toText :: Dynamic -> Text #

type Rep Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

type Rep Dynamic = D1 ('MetaData "Dynamic" "Amazonka.EC2.Metadata" "libZSamazonkaZSamazonka" 'False) ((C1 ('MetaCons "FWS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Document" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PKCS7" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Signature" 'PrefixI 'False) (U1 :: Type -> Type)))

dynamic :: MonadIO m => Env -> Dynamic -> m ByteString Source #

Retrieve the specified Dynamic data.

data Metadata Source #

Constructors

AMIId

The AMI ID used to launch the instance.

AMILaunchIndex

If you started more than one instance at the same time, this value indicates the order in which the instance was launched. The value of the first instance launched is 0.

AMIManifestPath

The path to the AMI's manifest file in Amazon S3. If you used an Amazon EBS-backed AMI to launch the instance, the returned result is unknown.

AncestorAMIIds

The AMI IDs of any instances that were rebundled to create this AMI. This value will only exist if the AMI manifest file contained an ancestor-amis key.

BlockDevice !Mapping

See: Mapping

Hostname

The private hostname of the instance. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which the device number is 0).

IAM !Info

See: Info

InstanceAction

Notifies the instance that it should reboot in preparation for bundling. Valid values: none | shutdown | bundle-pending.

InstanceId

The ID of this instance.

InstanceType

The type of instance.

See: InstanceType

KernelId

The ID of the kernel launched with this instance, if applicable.

LocalHostname

The private DNS hostname of the instance. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which the device number is 0).

LocalIPV4

The private IP address of the instance. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which the device number is 0).

MAC

The instance's media access control (MAC) address. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which the device number is 0).

Network !Text !Interface

See: Interface

AvailabilityZone

The Availability Zone in which the instance launched.

ProductCodes

Product codes associated with the instance, if any.

PublicHostname

The instance's public DNS. If the instance is in a VPC, this category is only returned if the enableDnsHostnames attribute is set to true. For more information, see Using DNS with Your VPC.

PublicIPV4

The public IP address. If an Elastic IP address is associated with the instance, the value returned is the Elastic IP address.

OpenSSHKey

Public key. Only available if supplied at instance launch time.

RAMDiskId

The ID of the RAM disk specified at launch time, if applicable.

ReservationId

ID of the reservation.

SecurityGroups

The names of the security groups applied to the instance.

Instances

Instances details
Eq Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Ord Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Show Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Generic Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Associated Types

type Rep Metadata :: Type -> Type #

Methods

from :: Metadata -> Rep Metadata x #

to :: Rep Metadata x -> Metadata #

ToText Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

toText :: Metadata -> Text #

type Rep Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

type Rep Metadata = D1 ('MetaData "Metadata" "Amazonka.EC2.Metadata" "libZSamazonkaZSamazonka" 'False) ((((C1 ('MetaCons "AMIId" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AMILaunchIndex" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "AMIManifestPath" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "AncestorAMIIds" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BlockDevice" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Mapping))))) :+: ((C1 ('MetaCons "Hostname" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "IAM" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Info)) :+: C1 ('MetaCons "InstanceAction" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "InstanceId" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InstanceType" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KernelId" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "LocalHostname" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LocalIPV4" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MAC" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Network" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Interface)) :+: (C1 ('MetaCons "AvailabilityZone" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ProductCodes" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "PublicHostname" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PublicIPV4" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OpenSSHKey" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "RAMDiskId" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ReservationId" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SecurityGroups" 'PrefixI 'False) (U1 :: Type -> Type))))))

metadata :: MonadIO m => Env -> Metadata -> m ByteString Source #

Retrieve the specified Metadata.

userdata :: MonadIO m => Env -> m (Maybe ByteString) Source #

Retrieve the user data. Returns Nothing if no user data is assigned to the instance.

Running Asynchronous Actions

Requests can be sent asynchronously, but due to guarantees about resource closure require the use of UnliftIO.Async.

The following example demonstrates retrieving two objects from S3 concurrently:

{-# LANGUAGE OverloadedStrings #-}
import qualified Amazonka as AWS
import qualified Amazonka.S3 as S3
import qualified UnliftIO.Async as Async

let requestA = S3.newGetObject "bucket" "prefix/object-a"
let requestB = S3.newGetObject "bucket" "prefix/object-b"

runResourceT $
  Async.withAsync (send env requestA) $ \asyncA ->
    Async.withAsync (send env requestB) $ \asyncB -> do
      Async.waitBoth asyncA asyncB

If you are running many async requests in parallel, using ContT can hide the giant callback pyramid:

runResourceT . evalContT $ do
  asyncA <- ContT $ Async.withAsync (send env requestA)
  asyncB <- ContT $ Async.withAsync (send env requestB)
  Async.waitBoth asyncA asyncB

Handling Errors

Errors are either returned or thrown by the library using IO. Sub-errors of the canonical Error type can be caught using trying or catching and the appropriate AsError Prism when using the non-Either send variants:

trying _Error          (send $ newListObjects "bucket-name") :: Either Error          ListObjectsResponse
trying _TransportError (send $ newListObjects "bucket-name") :: Either HttpException  ListObjectsResponse
trying _SerializeError (send $ newListObjects "bucket-name") :: Either SerializeError ListObjectsResponse
trying _ServiceError   (send $ newListObjects "bucket-name") :: Either ServiceError   ListObjectsResponse

Many of the individual amazonka-* libraries export compatible Getters for matching service specific error codes and messages in the style above. See the Error Matchers heading in each respective library for details.

class AsError a where #

Minimal complete definition

_Error

Methods

_Error :: Prism' a Error #

A general Amazonka error.

_TransportError :: Prism' a HttpException #

An error occured while communicating over HTTP with a remote service.

_SerializeError :: Prism' a SerializeError #

A serialisation error occured when attempting to deserialise a response.

_ServiceError :: Prism' a ServiceError #

A service specific error returned by the remote service.

class AsAuthError a where Source #

Minimal complete definition

_AuthError

Methods

_AuthError :: Prism' a AuthError Source #

A general authentication error.

_RetrievalError :: Prism' a HttpException Source #

An error occured while communicating over HTTP with the local metadata endpoint.

_MissingEnvError :: Prism' a Text Source #

The named environment variable was not found.

_InvalidEnvError :: Prism' a Text Source #

An error occured parsing named environment variable's value.

_MissingFileError :: Prism' a FilePath Source #

The specified credentials file could not be found.

_InvalidFileError :: Prism' a Text Source #

An error occured parsing the credentials file.

_InvalidIAMError :: Prism' a Text Source #

The specified IAM profile could not be found or deserialised.

trying :: MonadCatch m => Getting (First a) SomeException a -> m r -> m (Either a r) #

A variant of try that takes a Prism (or any Fold) to select which exceptions are caught (c.f. tryJust, catchJust). If the Exception does not match the predicate, it is re-thrown.

trying :: MonadCatch m => Prism'     SomeException a -> m r -> m (Either a r)
trying :: MonadCatch m => Lens'      SomeException a -> m r -> m (Either a r)
trying :: MonadCatch m => Traversal' SomeException a -> m r -> m (Either a r)
trying :: MonadCatch m => Iso'       SomeException a -> m r -> m (Either a r)
trying :: MonadCatch m => Getter     SomeException a -> m r -> m (Either a r)
trying :: MonadCatch m => Fold       SomeException a -> m r -> m (Either a r)

catching :: MonadCatch m => Getting (First a) SomeException a -> m r -> (a -> m r) -> m r #

Catch exceptions that match a given Prism (or any Fold, really).

>>> catching _AssertionFailed (assert False (return "uncaught")) $ \ _ -> return "caught"
"caught"
catching :: MonadCatch m => Prism' SomeException a     -> m r -> (a -> m r) -> m r
catching :: MonadCatch m => Lens' SomeException a      -> m r -> (a -> m r) -> m r
catching :: MonadCatch m => Traversal' SomeException a -> m r -> (a -> m r) -> m r
catching :: MonadCatch m => Iso' SomeException a       -> m r -> (a -> m r) -> m r
catching :: MonadCatch m => Getter SomeException a     -> m r -> (a -> m r) -> m r
catching :: MonadCatch m => Fold SomeException a       -> m r -> (a -> m r) -> m r

Building Error Prisms

_MatchServiceError :: AsError a => Service -> ErrorCode -> Getting (First ServiceError) a ServiceError #

Provides a generalised prism for catching a specific service error identified by the opaque service abbreviation and error code.

This can be used if the generated error prisms provided by Amazonka.ServiceName.Types do not cover all the thrown error codes. For example to define a new error prism:

{-# LANGUAGE OverloadedStrings #-}

import Amazonka.S3 (ServiceError, s3)

_NoSuchBucketPolicy :: AsError a => Getting (First ServiceError) a ServiceError
_NoSuchBucketPolicy = _MatchServiceError s3 "NoSuchBucketPolicy"

With example usage being:

>>> import Control.Exception.Lens (trying)
>>> :t trying _NoSuchBucketPolicy
MonadCatch m => m a -> m (Either ServiceError a)

Logging

The exposed logging interface is a primitive Logger function which gets threaded through service calls and serialisation routines. This allows the library to output useful information and diagnostics.

The newLogger function can be used to construct a simple logger which writes output to a Handle, but in most production code you should probably consider using a more robust logging library such as tinylog or fast-logger.

data LogLevel #

Constructors

Info

Info messages supplied by the user - this level is not emitted by the library.

Error

Error messages only.

Debug

Useful debug information + info + error levels.

Trace

Includes potentially sensitive signing metadata, and non-streaming response bodies.

Instances

Instances details
Enum LogLevel 
Instance details

Defined in Amazonka.Types

Eq LogLevel 
Instance details

Defined in Amazonka.Types

Ord LogLevel 
Instance details

Defined in Amazonka.Types

Show LogLevel 
Instance details

Defined in Amazonka.Types

Generic LogLevel 
Instance details

Defined in Amazonka.Types

Associated Types

type Rep LogLevel :: Type -> Type #

Methods

from :: LogLevel -> Rep LogLevel x #

to :: Rep LogLevel x -> LogLevel #

ToByteString LogLevel 
Instance details

Defined in Amazonka.Types

Methods

toBS :: LogLevel -> ByteString #

FromText LogLevel 
Instance details

Defined in Amazonka.Types

ToText LogLevel 
Instance details

Defined in Amazonka.Types

Methods

toText :: LogLevel -> Text #

type Rep LogLevel 
Instance details

Defined in Amazonka.Types

type Rep LogLevel = D1 ('MetaData "LogLevel" "Amazonka.Types" "libZSamazonka-coreZSamazonka-core" 'False) ((C1 ('MetaCons "Info" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Error" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Debug" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Trace" 'PrefixI 'False) (U1 :: Type -> Type)))

type Logger = LogLevel -> ByteStringBuilder -> IO () #

A function threaded through various request and serialisation routines to log informational and debug messages.

Constructing a Logger

newLogger :: MonadIO m => LogLevel -> Handle -> m Logger Source #

This is a primitive logger which can be used to log builds to a Handle.

Note: A more sophisticated logging library such as tinylog or fast-logger should be used in production code.

Re-exported Types