startSession method
Initiates a connection to a target (for example, an instance) for a Session Manager session. Returns a URL and token that can be used to open a WebSocket connection for sending input and receiving outputs.
AWS Tools for PowerShell usage: Start-SSMSession is not currently supported by AWS Tools for PowerShell on Windows local machines.
May throw InvalidDocument. May throw TargetNotConnected. May throw InternalServerError.
Parameter target
:
The instance to connect to for the session.
Parameter documentName
:
The name of the SSM document to define the parameters and plugin settings
for the session. For example, SSM-SessionManagerRunShell
. You
can call the GetDocument API to verify the document exists before
attempting to start a session. If no document name is provided, a shell to
the instance is launched by default.
Parameter parameters
:
Reserved for future use.
Implementation
Future<StartSessionResponse> startSession({
required String target,
String? documentName,
Map<String, List<String>>? parameters,
}) async {
ArgumentError.checkNotNull(target, 'target');
_s.validateStringLength(
'target',
target,
1,
400,
isRequired: true,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AmazonSSM.StartSession'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Target': target,
if (documentName != null) 'DocumentName': documentName,
if (parameters != null) 'Parameters': parameters,
},
);
return StartSessionResponse.fromJson(jsonResponse.body);
}