vault
vault copied to clipboard
Addition of creation of Vault App Roles through Go SDK
Currently, in Golang, as far as I can see, the only way to create an AppRole and specify the roleId and secretId is via Logical calls via the API like so:
vaultClient.Logical().Write("auth/approle/role/concourse", map[string]interface{}{
"backend": "approle",
"role_name": "concourse",
"token_policies": []string{"concourse"},
"token_no_default_policy": "true",
"bind_secret_id": "true",
"token_period": "0",
})
And then if we want to change the role_id and secret_id to be something that we choose we have to do the following.
secret, err := vaultClient.Logical().Write("auth/approle/role/concourse/secret-id", map[string]interface{}{
"secret_id": "secret_id_value",
})
if err != nil {
log.Fatal(err)
}
secretID := secret.Data["secret_id"].(string)
_, err = vaultClient.Logical().Write("auth/approle/role/concourse/role-id", map[string]interface{}{
"role_id": "role_id_value",
})
if err != nil {
log.Fatal(err)
}
Can we just have a dedicated method like we do for enabling of the approle functionality like so
vaultClient.Sys().EnableAuthWithOptions("approle", appRoleOptions)
Seems a bit inconsistent that we have Logical calls to the API for some things and then using the dedicated functions for others.