Skip to content

Commit ea0ddd1

Browse files
authored
docs: document aws sso login support (#1753)
Fixes #1488
1 parent fb3b1e5 commit ea0ddd1

2 files changed

Lines changed: 45 additions & 40 deletions

File tree

engine/baml-lib/llm-client/src/clients/aws_bedrock.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ impl UnresolvedAwsBedrock {
282282
}
283283
};
284284

285-
// #[cfg(not(target_arch = "wasm32"))]
286285
let profile = match self.profile.as_ref() {
287286
Some(profile) => Some(profile.resolve(ctx)?),
288287
None => match ctx.get_env_var("AWS_PROFILE") {
@@ -302,8 +301,6 @@ impl UnresolvedAwsBedrock {
302301
_ => None,
303302
},
304303
};
305-
// #[cfg(target_arch = "wasm32")]
306-
// let profile = None;
307304

308305
#[cfg(target_arch = "wasm32")]
309306
{

fern/03-reference/baml/clients/providers/aws-bedrock.mdx

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,63 +22,49 @@ client<llm> MyClient {
2222

2323
## Authentication
2424

25-
AWS Bedrock uses standard AWS authentication methods. Choose the one that best fits your environment:
25+
AWS Bedrock uses standard AWS authentication methods. We recommend using AWS profiles in development and AWS services' IAM roles in production, but all of the following are supported:
2626

2727
<Tabs>
28-
<Tab title="Environment Variables">
28+
<Tab title="AWS Profile">
2929

30-
The simplest way to authenticate. Set these environment variables:
30+
When developing locally, you can use the AWS CLI in combination with profiles to manage your credentials.
3131

32-
```bash
33-
export AWS_ACCESS_KEY_ID="your_key"
34-
export AWS_SECRET_ACCESS_KEY="your_secret"
35-
export AWS_REGION="us-east-1"
36-
```
32+
For example, if you run `aws sso login` with a default profile, BAML will automatically pick up those credentials:
3733

38-
```baml BAML
39-
client<llm> MyClient {
40-
provider aws-bedrock
41-
options {
42-
// No need to specify credentials - they'll be picked up from environment
43-
model "anthropic.claude-3-sonnet-20240229-v1:0"
44-
}
45-
}
34+
```ini ~/.aws/config
35+
[default]
36+
sso_start_url = https://your-sso-start-url.awsapps.com/start
37+
sso_region = us-west-2
38+
sso_account_id = 123456789012
39+
sso_role_name = YourSSORole
40+
region = us-west-2
41+
output = json
4642
```
4743

48-
</Tab>
44+
You can also choose a specific profile by setting the `AWS_PROFILE` environment variable.
4945

50-
<Tab title="AWS Profile">
46+
In the BAML playground, you can set this by clicking the "API Keys" button in
47+
the top right (you'll also need to set `AWS_REGION` to the same region as your
48+
profile).
5149

52-
Use AWS profiles to manage multiple sets of credentials:
50+
The BAML-generated clients will also respect `AWS_PROFILE` if it is set:
5351

54-
```ini
55-
# ~/.aws/config
56-
[profile my-profile]
57-
region = us-east-1
58-
aws_access_key_id = your_key
59-
aws_secret_access_key = your_secret
52+
```bash
53+
export AWS_PROFILE=staging-profile
6054
```
6155

62-
```baml BAML
63-
client<llm> MyClient {
64-
provider aws-bedrock
65-
options {
66-
profile "my-profile"
67-
model "anthropic.claude-3-sonnet-20240229-v1:0"
68-
}
69-
}
70-
```
56+
Alternatively, you can also explicitly specify the profile directly in the BAML config itself
57+
(this will take precedence over the environment variable):
7158

72-
You can also use AWS SSO profiles:
7359
```bash
7460
# First, login with SSO
75-
aws sso login --profile my-sso-profile
61+
aws sso login --profile staging-profile
7662

7763
# Then use the profile in your BAML config
7864
client<llm> MyClient {
7965
provider aws-bedrock
8066
options {
81-
profile "my-sso-profile"
67+
profile "staging-profile"
8268
model "anthropic.claude-3-sonnet-20240229-v1:0"
8369
}
8470
}
@@ -109,6 +95,28 @@ client<llm> MyClient {
10995

11096
</Tab>
11197

98+
<Tab title="Environment Variables">
99+
100+
The simplest way to authenticate. Set these environment variables:
101+
102+
```bash
103+
export AWS_ACCESS_KEY_ID="your_key"
104+
export AWS_SECRET_ACCESS_KEY="your_secret"
105+
export AWS_REGION="us-east-1"
106+
```
107+
108+
```baml BAML
109+
client<llm> MyClient {
110+
provider aws-bedrock
111+
options {
112+
// No need to specify credentials - they'll be picked up from environment
113+
model "anthropic.claude-3-sonnet-20240229-v1:0"
114+
}
115+
}
116+
```
117+
118+
</Tab>
119+
112120
<Tab title="Explicit Credentials">
113121

114122
You can specify credentials directly in your BAML configuration:

0 commit comments

Comments
 (0)