mirror of
https://github.com/coder/coder.git
synced 2026-10-16 14:48:56 +08:00
This PR adds configuration plumbing for Claude Platform on AWS ## Summary Makes Claude Platform for AWS configurable as a settings variant of `type=anthropic`, discriminated by `_type: "claude_platform_aws"`. Settings contain only `region` and `workspace_id`, plus the schema version. No new provider type or database enum is introduced. The API persists and projects those settings to the gateway. Provider keys can be added or removed independently: allowed BYOK takes precedence, followed by stored keys, then ambient SigV4 when neither key source applies. Model-availability hints and keyless provider construction reflect that ambient capability. Rejected or exhausted keys do not fall back to IAM. Removes Claude Platform-specific AWS identity fields, secret redaction/merge behavior, external-ID handling, and mode/key consistency checks. Bedrock configuration remains intact. Environment-based provider seeding was removed upstream and is not restored. The Claude Platform form and Experimental label remain follow-up work in #29050. ## Authentication limitation Each Claude Platform provider uses either the gateway's ambient AWS credentials when no provider keys are stored, or its stored API-key pool. In either case, a client credential takes precedence when BYOK is enabled. Rejected BYOK or an exhausted provider key pool does not fall back to ambient IAM. There is no per-provider AWS identity selection: keyless providers on the same gateway share its ambient AWS credential chain and cannot configure separate AWS access keys or assumed roles. Each provider still has its own Claude Platform workspace ID and separate provider attribution in Coder's usage/cost records; this does not imply separate AWS billing accounts. ## Validation - Race tests passed for SDK, daemon projection, db2sdk, chatprovider, and targeted CLI/API configuration tests. - Installed pre-commit hook passed, including generation, frontend/Go lint, and build. - Tests cover settings round trips, validation, adding/removing the last key without settings changes, keyless construction, model availability, and Bedrock regressions. Generated by Coder Agents on behalf of @johnstcn and @Shelnutt2 Co-authored-by: Cian Johnston <cian@coder.com>
40 lines
1.7 KiB
Go
40 lines
1.7 KiB
Go
package codersdk
|
|
|
|
// AIProviderSettingsTypeClaudePlatformAWS is the _type discriminator value for
|
|
// AIProviderClaudePlatformAWSSettings.
|
|
const AIProviderSettingsTypeClaudePlatformAWS = "claude_platform_aws"
|
|
|
|
// AIProviderClaudePlatformAWSSettingsVersion is the current schema version of
|
|
// AIProviderClaudePlatformAWSSettings.
|
|
const AIProviderClaudePlatformAWSSettingsVersion = 1
|
|
|
|
// AIProviderClaudePlatformAWSSettings configures providers that authenticate
|
|
// against Claude Platform for AWS: Anthropic's native Messages API hosted on
|
|
// AWS. It speaks the standard Messages wire format with standard Anthropic
|
|
// model IDs, so it is an authentication and routing variant of
|
|
// AIProviderTypeAnthropic rather than a provider type of its own.
|
|
// Requests use a client or provider API key when available, otherwise the
|
|
// gateway signs with its ambient AWS credentials.
|
|
type AIProviderClaudePlatformAWSSettings struct {
|
|
// Region selects the default regional endpoint and SigV4 signing scope.
|
|
// Required even when BaseURL points at a proxy.
|
|
Region string `json:"region"`
|
|
// WorkspaceID is sent as the anthropic-workspace-id header on every
|
|
// request. Required regardless of the credential used.
|
|
WorkspaceID string `json:"workspace_id"`
|
|
}
|
|
|
|
// IsConfigured reports whether the settings carry the fields required to route
|
|
// a provider at Claude Platform for AWS.
|
|
func (c AIProviderClaudePlatformAWSSettings) IsConfigured() bool {
|
|
return c.Region != "" && c.WorkspaceID != ""
|
|
}
|
|
|
|
func (AIProviderClaudePlatformAWSSettings) settingsType() string {
|
|
return AIProviderSettingsTypeClaudePlatformAWS
|
|
}
|
|
|
|
func (AIProviderClaudePlatformAWSSettings) settingsVersion() int {
|
|
return AIProviderClaudePlatformAWSSettingsVersion
|
|
}
|