-
Notifications
You must be signed in to change notification settings - Fork 11
/
aws-console
executable file
·48 lines (32 loc) · 954 Bytes
/
aws-console
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
import json
import sys
import webbrowser
import boto3
import requests
try:
service_name = sys.argv[1]
except IndexError:
service_name = 'console'
federation_url = 'https://signin.aws.amazon.com/federation'
destination_url = f'https://console.aws.amazon.com/{service_name}'
session = boto3.Session()
session_credentials = session.get_credentials()
credentials = {
'sessionId': session_credentials.access_key,
'sessionKey': session_credentials.secret_key,
'sessionToken': session_credentials.token,
}
params = {
'Action': 'getSigninToken',
'SessionDuration': 43200,
'Session': json.dumps(credentials),
}
response = requests.get(federation_url, params=params)
params = {
'Action': 'login',
'Destination': destination_url,
'SigninToken': response.json()['SigninToken']
}
request = requests.Request('GET', federation_url, params=params).prepare()
webbrowser.open(request.url)