org.llm4s.llmconnect.auth.aws
Members list
Type members
Classlikes
The AWS credentials AwsSecretsManagerApiKeyProvider signs its requests with (Signature Version 4): an access key id, its secret access key and, for temporary credentials from STS, a session token.
The AWS credentials AwsSecretsManagerApiKeyProvider signs its requests with (Signature Version 4): an access key id, its secret access key and, for temporary credentials from STS, a session token.
val longLived = AwsCredentials("AKIA...", Secret(secretAccessKey))
val temporary = AwsCredentials("ASIA...", Secret(secretAccessKey)).withSessionToken(Secret(sessionToken))
Value parameters
- accessKeyId
-
the access key id,
AKIA...or, for temporary credentials,ASIA...; not secret - secretAccessKey
-
the secret access key; never printed by
toStringnor put in an error - sessionToken
-
the session token of temporary credentials, sent as
X-Amz-Security-Token
Attributes
- Companion
- object
- Source
- AwsCredentials.scala
- Supertypes
Attributes
- Companion
- class
- Source
- AwsCredentials.scala
- Supertypes
- Self type
-
AwsCredentials.type
An ApiKeyProvider that reads the API key from AWS Secrets Manager (#2479) with its GetSecretValue action, for a deployment that cannot run the Secrets Store CSI driver or External Secrets Operator to write the key to a file (apiKeyFile).
An ApiKeyProvider that reads the API key from AWS Secrets Manager (#2479) with its GetSecretValue action, for a deployment that cannot run the Secrets Store CSI driver or External Secrets Operator to write the key to a file (apiKeyFile).
The key is read on the first current(), then reused for AwsSecretsManagerSettings.refreshInterval, then read again, so a key rotated in Secrets Manager is sent from the first request after the interval. Concurrent callers share one read. A read that fails is a Left and is tried again on the next call; the last key is not served after its interval, since a rotated-out key may already be revoked.
for
keys <- AwsSecretsManagerApiKeyProvider(
AwsSecretsManagerSettings("eu-west-1", AwsCredentials(accessKeyId, Secret(secretAccessKey)), "llm4s/openai")
.withField("apiKey")
)
config <- Llm4sConfig.provider("openai-main").map(_.withApiKeyProvider(keys))
client <- LLMConnect.getClient(config)
yield client
Errors never hold the key or a credential: an AuthenticationError when AWS refuses the credentials or denies access, a NotFoundError when there is no such secret or version stage, a ConfigurationError when the secret has no usable string (binary only, a missing or blank field, more than one line), a ServiceError for any other answer, and the HTTP client's own error when Secrets Manager cannot be reached.
It depends on no AWS SDK: one POST with llm4s's own HTTP client, signed with Signature Version 4. Getting the credentials - from an instance profile, IRSA or an assumed role - stays the caller's job. Close the provider to close the HTTP client it created; one passed to AwsSecretsManagerApiKeyProvider(settings, httpClient) stays the caller's to close.
Attributes
- Companion
- object
- Source
- AwsSecretsManagerApiKeyProvider.scala
- Supertypes
Attributes
- Companion
- class
- Source
- AwsSecretsManagerApiKeyProvider.scala
- Supertypes
- Self type
Where AwsSecretsManagerApiKeyProvider reads an API key in AWS Secrets Manager (#2479): the secret secretId (its name or ARN) in region, either its whole SecretString or, with withField, one field of a SecretString that is a JSON object, as the console's key/value secrets are.
Where AwsSecretsManagerApiKeyProvider reads an API key in AWS Secrets Manager (#2479): the secret secretId (its name or ARN) in region, either its whole SecretString or, with withField, one field of a SecretString that is a JSON object, as the console's key/value secrets are.
// the field apiKey of the key/value secret llm4s/openai, in eu-west-1
val settings = AwsSecretsManagerSettings("eu-west-1", AwsCredentials(accessKeyId, Secret(secretAccessKey)), "llm4s/openai")
.withField("apiKey")
.withRefreshInterval(1.minute)
Credentials that expire - an assumed role's, a pod identity's - are passed as a function, which is called again for every read from Secrets Manager: withCredentials(() => myCredentials()).
Value parameters
- credentials
-
called once per read for the credentials that sign it; never printed by
toString - endpoint
-
the Secrets Manager endpoint;
https://secretsmanager.<region>.amazonaws.comby default, set for a VPC endpoint or a FIPS endpoint - field
-
the key of a JSON-object
SecretStringthat holds the API key; none for the whole string - refreshInterval
-
how long a key read from Secrets Manager is used before it is read again
- region
-
the AWS region, such as
us-east-1; picks the endpoint and is part of the signature - requestTimeout
-
how long one read from Secrets Manager may take
- secretId
-
the secret's name or ARN
- versionStage
-
the version stage read:
AWSCURRENTby default, the version rotation last promoted
Attributes
- Companion
- object
- Source
- AwsSecretsManagerSettings.scala
- Supertypes
Attributes
- Companion
- class
- Source
- AwsSecretsManagerSettings.scala
- Supertypes
- Self type
