Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions packages/proxy/schema/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ const BedrockMetadataSchemaBase = BaseMetadataSchema.merge(
z.object({
region: z.string().min(1, "Region cannot be empty"),
auth_type: z
.enum(["iam_credentials", "api_key"])
.enum(["iam_credentials", "api_key", "assume_role"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle assume_role auth type in Bedrock client setup

Adding "assume_role" to the Bedrock metadata enum makes configuration validation accept a mode that is not implemented by the runtime: all Bedrock client constructors in packages/proxy/src/providers/bedrock.ts only special-case auth_type === "api_key" and otherwise send static IAM credentials (accessKeyId/secretAccessKey/sessionToken), and the newly added external_id is never used. In practice, a secret configured with auth_type: "assume_role" will still go through the IAM-credentials branch and fail at request time instead of assuming a role.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine, we are only adding gateway support and assume_role exchanges for iam_credentials internally.

.default("iam_credentials"),
access_key: z.string().nullish(),
session_token: z.string().nullish(),
external_id: z.string().nullish(),
role_arn: z.string().nullish(),
api_base: z.union([z.string().url(), z.string().length(0)]).nullish(),
}),
).strict();
export const BedrockMetadataSchema = BedrockMetadataSchemaBase;
export const BedrockMetadataSchemaWithAuth =
BedrockMetadataSchemaBase.superRefine((data, ctx) => {
if ((data.auth_type ?? "iam_credentials") === "iam_credentials") {
const authType = data.auth_type ?? "iam_credentials";
if (authType === "iam_credentials") {
if (!data.access_key) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
Expand All @@ -59,6 +62,22 @@ export const BedrockMetadataSchemaWithAuth =
});
}
}
if (authType === "assume_role") {
if (!data.external_id?.trim()) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "External ID is required for assume role",
path: ["external_id"],
});
}
if (!data.role_arn?.trim()) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "Role ARN is required for assume role",
path: ["role_arn"],
});
}
}
});
export type BedrockMetadata = z.infer<typeof BedrockMetadataSchema>;

Expand Down