Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5844 AWS Root Credential Rotation #9921

Merged
merged 11 commits into from
Sep 15, 2020
Merged

Conversation

Valarissa
Copy link
Contributor

@Valarissa Valarissa commented Sep 10, 2020

This is to re-introduce the changes found in #7131

Output of a live run:

~/hashicorp/vault (5844-aws-root-cred-rotation ✔) ᐅ vault secrets enable aws
Success! Enabled the aws secrets engine at: aws/

~/hashicorp/vault (5844-aws-root-cred-rotation ✔) ᐅ vault write aws/config/root \
access_key=`echo $AWS_ACCESS_KEY_ID` \
secret_key=`echo $AWS_SECRET_ACCESS_KEY` \
region=us-east-2
Success! Data written to: aws/config/root

~/hashicorp/vault (5844-aws-root-cred-rotation ✔) ᐅ vault write aws/roles/test-role \
credential_type=iam_user \
policy_document=-<<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "ec2:*",
      "Resource": "*"
    }
  ]
}
EOF
Success! Data written to: aws/roles/test-role

~/hashicorp/vault (5844-aws-root-cred-rotation ✔) ᐅ vault read aws/creds/test-role
Key                Value
---                -----
lease_id           aws/creds/test-role/rLU3oLqyBQbAZgtg00hMLnOx
lease_duration     768h
lease_renewable    true
access_key         AKIA****************
secret_key         Q********************************1
security_token     <nil>

~/hashicorp/vault (5844-aws-root-cred-rotation ✔) ᐅ vault write -force aws/config/rotate-root
Key           Value
---           -----
access_key    AKIA****************

~/hashicorp/vault (5844-aws-root-cred-rotation ✔) ᐅ vault read aws/config/root
Key             Value
---             -----
access_key      AKIA****************
iam_endpoint    n/a
max_retries     -1
region          us-east-2
sts_endpoint    n/a

~/hashicorp/vault (5844-aws-root-cred-rotation ✔) ᐅ vault read aws/creds/test-role
Key                Value
---                -----
lease_id           aws/creds/test-role/HLYPlZeMo5L40idcX5c2J4mx
lease_duration     768h
lease_renewable    true
access_key         AKIA****************
secret_key         M********************************J
security_token     <nil>
~/hashicorp/vault (5844-aws-root-cred-rotation ✔) ᐅ vault write -force aws/config/rotate-root
Key           Value
---           -----
access_key    AKIA****************

@Valarissa Valarissa requested a review from a team September 10, 2020 18:54
Copy link
Contributor

@calvn calvn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly did a diff scan since the original PR has been reviewed and approved.

@calvn calvn added this to the 1.6 milestone Sep 10, 2020
@calvn calvn added the auth/aws label Sep 10, 2020
Copy link
Contributor

@calvn calvn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved a bit too quick without looking at CI, but left some follow-up comments :)

@calvn calvn self-requested a review September 10, 2020 20:15
@Valarissa Valarissa force-pushed the 5844-aws-root-cred-rotation branch from 23fe029 to 57320a3 Compare September 11, 2020 17:35
@Valarissa
Copy link
Contributor Author

Had to update the vendor files in order to get CI passing.

Copy link
Contributor

@tomhjp tomhjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM. Given the endpoint in question, I don't think the race is likely to happen, but it also seems unnecessary to me. Perhaps I am just missing some context though.

@@ -138,6 +138,46 @@ $ curl \
http://127.0.0.1:8200/v1/auth/aws/config/client
```

## Rotate Config Credentials
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Would Rotate Root Credentials be a slightly better title?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied all of the docs from a previous PR, unsure what others think about this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The equivalent on AWS Secrets Engine refers this operation as "Rotate Root [IAM] Credentials", so I I think using that here as well is fine :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Change to docs will be made after manual testing is finished 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good, just pushed up a new commit to take care of this. :D

builtin/credential/aws/path_config_rotate_root.go Outdated Show resolved Hide resolved
Region: aws.String(region),

// Prevents races.
HTTPClient: cleanhttp.DefaultClient(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow TIL. I never thought about the need for this before.

builtin/credential/aws/path_config_rotate_root_test.go Outdated Show resolved Hide resolved
@Valarissa Valarissa force-pushed the 5844-aws-root-cred-rotation branch from 57320a3 to d723743 Compare September 14, 2020 21:03
@Valarissa Valarissa merged commit 4ff444f into master Sep 15, 2020
@kalafut kalafut deleted the 5844-aws-root-cred-rotation branch September 15, 2020 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants