amazonka-2.0: Comprehensive Amazon Web Services SDK.
Copyright(c) 2013-2023 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Amazonka.Env

Description

Environment and AWS specific configuration needed to perform AWS requests.

Synopsis

Creating the Environment

newEnv Source #

Arguments

:: MonadIO m 
=> (EnvNoAuth -> m Env)

Credential discovery mechanism, often discover.

-> m Env 

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 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's $sel:retryCheck:Env field to (\_ _ -> False).

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

See: newEnvFromManager.

newEnvFromManager Source #

Arguments

:: MonadIO m 
=> Manager 
-> (EnvNoAuth -> m Env)

Credential discovery mechanism.

-> m Env 

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.

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.

Constructors

Env 

Instances

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

Defined in Amazonka.Env

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.Env

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.

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

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

lookupRegion :: MonadIO m => m (Maybe Region) Source #

Look up the region in the AWS_REGION environment variable.

Lenses

env_auth :: Lens (Env' withAuth) (Env' withAuth') (withAuth Auth) (withAuth' Auth) 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.