You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# see @ https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository
The AWSecure CLI can autorotate the AWS Access Keys based on the profile that the user is currently using or via cronjob.
35
35
@@ -41,11 +41,12 @@ For example, if you configured to only use in the user request and there are mul
41
41
42
42
The AWS Access Keys auto-rotation works transparently for the users, when the user executes an AWS command (e.g. `aws lambda list-functions`), it will check if needs to rotate the AWS Access Keys for the current AWS Profile. Once the AWS Access Keys auto-rotation steps are done, it will run the command requested by the user (e.g. `aws lambda list-functions`).
43
43
44
-
### How it works - cronjob
45
-
46
44
This allows users to add the AWS Access Keys auto-rotation as a cronjob (e.g. on crontab), so they can disable it when running any AWS command. It's also possible to add multiple entries, one per AWS profile.
47
45
46
+
This is helpful in case you have a profile that you barely use or you want to eliminate the extra ~3 seconds on each command or ~25 seconds when the keys needs to be rotated.
47
+
48
48
For example:
49
+
49
50
Configure the `~/.awsecure-cli` to never run the AWS Access Keys auto-rotation.
50
51
51
52
```bash
@@ -69,6 +70,12 @@ PATH=/usr/local/bin:...
69
70
70
71
> Make sure you have the environment variable PATH configure and pointing to AWSecure CLI.
71
72
73
+
## AWSecure CLI and AWS MFA
74
+
75
+
The AWSecure CLI makes easier to use AWS MFA in the terminal, specially when you have multiple profiles and/or using other tools such as kubectl.
76
+
77
+
The AWSecure CLI can automatically gets the first MFA device configured in your user, request the MFA code and then temporarily stores the session token for the time you define in the `AWSECURE_CLI_MFA_TOKEN_DURATION`. Once the MFA token duration is reached, it will automatically ask you again for the MFA code and renew the session token.
78
+
72
79
## Instalation
73
80
74
81
There are two ways you can install the wrapper. You can create a symbolic link to `/usr/local/bin` (or another place of your choice) or by setting the `awsecure-cli/bin/<INTERPRETER>`.
@@ -100,40 +109,98 @@ These are the configurations that you can define in your `~/.awsecure-cli`.
100
109
| AWSECURE_CLI_LOG_TO_FILE | false | true<br>false | This will send the logs to a file `/tmp/awsecure-cli.log.<Ymd>` (e.g. `/tmp/awsecure-cli.log.20220215`) |
| AWSECURE_CLI_AUTOROTATE_PERIOD | 168 | 1 to ... | This value is based on hours and once your AWS Access Keys are older than this, it will autorotate (168 hours == 7 days) |
103
-
| AWSECURE_CLI_AUTOROTATE_CHECK | daily | daily<br>on-reboot<br>always | This is when the autorotate will be executed.<br>If you're using in the user request, this will only be triggered if you run the AWS CLI |
104
-
| AWSECURE_CLI_AUTOROTATE_ONLY | not defined | true<br>false | This trigger the only the AWS Access Keys auto-rotation, any AWS command (e.g. `aws lambda list-functions`) will be ignored |
112
+
| AWSECURE_CLI_AUTOROTATE_CHECK | daily | daily<br>on-reboot<br>always | This is when the autorotate will be executed.<br>If you're using in the user request, this will only be triggered if you run the AWS CLI. This check is based on your AWSecure CLI utilization. If you don't set it on cronjob or use it, then it will never autorotate your AWS access keys. |
113
+
| AWSECURE_CLI_AUTOROTATE_ONLY | not defined | true<br>false | This trigger only the AWS Access Keys auto-rotation, any AWS command (e.g. `aws lambda list-functions`) will be ignored |
114
+
| AWSECURE_CLI_MFA_ON | false | true<br>false | This will add the AWS_SESSION_TOKEN on (almost) all AWS CLI request. You need to set AWSECURE_CLI_MFA_AUTO_GET_DEVICE or AWSECURE_CLI_MFA_AWS_ARN |
115
+
| AWSECURE_CLI_MFA_AUTO_GET_DEVICE | true | true<br>false | This will automatically get the first AWS MFA device configured in your user and set the AWSECURE_CLI_MFA_AWS_ARN |
116
+
| AWSECURE_CLI_MFA_AWS_ARN | false | string | This is the AWS ARN for the MFA device configured in your user. The ARN starts with `arn:aws:iam::<AWS_Account_ID>:sms-mfa/` or `arn:aws:iam::<AWS_Account_ID>:mfa`. Please, check the "[Checking MFA status](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_checking-status.html) official documentation." |
117
+
| AWSECURE_CLI_MFA_TOKEN_DURATION | 900 | int | This is how long the token will be valid. The token will be temporarly stored locally and renewed once is reaches the time informed. Valid range: Minimum value of 900 (15 minutes). Maximum value of 129600 (36 hours) - Please, check the [AWS official documentation - AWS STS API Reference](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetSessionToken.html#API_GetSessionToken_RequestParameters)|
105
118
106
119
> \* mandatory parameter
107
120
108
-
### Example
121
+
## Configuration examples
122
+
123
+
These are some of the configuration examples you can have in your AWSecure CLI.
124
+
125
+
### Minimal (inc. Access keys autorotation)
126
+
127
+
The `AWSECURE_CLI_AWS_BIN_FILEPATH` is the only thing you have to define. All the other configurations already have a pre-defined value or it's not mandatory.
109
128
110
-
You can configure via `~/.awsecure-cli`.
129
+
This will autorotate your AWS Access keys every 168 hours (7 days) and checking if it's needed to rotate every day.
AWSecure CLI can also be integrated with kubectl. The AWSCLI is used to get the session-token and autheticate to your EKS cluster.
186
+
187
+
The only mandatory for this, is the `AWSECURE_CLI_MUTED="false"`. This is because kubectl only accepts a specific JSON return, anything more than that will cause an error and prevent you from using the kubectl.
Make sure you have, at least, the `AWS_PROFILE` and `AWSECURE_CLI_MUTED` defined in your `~/.kube/config`.
147
214
215
+
> In case you define the `AWSECURE_CLI_AUTOROTATE_PERIOD` via `~/.kube/config`, make sure it's the same as the one defined via `~/.awsecure-cli` and/or environment variables.
This will use the MFA for every kubectl request you make and it will automatically gets your first MFA device.
249
+
250
+
To use the MFA is relative simply, but since kubectl will isn't interactive, you can't pass the MFA code. So, in order to fix it, you have to first run an AWSCLI command (e.g. `aws s3 ls`) to create the session token and then you can use the kubectl. You can also disable the MFA only for kubectl.
> In case you define the `AWSECURE_CLI_MFA_TOKEN_DURATION` via `~/.kube/config`, make sure it's the same as the one defined via `~/.awsecure-cli` and/or environment variables.
0 commit comments