Skip to main content
In this guide, you will learn how to configure HashiCorp Vault’s AWS Secrets Engine using the assumed_role credential type to obtain temporary, cross-account AWS credentials. Vault runs in Account A (ID ending in 6147) and will assume a role in Account B (ID ending in 2126) to generate scoped credentials.

Table of Contents

  1. Verify Vault Cluster Health
  2. Prepare Target AWS Account (Account B)
    2.1 Inspect Existing Role (Optional)
    2.2 Create a Customer-Managed Policy
    2.3 Create a Role Trusted by Vault’s Account
  3. Enable & Configure AWS Secrets Engine
  4. Define Vault Role for Cross-Account Access
  5. Generate & Use Temporary Credentials
  6. Flowchart
  7. Conclusion
  8. References

1. Verify Vault Cluster Health

First, ensure your Vault cluster in Account A is initialized, unsealed, and active.
Expected output:

IAM Role Permissions for Vault EC2 Nodes

Attach a policy to your Vault EC2 instances that permits required AWS API actions:

2. Prepare Target AWS Account (Account B)

In Account B, you will create an IAM policy and role that Vault in Account A can assume.

2.1 Inspect Existing Role (Optional)

The image shows an AWS Identity and Access Management (IAM) console displaying the summary of a role, including its permissions policies and details like Role ARN, creation time, and maximum session duration.

2.2 Create a Customer-Managed Policy

Navigate to IAM > Policies > Create policy in the AWS Console and add S3 access permissions:
The image shows the AWS Identity and Access Management (IAM) Management Console with a focus on the "Policies" section, displaying two customer-managed policies related to "vault."

2.3 Create a Role Trusted by Vault’s Account

  1. Go to IAM > Roles > Create role.
  2. Select Another AWS account as the trusted entity and enter Vault’s Account ID (...6147).
  3. Attach the policy you just created (e.g., vault-role-bucket-access).
  4. Name the role vault-role-bucket-access and complete creation.
The image shows an AWS IAM Management Console screen for creating a role, with options to select the type of trusted entity and choose a use case. In the background, there is a terminal window with some text.
The image shows an AWS IAM Management Console screen where a user is creating a role by selecting a trusted entity type, specifically another AWS account. The background displays a terminal window with some text.

3. Enable & Configure AWS Secrets Engine

Back in Account A, enable and configure Vault’s AWS Secrets Engine.
Next, update the IAM role policy attached to your Vault servers to permit assuming the new cross-account role:
Apply your changes (for example, via Terraform):
To support multiple target roles or accounts, add additional role ARNs to the Resource array in the PermitAccessToCrossAccountRole statement.

4. Define Vault Role for Cross-Account Access

Create a Vault role that references the IAM role in Account B:

5. Generate & Use Temporary Credentials

  1. Generate STS credentials with a 1-hour TTL:
  2. Export credentials to your shell: Linux/macOS:
    Windows PowerShell:
  3. Use the temporary credentials:

6. Flowchart

The image is a flowchart illustrating the "Assumed_Role Method" for managing dynamic secrets with AWS, detailing the process of requesting, generating, and revoking AWS credentials using Vault and AWS STS.

7. Conclusion

You have successfully configured Vault’s AWS Secrets Engine to assume a role in a separate AWS account, generate temporary credentials scoped to that role’s permissions, and consume those credentials to perform cross-account operations. This architecture is highly scalable—simply extend the IAM policy and add Vault roles for additional accounts or use cases.

8. References

Watch Video