Copyright | (c) 2013-2023 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 | Safe-Inferred |
Language | Haskell2010 |
Environment and AWS specific configuration needed to perform AWS requests.
Synopsis
- newEnv :: MonadIO m => (EnvNoAuth -> m Env) -> m Env
- newEnvFromManager :: MonadIO m => Manager -> (EnvNoAuth -> m Env) -> m Env
- newEnvNoAuth :: MonadIO m => m EnvNoAuth
- newEnvNoAuthFromManager :: MonadIO m => Manager -> m EnvNoAuth
- data Env' withAuth = Env {}
- type Env = Env' Identity
- type EnvNoAuth = Env' Proxy
- authMaybe :: Foldable withAuth => Env' withAuth -> Maybe Auth
- lookupRegion :: MonadIO m => m (Maybe Region)
- env_region :: Lens' (Env' withAuth) Region
- env_logger :: Lens' (Env' withAuth) Logger
- env_hooks :: Lens' (Env' withAuth) Hooks
- env_retryCheck :: Lens' (Env' withAuth) (Int -> HttpException -> Bool)
- env_overrides :: Lens' (Env' withAuth) (Service -> Service)
- env_manager :: Lens' (Env' withAuth) Manager
- env_auth :: Lens (Env' withAuth) (Env' withAuth') (withAuth Auth) (withAuth' Auth)
- overrideService :: (Service -> Service) -> Env' withAuth -> Env' withAuth
- configureService :: Service -> Env' withAuth -> Env' withAuth
- globalTimeout :: Seconds -> Env' withAuth -> Env' withAuth
- once :: Env' withAuth -> Env' withAuth
- retryConnectionFailure :: Int -> Int -> HttpException -> Bool
Creating the Environment
Creates a new environment with a new Manager
without
debug logging and uses the provided function to expand/discover
credentials. Record updates or 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 updating its $sel:region:Env
field.
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'
s
$sel:retryCheck:Env
field to (\_ _ -> False)
.
Throws AuthError
when environment variables or IAM profiles cannot be read.
See: newEnvFromManager
.
Creates a new environment, but with an existing Manager
.
newEnvNoAuth :: MonadIO m => m EnvNoAuth Source #
Generate an environment without credentials, which may only make
unsigned requests. Sets the region based on the AWS_REGION
environment variable, or NorthVirginia
if unset.
This lets us support calls like the sts:AssumeRoleWithWebIdentity operation, which needs to make an unsigned request to pass the token from an identity provider.
newEnvNoAuthFromManager :: MonadIO m => Manager -> m EnvNoAuth Source #
Generate an environment without credentials, passing in an
explicit Manager
.
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
type Env = Env' Identity Source #
An environment with auth credentials. Most AWS requests need one
of these, and you can create one with newEnv
.
type EnvNoAuth = Env' Proxy Source #
An environment with no auth credentials. Used for certain
requests which need to be unsigned, like
sts:AssumeRoleWithWebIdentity
, and you can create one with
newEnvNoAuth
if you need it.
lookupRegion :: MonadIO m => m (Maybe Region) Source #
Look up the region in the AWS_REGION
environment variable.
Lenses
env_retryCheck :: Lens' (Env' withAuth) (Int -> HttpException -> Bool) Source #
Overriding Default Configuration
overrideService :: (Service -> Service) -> Env' withAuth -> Env' withAuth Source #
Provide a function which will be added to the existing stack of overrides applied to all service configurations.
configureService :: Service -> Env' withAuth -> Env' withAuth 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.defaultService
.
Env
override helpers
globalTimeout :: Seconds -> Env' withAuth -> Env' withAuth Source #
Override the timeout value for this Env
.
Default timeouts are chosen by considering:
- This
timeout
, if set. - The related
Service
timeout for the sent request if set. (Usually 70s) - The
$sel:manager:Env
timeout if set. - The default
ClientRequest
timeout. (Approximately 30s)
once :: Env' withAuth -> Env' withAuth Source #
Disable any retry logic for an Env
, so that any requests will
at most be sent once.
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.