This is the sixth post in a series on Vault. For previous posts see, Getting Started, Secrets Engines, Manage Policies, Access Secrets, and Database Dynamic Secrets.
Overview Link to heading
One of the key powerful features of Vault is the ability to dynamically generate credentials. The previous post on Secrets Engines discussed the possible cloud options Vault provides for dynamic credentials.
This post will dive in and look at using Vault to generate dynamic credentials for Amazon Web Services (AWS). The sequence of steps is similar for AliCloud, Google Cloud, and Microsoft Azure.
The general workflow is:
- Enable cloud specific secrets engine
- Connect to cloud with credentials
- Create necessary roles
- Generate cloud role credentials as needed
Connect to the Cloud Link to heading
First, enable the AWS secret engine and pass in credentials that have permission to generate users and appropriate roles. In this example, an engine specific to the us-west-2 region is specified:
|
|
Do not use the root account with Vault. A user should instead create a dedicated user with the correct permissions specific for Vault. Vault provides an example IAM policy that would work to do this.
Cloud Role Link to heading
Next, when users request credentials they will request targetting a specific cloud role. The role will specify the access to the credentials grant. In the case of AWS, a role will include an IAM policy. Here is an example that would give the user permissions specific to AWS EC2:
|
|
For AWS, Vault will also accpet specific policy ARNs or an IAM group:
|
|
Cloud Credentials Link to heading
Finally, when users create credentials against a role, Vault will create an IAM user and attach the policy document to the user. Vault then creates and returns an access key and secret key for the user.
|
|
In the AWS Console these users will show up with the user name of
vault-token-$role-$timestamp
.
Other Clouds Link to heading
Again the basic workflow show above is similar on other clouds that Vault can connect to. The differences are in specifying the role policies, which are cloud-specific.