Skip to content

Commit 19eb5d1

Browse files
committed
fix logic error
1 parent f72acc7 commit 19eb5d1

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/ec2/model.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,10 @@ export class Ec2ConnectionManager {
7777
}
7878
}
7979

80-
// public async hasProperPolicies(IamRoleArn: string): Promise<boolean> {
81-
// const attachedPolicies = (await this.iamClient.listAttachedRolePolicies(IamRoleArn)).map(
82-
// policy => policy.PolicyName!
83-
// )
84-
// const requiredPolicies = ['AmazonSSMManagedInstanceCore', 'AmazonSSMManagedEC2InstanceDefaultPolicy']
85-
86-
// return requiredPolicies.length !== 0 && requiredPolicies.every(policy => attachedPolicies.includes(policy))
87-
// }
88-
8980
public async hasProperPermissions(IamRoleArn: string): Promise<boolean> {
9081
const deniedActions = await getDeniedSsmActions(this.iamClient, IamRoleArn)
9182

92-
return deniedActions.length !== 0
83+
return deniedActions.length === 0
9384
}
9485

9586
public async isInstanceRunning(instanceId: string): Promise<boolean> {
@@ -119,9 +110,9 @@ export class Ec2ConnectionManager {
119110
this.throwConnectionError(message, selection, { code: 'EC2SSMPermission' })
120111
}
121112

122-
const hasProperPolicies = await this.hasProperPermissions(IamRole!.Arn)
113+
const hasPermission = await this.hasProperPermissions(IamRole!.Arn)
123114

124-
if (!hasProperPolicies) {
115+
if (!hasPermission) {
125116
const message = `Ensure an IAM role with the required policies is attached to the instance. Found attached role: ${
126117
IamRole!.Arn
127118
}`

0 commit comments

Comments
 (0)