Skip to content

Commit fd060c1

Browse files
committed
Autofill role arn field
1 parent 38d1389 commit fd060c1

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

packages/core/src/login/webview/vue/amazonq/backend_amazonq.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,8 @@ export class AmazonQLoginWebview extends CommonAuthWebview {
202202
): Promise<AuthError | undefined> {
203203
getLogger().debug(`called startIamCredentialSetup()`)
204204
// Defining separate auth function to emit telemetry before returning from this method
205-
await globals.globalState.update('recentIamKeys', {
206-
accessKey: accessKey,
207-
})
205+
await globals.globalState.update('recentIamKeys', { accessKey: accessKey })
206+
await globals.globalState.update('recentRoleArn', { roleArn: roleArn })
208207
const runAuth = async (): Promise<AuthError | undefined> => {
209208
try {
210209
await AuthUtil.instance.login_iam(accessKey, secretKey, sessionToken, roleArn)

packages/core/src/login/webview/vue/backend.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ export abstract class CommonAuthWebview extends VueWebview {
310310
return globals.globalState.tryGet('recentIamKeys', Object, { accessKey: '' })
311311
}
312312

313+
getDefaultRoleArn(): { roleArn: string } {
314+
return globals.globalState.tryGet('recentRoleArn', Object, { roleArn: '' })
315+
}
316+
313317
cancelAuthFlow() {
314318
AuthSSOServer.lastInstance?.cancelCurrentFlow()
315319
}

packages/core/src/login/webview/vue/login.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ export default defineComponent({
396396
this.startUrl = defaultSso.startUrl
397397
this.selectedRegion = defaultSso.region
398398
const defaultIamAccessKey = await this.getDefaultIamAccessKey()
399+
const defaultRoleArn = await this.getDefaultRoleArn()
399400
this.accessKey = defaultIamAccessKey.accessKey
401+
this.roleArn = defaultRoleArn.roleArn
400402
await this.emitUpdate('created')
401403
},
402404
@@ -640,6 +642,9 @@ export default defineComponent({
640642
async getDefaultIamAccessKey() {
641643
return await client.getDefaultIamKeys()
642644
},
645+
async getDefaultRoleArn() {
646+
return await client.getDefaultRoleArn()
647+
},
643648
handleHelpLinkClick() {
644649
void client.emitUiClick('auth_helpLink')
645650
},

packages/core/src/shared/globalState.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export type globalKey =
7272
| 'recentCredentials'
7373
| 'recentSso'
7474
| 'recentIamKeys'
75+
| 'recentRoleArn'
7576
// List of regions enabled in AWS Explorer.
7677
| 'region'
7778
// TODO: implement this via `PromptSettings` instead of globalState.

0 commit comments

Comments
 (0)