i am able to use AWS SSM CLI to establish a port forwarding connection and open a RDP session with an EC2 instance by using below command.
aws ssm start-session --target <InstanceID> --document-name AWS-StartPortForwardingSession --parameters portNumber="3389","localPortNumber"="1101""
Now i am trying the same with .NET SDK by using class "AmazonSimpleSystemsManagementClient" and callsing "StartSession" method, this method returns a "SessionResponse" class with session id and other parameters.
code is as below.
var client = new AmazonSimpleSystemsManagementClient(strAccessKeyID,strSecretAccessKey,strSessionToken, RegionEndpoint.USEast1);
var res = client.GetDocument("AWS-StartPortForwardingSession");
Amazon.SimpleSystemsManagement.Model.StartSessionRequest request = new Amazon.SimpleSystemsManagement.Model.StartSessionRequest();
Dictionary<string, List<string>> paramDict = new Dictionary<string, List<string>>();
paramDict.Add("portNumber", new List<string>() { "3389" });
paramDict.Add("localPortNumber", new List<string> { "1101"});
var sessionResponse = client.StartSession(new
Amazon.SimpleSystemsManagement.Model.StartSessionRequest()
{
DocumentName = "AWS-StartPortForwardingSession",
Target = "<InstanceID>",
Parameters = paramDict
}) ;
Console.WriteLine(sessionResponse.SessionId);
with the above code the session reponse is returning successfully but the issue is not able to open a RDP session. Any idea why RDP is not working?.
thanks, Sarath.