Closed nitrocode closed 2 months ago
Just tried this with v0.27.0 which should have the support but get an error. Here's the command I'm using (adapted from release notes):
granted sso populate --sso-region us-west-2 --profile-template '{{ .RoleName | strings.ToLower }}/{{ .AccountName | strings.ToLower }}' https://<endpoint>.awsapps.com/start
Here's the error.
[✘] template: :1: function "strings" not defined
Am I just missing something simple?
Nevermind, this works. --profile-template '{{ .RoleName | lower }}/{{ .AccountName | lower }}'
Oh very nice. Thank you @mikesarver for the contribution and @jmreicha for confirming that it works.
Also, it looks like sprig functions have been in granted's cli since https://github.com/common-fate/granted/releases/tag/v0.25.0 which was released shortly after the dependency was bumped https://github.com/common-fate/granted/pull/648 to v0.9.0
Context
I'd like to generate my profiles with the following template
I'd like to lowercase it using
strings.ToLower
. Here is an example fromgomplate
which worksHere is the error
Workaround
If I just want to lowercase, then it's pretty simple as I can lowercase all the profile names
But I'd also like to delete
-,.
n names and maybe do additional string manipulations. I suppose these can be done using sed as well.References
Maybe the issue is in the common-fate/awsconfigfile package
Perhaps instead of using text/template, the masterminds/sprig library should be used instead?