Browse code
feat: allow opening the console in a specific region
Ed Langley authored on 29/06/2020 19:23:57
Showing 2 changed files
Showing 2 changed files
... | ... |
@@ -34,9 +34,20 @@ |
34 | 34 |
:items '(:|Developer Role| :|Provisioner Role|) |
35 | 35 |
:reader role-selector |
36 | 36 |
:selected-item keyword:|Developer Role|) |
37 |
+ (region-selector capi:option-pane |
|
38 |
+ :reader region-selector |
|
39 |
+ ;; :external-max-width '(character 35) |
|
40 |
+ :items (list "us-east-1" "us-east-2" |
|
41 |
+ "us-west-1" "us-west-2" |
|
42 |
+ "ca-central-1" |
|
43 |
+ "eu-central-1" |
|
44 |
+ "eu-west-1" "eu-west-2")) |
|
45 |
+ (open-console-button capi:push-button |
|
46 |
+ :selection-callback 'execute-action |
|
47 |
+ :callback-type :data-interface |
|
48 |
+ :data :|Open Web Console|) |
|
37 | 49 |
(action-buttons capi:push-button-panel |
38 |
- :items '(:|Open Web Console| |
|
39 |
- :|Authorize iTerm| |
|
50 |
+ :items '(:|Authorize iTerm| |
|
40 | 51 |
:|Cloudformation Stacks|) |
41 | 52 |
:selection-callback 'execute-action |
42 | 53 |
:callback-type :data-interface) |
... | ... |
@@ -58,8 +69,12 @@ |
58 | 69 |
(action-layout capi:row-layout |
59 | 70 |
`(nil |
60 | 71 |
action-buttons)) |
72 |
+ (webconsole-layout capi:row-layout |
|
73 |
+ '(region-selector |
|
74 |
+ open-console-button)) |
|
61 | 75 |
(right-layout capi:column-layout |
62 | 76 |
'(output-pane |
77 |
+ webconsole-layout |
|
63 | 78 |
action-layout)) |
64 | 79 |
(main-layout capi:row-layout |
65 | 80 |
'(data-layout |
... | ... |
@@ -78,7 +93,9 @@ |
78 | 93 |
(signin-token (gethash "SigninToken" |
79 | 94 |
(yason:parse |
80 | 95 |
(dexador:get federation-url))))) |
81 |
- (open-url (url-from-signin-token signin-token)))) |
|
96 |
+ (open-url (url-from-signin-token signin-token |
|
97 |
+ (capi:choice-selected-item |
|
98 |
+ (region-selector interface)))))) |
|
82 | 99 |
(:method ((action (eql :|Authorize iTerm|)) (interface mfa-tool)) |
83 | 100 |
(uiop:run-program (format nil "osascript '~a'" |
84 | 101 |
(probe-file |
... | ... |
@@ -41,20 +41,26 @@ |
41 | 41 |
:initform (cells:c-in nil)) |
42 | 42 |
(session-id :reader session-id |
43 | 43 |
:initform (cells:c? (typecase (^credentials) |
44 |
- (aws:credentials (aws-sdk/credentials/base:credentials-access-key-id (^credentials))) |
|
44 |
+ (aws:credentials |
|
45 |
+ (aws-sdk/credentials/base:credentials-access-key-id |
|
46 |
+ (^credentials))) |
|
45 | 47 |
(cons (serapeum:assocadr "AccessKeyId" (^credentials) |
46 | 48 |
:test 'equal))))) |
47 |
- (session-key :reader session-key |
|
49 |
+ (session-key :reader session-key |
|
48 | 50 |
:initform (cells:c? (typecase (^credentials) |
49 |
- (aws:credentials (aws-sdk/credentials/base:credentials-secret-access-key (^credentials))) |
|
51 |
+ (aws:credentials |
|
52 |
+ (aws-sdk/credentials/base:credentials-secret-access-key |
|
53 |
+ (^credentials))) |
|
50 | 54 |
(cons (serapeum:assocadr "SecretAccessKey" (^credentials) |
51 | 55 |
:test 'equal))))) |
52 |
- (session-token :reader session-token |
|
56 |
+ (session-token :reader session-token |
|
53 | 57 |
:initform (cells:c? (typecase (^credentials) |
54 |
- (aws:credentials (aws-sdk/credentials/base:credentials-session-token (^credentials))) |
|
58 |
+ (aws:credentials |
|
59 |
+ (aws-sdk/credentials/base:credentials-session-token |
|
60 |
+ (^credentials))) |
|
55 | 61 |
(cons (serapeum:assocadr "SessionToken" (^credentials) |
56 | 62 |
:test 'equal))))) |
57 |
- (url-params :reader url-params |
|
63 |
+ (url-params :reader url-params |
|
58 | 64 |
:initform (cells:c? (fw.lu:alist-string-hash-table |
59 | 65 |
`(("sessionId" . ,(^session-id)) |
60 | 66 |
("sessionKey" . ,(^session-key)) |
... | ... |
@@ -69,8 +75,13 @@ |
69 | 75 |
:secret-access-key (session-key source) |
70 | 76 |
:session-token (session-token source)))) |
71 | 77 |
|
72 |
-(defun url-from-signin-token (signin-token) |
|
73 |
- (format nil "https://signin.aws.amazon.com/federation?Action=login&Destination=https%3A%2F%2Fconsole.aws.amazon.com&SigninToken=~a" |
|
78 |
+(defun url-from-signin-token (signin-token &optional (region "us-west-2")) |
|
79 |
+ (format nil #.(concatenate 'string |
|
80 |
+ "https://signin.aws.amazon.com/federation?" |
|
81 |
+ "Action=login&" |
|
82 |
+ "Destination=https%3A%2F%2F~a.console.aws.amazon.com&" |
|
83 |
+ "SigninToken=~a") |
|
84 |
+ region |
|
74 | 85 |
signin-token)) |
75 | 86 |
|
76 | 87 |
(defun read-new-aws-credentials () |
... | ... |
@@ -104,7 +115,7 @@ |
104 | 115 |
:credentials (serapeum:assocdr "Credentials" api-result |
105 | 116 |
:test 'equal))) |
106 | 117 |
(federation-url (url parser)) |
107 |
- (signin-token (gethash "SigninToken" |
|
118 |
+ (signin-token (gethash "SigninToken" |
|
108 | 119 |
(yason:parse |
109 | 120 |
(dexador:get federation-url))))) |
110 | 121 |
(values signin-token |