Copyright | (c) 2013-2021 Brendan Hay |
---|---|
License | Mozilla Public License, v. 2.0. |
Maintainer | Brendan Hay <brendan.g.hay+amazonka@gmail.com> |
Stability | provisional |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Environment and AWS specific configuration needed to perform AWS requests.
Synopsis
- newEnv :: MonadIO m => Credentials -> m Env
- newEnvNoAuth :: MonadIO m => m EnvNoAuth
- newEnvWith :: Manager -> EnvNoAuth
- data Env' withAuth = Env {
- _envRegion :: Region
- _envLogger :: Logger
- _envRetryCheck :: Int -> HttpException -> Bool
- _envOverride :: Dual (Endo Service)
- _envManager :: Manager
- _envAuth :: withAuth Auth
- type Env = Env' Identity
- type EnvNoAuth = Env' Proxy
- envAuthMaybe :: Foldable withAuth => Env' withAuth -> Maybe Auth
- authenticate :: (MonadIO m, Foldable withAuth) => Credentials -> Env' withAuth -> m Env
- override :: (Service -> Service) -> Env -> Env
- configure :: Service -> Env -> Env
- within :: Region -> Env -> Env
- once :: Env -> Env
- timeout :: Seconds -> Env -> Env
- envRegion :: Lens' (Env' withAuth) Region
- envLogger :: Lens' (Env' withAuth) Logger
- envRetryCheck :: Lens' (Env' withAuth) (Int -> HttpException -> Bool)
- envOverride :: Lens' (Env' withAuth) (Dual (Endo Service))
- envManager :: Lens' (Env' withAuth) Manager
- envAuth :: Lens (Env' withAuth) (Env' withAuth') (withAuth Auth) (withAuth' Auth)
- retryConnectionFailure :: Int -> Int -> HttpException -> Bool
Creating the Environment
:: 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 HttpException
s 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.
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.
Env | |
|
Instances
Generic (Env' withAuth) Source # | |
type Rep (Env' withAuth) Source # | |
Defined in Amazonka.Auth type Rep (Env' withAuth) = D1 ('MetaData "Env'" "Amazonka.Auth" "libZSamazonkaZSamazonka" 'False) (C1 ('MetaCons "Env" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_envRegion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Region) :*: (S1 ('MetaSel ('Just "_envLogger") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Logger) :*: S1 ('MetaSel ('Just "_envRetryCheck") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Int -> HttpException -> Bool)))) :*: (S1 ('MetaSel ('Just "_envOverride") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Dual (Endo Service))) :*: (S1 ('MetaSel ('Just "_envManager") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Manager) :*: S1 ('MetaSel ('Just "_envAuth") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (withAuth Auth)))))) |
Overriding Default Configuration
:: (MonadIO m, Foldable withAuth) | |
=> Credentials | Credential discovery mechanism. |
-> Env' withAuth | Previous environment. |
-> m Env |
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
.
Scoped Actions
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:
- This
timeout
, if set. - The related
Service
timeout for the sent request if set. (Usually 70s) - The
envManager
timeout if set. - The default
ClientRequest
timeout. (Approximately 30s)
Env
Lenses
We provide lenses for Env'
, though you are of course free to use
the generic-lens
package.
envRetryCheck :: Lens' (Env' withAuth) (Int -> HttpException -> Bool) Source #
Retry HTTP Exceptions
retryConnectionFailure :: Int -> Int -> HttpException -> Bool Source #
Retry the subset of transport specific errors encompassing connection failure up to the specific number of times.