|
4 | 4 | # This source code is licensed under the terms described in the LICENSE file in |
5 | 5 | # the root directory of this source tree. |
6 | 6 |
|
| 7 | +import os |
| 8 | + |
7 | 9 | from pydantic import BaseModel, Field |
8 | 10 |
|
9 | 11 |
|
10 | 12 | class BedrockBaseConfig(BaseModel): |
11 | 13 | aws_access_key_id: str | None = Field( |
12 | | - default=None, |
| 14 | + default_factory=lambda: os.getenv("AWS_ACCESS_KEY_ID"), |
13 | 15 | description="The AWS access key to use. Default use environment variable: AWS_ACCESS_KEY_ID", |
14 | 16 | ) |
15 | 17 | aws_secret_access_key: str | None = Field( |
16 | | - default=None, |
| 18 | + default_factory=lambda: os.getenv("AWS_SECRET_ACCESS_KEY"), |
17 | 19 | description="The AWS secret access key to use. Default use environment variable: AWS_SECRET_ACCESS_KEY", |
18 | 20 | ) |
19 | 21 | aws_session_token: str | None = Field( |
20 | | - default=None, |
| 22 | + default_factory=lambda: os.getenv("AWS_SESSION_TOKEN"), |
21 | 23 | description="The AWS session token to use. Default use environment variable: AWS_SESSION_TOKEN", |
22 | 24 | ) |
23 | 25 | region_name: str | None = Field( |
24 | | - default=None, |
| 26 | + default_factory=lambda: os.getenv("AWS_DEFAULT_REGION"), |
25 | 27 | description="The default AWS Region to use, for example, us-west-1 or us-west-2." |
26 | 28 | "Default use environment variable: AWS_DEFAULT_REGION", |
27 | 29 | ) |
28 | 30 | profile_name: str | None = Field( |
29 | | - default=None, |
| 31 | + default_factory=lambda: os.getenv("AWS_PROFILE"), |
30 | 32 | description="The profile name that contains credentials to use.Default use environment variable: AWS_PROFILE", |
31 | 33 | ) |
32 | 34 | total_max_attempts: int | None = Field( |
33 | | - default=None, |
| 35 | + default_factory=lambda: int(val) if (val := os.getenv("AWS_MAX_ATTEMPTS")) else None, |
34 | 36 | description="An integer representing the maximum number of attempts that will be made for a single request, " |
35 | 37 | "including the initial attempt. Default use environment variable: AWS_MAX_ATTEMPTS", |
36 | 38 | ) |
37 | 39 | retry_mode: str | None = Field( |
38 | | - default=None, |
| 40 | + default_factory=lambda: os.getenv("AWS_RETRY_MODE"), |
39 | 41 | description="A string representing the type of retries Boto3 will perform." |
40 | 42 | "Default use environment variable: AWS_RETRY_MODE", |
41 | 43 | ) |
42 | 44 | connect_timeout: float | None = Field( |
43 | | - default=60, |
| 45 | + default_factory=lambda: float(os.getenv("AWS_CONNECT_TIMEOUT", "60")), |
44 | 46 | description="The time in seconds till a timeout exception is thrown when attempting to make a connection. " |
45 | 47 | "The default is 60 seconds.", |
46 | 48 | ) |
47 | 49 | read_timeout: float | None = Field( |
48 | | - default=60, |
| 50 | + default_factory=lambda: float(os.getenv("AWS_READ_TIMEOUT", "60")), |
49 | 51 | description="The time in seconds till a timeout exception is thrown when attempting to read from a connection." |
50 | 52 | "The default is 60 seconds.", |
51 | 53 | ) |
52 | 54 | session_ttl: int | None = Field( |
53 | | - default=3600, |
| 55 | + default_factory=lambda: int(os.getenv("AWS_SESSION_TTL", "3600")), |
54 | 56 | description="The time in seconds till a session expires. The default is 3600 seconds (1 hour).", |
55 | 57 | ) |
56 | 58 |
|
|
0 commit comments