@@ -35,6 +35,8 @@ const minimumSsmActions = [
35
35
'ssmmessages:OpenDataChannel' ,
36
36
]
37
37
38
+ const policyAttachDelay = 5000
39
+
38
40
export async function openRemoteTerminal ( options : vscode . TerminalOptions , onClose : ( ) => void ) {
39
41
const timeout = new Timeout ( 60000 )
40
42
@@ -187,19 +189,31 @@ export async function getDeniedSsmActions(client: IamClient, roleArn: string): P
187
189
return deniedActions
188
190
}
189
191
190
- export async function promptToAddPolicies ( client : IamClient , roleArn : string ) : Promise < boolean > {
192
+ export async function promptToAddInlinePolicy ( client : IamClient , roleArn : string ) : Promise < boolean > {
191
193
const promptText = `${
192
194
getIdeProperties ( ) . company
193
195
} Toolkit will add required actions to role ${ roleArn } :\n${ getFormattedSsmActions ( ) } `
194
196
const confirmation = await showConfirmationMessage ( { prompt : promptText , confirm : 'Approve' } )
195
197
196
198
if ( confirmation ) {
197
- addSsmActionsToInlinePolicy ( client , roleArn )
199
+ await addInlinePolicyWithDelay ( client , roleArn )
198
200
}
199
201
200
202
return confirmation
201
203
}
202
204
205
+ async function addInlinePolicyWithDelay ( client : IamClient , roleArn : string ) {
206
+ const timeout = new Timeout ( policyAttachDelay )
207
+ await showMessageWithCancel ( `Adding Inline Policy to ${ roleArn } ` , timeout )
208
+ await addSsmActionsToInlinePolicy ( client , roleArn )
209
+
210
+ function delay ( ms : number ) {
211
+ return new Promise ( resolve => setTimeout ( resolve , ms ) )
212
+ }
213
+
214
+ await delay ( policyAttachDelay ) . finally ( ( ) => timeout . cancel ( ) )
215
+ }
216
+
203
217
function getFormattedSsmActions ( ) {
204
218
const formattedActions = minimumSsmActions . map ( action => `"${ action } ",\n` ) . reduce ( ( l , r ) => l + r )
205
219
0 commit comments