Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
fe9d87d6
Unverified
Commit
fe9d87d6
authored
Jan 19, 2022
by
Mike Mattice
Committed by
GitHub
Jan 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(aws): accept aws mfa tokencode on `acp` cli call (#10130)
Co-authored-by:
Mike Mattice
<
mmattice@reliant.io
>
parent
22c11da1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
README.md
plugins/aws/README.md
+4
-4
aws.plugin.zsh
plugins/aws/aws.plugin.zsh
+5
-3
No files found.
plugins/aws/README.md
View file @
fe9d87d6
...
@@ -16,10 +16,10 @@ plugins=(... aws)
...
@@ -16,10 +16,10 @@ plugins=(... aws)
Run
`asp`
without arguments to clear the profile.
Run
`asp`
without arguments to clear the profile.
*
`asp [<profile>] login`
: If AWS SSO has been configured in your aws profile, it will run the
`aws sso login`
command following profile selection.
*
`asp [<profile>] login`
: If AWS SSO has been configured in your aws profile, it will run the
`aws sso login`
command following profile selection.
*
`acp [<profile>]
`
: in addition to
`asp`
functionality, it actually changes the profile by
*
`acp [<profile>]
[<mfa_token>]`
: in addition to
`asp`
functionality, it actually changes
assuming the role specified in the
`<profile>`
configuration. It supports MFA and se
ts
the profile by assuming the role specified in the
`<profile>`
configuration. It suppor
ts
`$AWS_ACCESS_KEY_ID`
,
`$AWS_SECRET_ACCESS_KEY`
and
`$AWS_SESSION_TOKEN`
, if obtained. It
MFA and sets
`$AWS_ACCESS_KEY_ID`
,
`$AWS_SECRET_ACCESS_KEY`
and
`$AWS_SESSION_TOKEN`
, if
requires the roles to be configured as per the
obtained. It
requires the roles to be configured as per the
[
official guide
](
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html
)
.
[
official guide
](
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html
)
.
Run
`acp`
without arguments to clear the profile.
Run
`acp`
without arguments to clear the profile.
...
...
plugins/aws/aws.plugin.zsh
View file @
fe9d87d6
...
@@ -45,6 +45,7 @@ function acp() {
...
@@ -45,6 +45,7 @@ function acp() {
fi
fi
local
profile
=
"
$1
"
local
profile
=
"
$1
"
local
mfa_token
=
"
$2
"
# Get fallback credentials for if the aws command fails or no command is run
# Get fallback credentials for if the aws command fails or no command is run
local
aws_access_key_id
=
"
$(
aws configure get aws_access_key_id
--profile
$profile
)
"
local
aws_access_key_id
=
"
$(
aws configure get aws_access_key_id
--profile
$profile
)
"
...
@@ -58,9 +59,10 @@ function acp() {
...
@@ -58,9 +59,10 @@ function acp() {
if
[[
-n
"
$mfa_serial
"
]]
;
then
if
[[
-n
"
$mfa_serial
"
]]
;
then
local
-a
mfa_opt
local
-a
mfa_opt
local
mfa_token
if
[[
-z
"
$mfa_token
"
]]
;
then
echo
-n
"Please enter your MFA token for
$mfa_serial
: "
echo
-n
"Please enter your MFA token for
$mfa_serial
: "
read
-r
mfa_token
read
-r
mfa_token
fi
if
[[
-z
"
$sess_duration
"
]]
;
then
if
[[
-z
"
$sess_duration
"
]]
;
then
echo
-n
"Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
echo
-n
"Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
read
-r
sess_duration
read
-r
sess_duration
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment