Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

SSM startSession does not work with AWS-StartPortForwardingSession #7

Closed
3 tasks done
dmattia opened this issue Mar 15, 2020 · 4 comments
Closed
3 tasks done
Assignees
Labels
feature-request New feature or request ssm

Comments

@dmattia
Copy link

dmattia commented Mar 15, 2020

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
Forwarding remote ports to local ports does not work through the SDK.

Is the issue in the browser/Node.js?
Node.js

If on Node.js, are you running this on AWS Lambda?
No

Details of the browser/Node.js version
v12.14.0

SDK version number
v2.638.0

To Reproduce (observed behavior)

    const params = {
      DocumentName: "AWS-StartPortForwardingSession",
      Target: "i-<my_instance>",
      Parameters: {
        portNumber: ["8200"],
        localPortNumber: ["8200"],
      }
    };
    await ssm.startSession(params).promise();

The above code runs, and the promise returns successfully without throwing any error. However, the specified local port is not bound to.

Expected behavior
I expected that local port 8200 would be bound to, just like if I had run

aws ssm start-session \
  --target "i-<my_instance>" \
  --document-name "AWS-StartPortForwardingSession" \
  --parameters '{"portNumber": ["8200"], "localPortNumber": ["8200"]}'

which does bind to my local port

@ajredniwja
Copy link

Hey @dmattia thank-you for reaching out, you are right about the behavior, it is because the feature has not been implemented yet. This is mentioned in the API reference. The Parameters being just a name space for future use by the service team which can also be confirmed in https://github.com/aws/aws-sdk-js/blob/bda2ee776a8e6435b529cde2ab9b86e006a95e30/apis/ssm-2014-11-06.min.json#L4016-L4022

Marking it as a feature request for the service team. Please reach out if you have any additional questions.

@ajredniwja ajredniwja transferred this issue from aws/aws-sdk-js Nov 6, 2020
@ajredniwja ajredniwja added feature-request New feature or request service-api This issue pertains to the AWS API labels Nov 7, 2020
@stobrien89 stobrien89 added ssm feature-request New feature or request and removed feature-request New feature or request service-api This issue pertains to the AWS API labels Jul 26, 2021
@peterwoodworth peterwoodworth self-assigned this Sep 22, 2021
@peterwoodworth
Copy link
Contributor

I've submitted this as a ticket, and received a couple responses from the team. There seems to be a misunderstanding here of how startSession works. Read the replies below, I've bolded the most important part:

There's a custom logic in aws ssm start-session aws cli implementation that after successful SSM Start-Session API call, the CLI triggers SessionManagerPlugin which handles PortForwarding. Session Manager is only available via aws cli or aws session manager console.

To clarify, the startsession call from the sdk is only the first step necessary in the protocol needed to initiate a session, port forwarding or otherwise. Any parameters in that API call would only modify the initial startSession request. The client code contained in the SessionManagerPlugin handles what type of session is created from the response, and subsequently, any parameters that are passed to the session itself.

@github-actions
Copy link

This issue is now closed.

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@decatur
Copy link

decatur commented Dec 11, 2021

See answer to How to use session-manager-plugin command for how to achieve this with boto3 and Python.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request New feature or request ssm
Projects
None yet
Development

No branches or pull requests

5 participants