Is there a better way to handle JSON policy docume...
# golang
a
Is there a better way to handle JSON policy documents (thinking AWS IAM, bucket policies here) than just a huge mangled string?
g
b
I generally tend to define the structs explicitly rather than
map[string]interface{}
https://github.com/jaxxstorm/iac-in-go/blob/master/eks/kubeConfig.go @ambitious-salesmen-39356
👍 1
a
I'll take a look at both of these - thank you.
b
@gentle-diamond-70147 we should add some overlays for this stuff I think
👍 1
g
@billowy-army-68599 agreed!
a
what would overlay mean in this context?
b
An overlay is like a helper method built into the SDK that abstracts some of this pain away
b
Handy tool for generating the structs: https://mholt.github.io/json-to-go/
i
as a third approach, i’ve been using Go templates: https://pkg.go.dev/github.com/gwatts/pulutil/template/#example-NewJSON
combining the explicit struct or map approach with a library to handle the json + apply might be a nice half-way measure perhaps