File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { TaskDefinition } from 'aws-sdk/clients/ecs'
18
18
import { getLogger } from '../shared/logger'
19
19
import { SSM } from 'aws-sdk'
20
20
import { fromExtensionManifest } from '../shared/settings'
21
+ import { getDeniedSsmActions } from '../shared/remoteSession'
21
22
22
23
interface EcsTaskIdentifer {
23
24
readonly task : string
@@ -41,15 +42,7 @@ export async function checkPermissionsForSsm(
41
42
} )
42
43
}
43
44
44
- const deniedActions = await client . getDeniedActions ( {
45
- PolicySourceArn : task . taskRoleArn ,
46
- ActionNames : [
47
- 'ssmmessages:CreateControlChannel' ,
48
- 'ssmmessages:CreateDataChannel' ,
49
- 'ssmmessages:OpenControlChannel' ,
50
- 'ssmmessages:OpenDataChannel' ,
51
- ] ,
52
- } )
45
+ const deniedActions = await getDeniedSsmActions ( client , task . taskRoleArn )
53
46
54
47
if ( deniedActions . length !== 0 ) {
55
48
const message = localize (
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ import { SystemUtilities } from './systemUtilities'
19
19
import { getOrInstallCli } from './utilities/cliUtils'
20
20
import { pushIf } from './utilities/collectionUtils'
21
21
import { ChildProcess } from './utilities/childProcess'
22
+ import { IamClient } from './clients/iamClient'
23
+ import { IAM } from 'aws-sdk'
22
24
23
25
export interface MissingTool {
24
26
readonly name : 'code' | 'ssm' | 'ssh'
@@ -167,3 +169,17 @@ export async function handleMissingTool(tools: Err<MissingTool[]>) {
167
169
} )
168
170
)
169
171
}
172
+
173
+ export async function getDeniedSsmActions ( client : IamClient , roleArn : string ) : Promise < IAM . EvaluationResult [ ] > {
174
+ const deniedActions = await client . getDeniedActions ( {
175
+ PolicySourceArn : roleArn ,
176
+ ActionNames : [
177
+ 'ssmmessages:CreateControlChannel' ,
178
+ 'ssmmessages:CreateDataChannel' ,
179
+ 'ssmmessages:OpenControlChannel' ,
180
+ 'ssmmessages:OpenDataChannel' ,
181
+ ] ,
182
+ } )
183
+
184
+ return deniedActions
185
+ }
You can’t perform that action at this time.
0 commit comments