Skip to content

Commit

Permalink
fix: provide region to AWS SDK SecretClient from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
fossamagna committed Oct 22, 2024
1 parent 56fa6ae commit aaf05ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/mean-dodos-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"amplify-backend-vscode": patch
---

fix: provide region to AWS SDK SecretClient from config file
12 changes: 11 additions & 1 deletion src/secrets/amplify-secrets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type { BackendIdentifier } from "@aws-amplify/plugin-types";
import Auth from "../auth/credentials";
import { fromIni } from "@aws-sdk/credential-providers";

export interface AmplifySecrets {
getSecret(secretName: string): Promise<SecretItem>;
Expand All @@ -25,8 +27,16 @@ export class AmplifyBackendSecret implements AmplifySecrets {
}

private async getBackendSecretClient() {
const profile = Auth.instance.getProfile();
const credentials = fromIni({
profile,
});
const region = await Auth.instance.getRegion(profile);
const backendSecret = import("@aws-amplify/backend-secret");
const secretClient = (await backendSecret).getSecretClient();
const secretClient = (await backendSecret).getSecretClient({
credentials,
region,
});
return secretClient;
}

Expand Down

0 comments on commit aaf05ea

Please sign in to comment.