Skip to content

Commit 2fc5623

Browse files
committed
Add docs for rotate and clearer errors
1 parent aad54a1 commit 2fc5623

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,31 @@ Then when you use the `admin` profile, `aws-vault` will look in the `read-only`
106106

107107
**Note:** When assuming roles, `mfa_serial` will not be inherited from the profile designated in `source_profile` -- you must include a reference to `mfa_serial` in every profile you wish to use it with.
108108

109+
## Rotating Credentials
110+
111+
Regularly rotating your access keys is a critical part of credential management. You can do this with the `aws-vault rotate <profile>` command as often as you like.
112+
113+
The minimal IAM policy required to rotate your own credentials is:
114+
115+
```json
116+
{
117+
"Version": "2012-10-17",
118+
"Statement": [
119+
{
120+
"Effect": "Allow",
121+
"Action": [
122+
"iam:CreateAccessKey",
123+
"iam:DeleteAccessKey",
124+
"iam:GetUser"
125+
],
126+
"Resource": [
127+
"arn:aws:iam::*:user/${aws:username}"
128+
]
129+
}
130+
]
131+
}
132+
```
133+
109134
## Development
110135

111136
Developed with golang, to install run:

cli/rotate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func RotateCommand(app *kingpin.Application, input RotateCommandInput) {
4444
Config: awsConfig,
4545
}
4646

47-
fmt.Printf("Rotating credentials for profile %q\n", input.Profile)
47+
fmt.Printf("Rotating credentials for profile %q (takes 10-20 seconds)\n", input.Profile)
4848

4949
if err := rotator.Rotate(input.Profile); err != nil {
5050
app.Fatalf(awsConfig.FormatCredentialError(err, input.Profile))

vault/rotator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (r *Rotator) Rotate(profile string) error {
8080
var iamUserName *string
8181

8282
// A username is needed for some IAM calls if the credentials have assumed a role
83-
if oldSessionVal.SessionToken != "" {
83+
if oldSessionVal.SessionToken != "" || currentUserName != "root" {
8484
iamUserName = aws.String(currentUserName)
8585
}
8686

0 commit comments

Comments
 (0)