goformation
goformation copied to clipboard
Short form functions effectively break goformation
For example, if you have a yaml template using !And [condition] instead of Fn::And: [condition], then the !And is simply removed when the template is parsed by the internal yaml parser.
Should the template be pre-processed to convert short form functions into long form so that the yaml template is actually valid yaml?
Edit: This should be documented as well so people don't expect yaml templates with short form functions to work, only to have to spend time figuring out why it's not working
Yikes, yeah, I think I'm hitting this as well. Will try to come up with some code, but looks like something like:
Foo: !Sub "something${AWS::Region}"
Gets converted to something like
Foo: "something${AWS::Region}"
Update: here's a minimal repro:
$ cat main.go
package main
import (
"fmt"
"log"
"github.com/awslabs/goformation"
)
const in = `
AWSTemplateFormatVersion: !Sub "before${AWS::Region}:${AWS::AccountId}after"
`
func main() {
cf, err := goformation.ParseYAML([]byte(in))
if err != nil {
log.Fatalf("parsing stack: %s", err)
}
fmt.Printf("cf.AWSTemplateFormatVersion: %q", cf.AWSTemplateFormatVersion)
}
$ go run main.go
cf.AWSTemplateFormatVersion: "before${AWS::Region}:${AWS::AccountId}after"
Update: never mind. Different bug perhaps. Behaviour is the same with a long-form.
I can see why this would be non-trivial to support: the YAML library goformation's using (a fork of go-yaml v2) doesn't support YAML tags, which is what the short forms are. v3 of go-yaml does support tags via the new Node type, but using this would require custom marshalling for basically every type where a short function could occur.