Add support for aws credentials file or environment variables, and session token

This commit is contained in:
Saoud Rizwan
2024-09-03 13:58:21 -04:00
parent f1713e4b99
commit 0badfa2706
6 changed files with 32 additions and 16 deletions

View File

@@ -153,6 +153,14 @@ const ApiOptions: React.FC<ApiOptionsProps> = ({ showModelOptions, apiErrorMessa
placeholder="Enter Secret Key...">
<span style={{ fontWeight: 500 }}>AWS Secret Key</span>
</VSCodeTextField>
<VSCodeTextField
value={apiConfiguration?.awsSessionToken || ""}
style={{ width: "100%" }}
type="password"
onInput={handleInputChange("awsSessionToken")}
placeholder="Enter Session Token...">
<span style={{ fontWeight: 500 }}>AWS Session Token</span>
</VSCodeTextField>
<div className="dropdown-container">
<label htmlFor="aws-region-dropdown">
<span style={{ fontWeight: 500 }}>AWS Region</span>
@@ -192,14 +200,9 @@ const ApiOptions: React.FC<ApiOptionsProps> = ({ showModelOptions, apiErrorMessa
marginTop: "5px",
color: "var(--vscode-descriptionForeground)",
}}>
These credentials are stored locally and only used to make API requests from this extension.
{!(apiConfiguration?.awsAccessKey && apiConfiguration?.awsSecretKey) && (
<VSCodeLink
href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html"
style={{ display: "inline" }}>
You can find your AWS access key and secret key here.
</VSCodeLink>
)}
Authenticate by either providing the keys above or use the default AWS credential providers,
i.e. ~/.aws/credentials or environment variables. These credentials are only used locally to
make API requests from this extension.
</p>
</div>
)}

View File

@@ -31,7 +31,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
setState(message.state)
const config = message.state?.apiConfiguration
const hasKey = config
? [config.apiKey, config.openRouterApiKey, config.awsAccessKey, config.vertexProjectId].some(
? [config.apiKey, config.openRouterApiKey, config.awsRegion, config.vertexProjectId].some(
(key) => key !== undefined
)
: false

View File

@@ -9,8 +9,8 @@ export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): s
}
break
case "bedrock":
if (!apiConfiguration.awsAccessKey || !apiConfiguration.awsSecretKey || !apiConfiguration.awsRegion) {
return "You must provide a valid AWS access key, secret key, and region."
if (!apiConfiguration.awsRegion) {
return "You must choose a region to use with AWS Bedrock."
}
break
case "openrouter":
@@ -26,4 +26,4 @@ export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): s
}
}
return undefined
}
}