I am trying to change the policy for the s3 bucket to aws. I created the following json structure for the policy:
type Policy struct {
Version string `json:"Version"`
Id string `json:"Id"`
Statement []Statement `json:"Statement"`
}
type Statement struct {
Sid string `json:"Sid"`
Effect string `json:"Effect"`
Principal Principal `json:"Principal"`
Action []string `json:"Action"`
Resource []string `json:"Resource"`
}
type Principal struct {
AWS[]string `json:"AWS"`
}
Which is great for posting bucket rules. The problem occurs when I try to get the current policy and change it.
If there is an operator that has only one AWS, Action, or Resource value, Amazon will convert it from the array to a simple value, resulting in my unmarshalling will fail.
Is there any way to specify AWS / Action / Resource values as a slice of a string or just a string?
I know that there are packages that I could use to get around this to some extent ( github.com/Jeffail/gabsfor example), but it would be easier to just create a JSON structure, as it is quite simple.