hashicorp / hashicorp/vault-lambda-extension
How to use with HCP Vault?
- Dominant language
- Go
- Stars
- 148
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
I'm following the quickstart and following this video [AWS re:Invent - Using Vault with AWS Lambda and More](https://www.youtube.com/watch?v=U3zHvg-2WJw) with a Vault server hosted on Hashicorp Cloud Platform.
I'm stuck at the third step of the guide, running `vault write auth/aws/role/vault-lambda-role`
Around the minute [16:12](https://youtu.be/U3zHvg-2WJw?t=972) of the video I linked a similar issue is mentioned, but the solution is not very clear.
These are the commands I ran:
Configure my Vault client
```sh
export VAULT_ADDR=""
export VAULT_TOKEN=""
export VAULT_NAMESPACE=admin
```
Enable AWS auth backend and configure it as the guide says
```sh
vault auth enable aws
Success! Enabled aws auth method at: aws/
```
```sh
vault write -force auth/aws/config/client
Success! Data written to: auth/aws/config/client
```
Add a config STS since my lambda and its role are not in the same account as my user:
```sh
vault write auth/aws/config/sts/*** auth_type=iam sts_role="arn:aws:iam::***:role/vault-lambda-role"
Success! Data written to: auth/aws/config/sts/***
```
Then run the final command from the guide
```sh
vault write auth/aws/role/vault-lambda-role \
auth_type=iam \
bound_iam_principal_arn="arn:aws:iam::***:role/vault-lambda-role" \
policies="serverless" \
ttl=1h
Error writing data to auth/aws/role/vault-lambda-role: Error making API request.
URL: PUT https://***.aws.hashicorp.cloud:8200/v1/auth/aws/role/vault-lambda-role
Code: 400. Errors:
* unable to resolve ARN "arn:aws:iam::***:role/vault-lambda-role" to internal ID: AccessDenied: User: arn:aws:sts::285268573241:assumed-role/HCP-Vault-333b91a7-4002-4181-b026-ca105a6eca86-VaultNode/i-06f09e6fc27076955 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::***:role/vault-lambda-role
status code: 403, request id: 3044253b-6b33-4f8b-93a5-935c600fd211
```
This is the assume role policy of my role:
```hcl
data "aws_iam_policy_document" "assume_role" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
}
```
I already tried allowing the assumed role from the error message, with no success:
```hcl
data "aws_iam_policy_document" "assume_role" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = [
"arn:aws:sts::285268573241:assumed-role/HCP-Vault-333b91a7-4002-4181-b026-ca105a6eca86-VaultNode/i-06f09e6fc27076955"
]
}
}
}
```
Am I missing something? How do I allow the HCP Vault user to assume my lambda role? Any help would be appreciated. Thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.