Following below steps:
vault secrets enable -path=“secret” kv
vault kv put secret/myapp/config ttl=‘30s’ username=‘appuser’ password=‘suP3rsec(et!’
echo “path "secret/myapp/*" {
capabilities = ["read", "list"]
}” | vault policy write myapp -
vault auth enable aws
vault write -force auth/aws/config/client
vault write auth/aws/role/sk1.ghosh.cli auth_type=iam bound_iam_principal_arn=“arn:aws:iam:::user/sk1.ghosh.cli” policies=myapp ttl=24h
My CLI returns secret values, but failing when trying to execute using CLI with Vault Agent
vault write auth/aws/role/sk1.ghosh.cli auth_type=iam bound_iam_principal_arn=“arn:aws:iam::837566505083:user/sk1.ghosh.cli” policies=myapp ttl=24h
vault agent -config=./vault-agent.hcl
curl --header “X-Vault-Token: $(cat ./vault-token-via-agent)” $VAULT_ADDR/v1/secret/myapp/config | jq -r “.data”
vault-agent.hcl
exit_after_auth = true
pid_file = “./pidfile”
auto_auth {
method “aws” {
mount_path = “auth/aws”
config = {
type = “iam”
role = “sk1.ghosh.cli”
}
}
sink “file” {
config = {
path = “/root/vault-token-via-agent”
}
}
}
vault {
address = “http://127.0.0.1:8200”