feat: add bedrock credential type for AWS Bedrock authentication#784
Open
knechtionscoding wants to merge 1 commit intokelos-dev:mainfrom
Open
feat: add bedrock credential type for AWS Bedrock authentication#784knechtionscoding wants to merge 1 commit intokelos-dev:mainfrom
knechtionscoding wants to merge 1 commit intokelos-dev:mainfrom
Conversation
Add a new `bedrock` credential type that injects AWS environment variables (CLAUDE_CODE_USE_BEDROCK, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION) from a referenced Secret, with optional support for AWS_SESSION_TOKEN and ANTHROPIC_BEDROCK_BASE_URL. Refactor credential injection into a centralized credentialEnvVars() function so that adding future providers (e.g. Vertex) requires only a new case block. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="examples/09-bedrock-credentials/README.md">
<violation number="1" location="examples/09-bedrock-credentials/README.md:61">
P2: IRSA example uses `type: api-key` with a dummy secret, but api-key credentials always inject a non-optional SecretKeyRef (ANTHROPIC_API_KEY). Without creating a dummy secret containing that key, the pod will fail to start; the README doesn’t mention this requirement.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
84f94fb to
d0a18b6
Compare
There was a problem hiding this comment.
1 issue found across 26 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="api/v1alpha1/task_types.go">
<violation number="1" location="api/v1alpha1/task_types.go:103">
P2: Bedrock credentials validation allows IRSA mode without requiring `region`, so invalid specs can pass admission and fail at runtime.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
api/v1alpha1/task_types.go
Outdated
|
|
||
| // Credentials specifies how to authenticate with the agent. | ||
| // +kubebuilder:validation:Required | ||
| // +kubebuilder:validation:XValidation:rule="self.type == 'bedrock' || has(self.secretRef)",message="secretRef is required for api-key and oauth credential types" |
There was a problem hiding this comment.
P2: Bedrock credentials validation allows IRSA mode without requiring region, so invalid specs can pass admission and fail at runtime.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At api/v1alpha1/task_types.go, line 103:
<comment>Bedrock credentials validation allows IRSA mode without requiring `region`, so invalid specs can pass admission and fail at runtime.</comment>
<file context>
@@ -86,6 +100,7 @@ type TaskSpec struct {
// Credentials specifies how to authenticate with the agent.
// +kubebuilder:validation:Required
+ // +kubebuilder:validation:XValidation:rule="self.type == 'bedrock' || has(self.secretRef)",message="secretRef is required for api-key and oauth credential types"
Credentials Credentials `json:"credentials"`
</file context>
Suggested change
| // +kubebuilder:validation:XValidation:rule="self.type == 'bedrock' || has(self.secretRef)",message="secretRef is required for api-key and oauth credential types" | |
| // +kubebuilder:validation:XValidation:rule="self.type != 'bedrock' || has(self.secretRef) || self.region != ''",message="for bedrock, either secretRef or region is required" | |
| // +kubebuilder:validation:XValidation:rule="self.type == 'bedrock' || has(self.secretRef)",message="secretRef is required for api-key and oauth credential types" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind feature
What this PR does / why we need it:
Add a new
bedrockcredential type that injects AWS environment variables (CLAUDE_CODE_USE_BEDROCK,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION) from a referenced Secret, with optional support forAWS_SESSION_TOKENandANTHROPIC_BEDROCK_BASE_URL.Refactor credential injection into a centralized
credentialEnvVars()function so that adding future providers (e.g. Vertex) requires only a new case block.Changes:
CredentialTypeBedrockconstant and update CRD enum validationcredentialEnvVars()to centralize credential env var injection for all typesbedrockconfig block in CLI for auto-creating AWS credential secretsexamples/09-bedrock-credentials/Which issue(s) this PR is related to:
Fixes #780
Special notes for your reviewer:
AWS_SESSION_TOKENandANTHROPIC_BEDROCK_BASE_URLare injected withOptional: trueon theSecretKeySelector, so pods won't fail if those keys are absent from the Secret.credentialEnvVars()refactor is a no-op for existingapi-keyandoauthtypes — it just moves the same logic into a single function.secretRefoptional, which is a separate API change. The IRSA workaround viapodOverrides.envis documented in the example README.Does this PR introduce a user-facing change?
Summary by cubic
Add a new
bedrockcredential type to run Claude Code via AWS Bedrock. Injects AWS env vars from a Secret, adds CLI/config to create/update it, and centralizes credential env var injection.New Features
bedrock; injectsCLAUDE_CODE_USE_BEDROCK=1,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION, plus optionalAWS_SESSION_TOKENandANTHROPIC_BEDROCK_BASE_URL.bedrockblock;kelos runcan create/updatekelos-credentials; completion includesbedrock; examples inexamples/09-bedrock-credentials/.secretRefremains required (workaround documented in the example).Refactors
credentialEnvVars()and use it forapi-key,oauth, andbedrock; add unit test for Bedrock injection.Written for commit d0a18b6. Summary will update on new commits.