You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ec2): openTerminal fails on Cloud9 instances #3677
Problem:
Steps to reproduce:
- create a cloud9 ec2 instance
- try to use "open terminal" feature on the instance
- command failed error :(
Questions:
- Why did the toolkit try to use the `AWSCloud9SSMInstanceProfile` role if it's not valid?
- In order to check if an EC2 instance has the proper permissions, we use
the EC2 SDK to get the role name associated with the instance. Then, we
use the IAM SDK to list the policies associated with that role. Therefore,
the toolkit got the `AWSCloud9SSMInstanceProfile` role from the EC2 SDK,
but then the IAM threw an error saying the role does not exist. Currently
unsure why the role is invalid.
- or is it valid, but we need to pass the full ARN to whatever API is throwing the error?
- The docs:
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/IAM.html#listAttachedRolePolicies-property,
only accept the `friendly name` which is the role name and not the ARN.
Once we know why the role doesn't exist (despite being attached to an EC2
instance), that will likely lead us to how we can request more info on it
via SDK.
- or do we need to find a different role and ignore this one?
- Only one IAM role can be attached to each EC2 instance. Since this is the
role we get from the EC2 SDK, there is no other role we can use.
- or can we tell the user something more meaningful about what the problem
actually is, instead of just "NoSuchEntity ... the role cannot be found"?
Solution:
- Show a specific error about what happened. Rather than throwing the general
lacking permission error, mention that there was a failure in retrieving the
policies attached to a given instance.
- Log the ARN of the role we receive from the EC2 SDK.
Note: Because we check for policies before executing `startSession`, it is
possible that the proper policies do exist on the instance, but we fail the
pre-check. Thus, we don't connect despite having the proper polices. One way
around this could be to attempt connection despite a missing role, however this
presents another challenge of what error message to throw if that connection
fails.
0 commit comments