Documentation
¶
Overview ¶
Package parse provides functions for parsing CloudFormation templates from JSON and YAML inputs.
Example ¶
package main
import (
"fmt"
"github.com/aws-cloudformation/rain/cft/parse"
)
func main() {
template, _ := parse.String(`
Resources:
Bucket:
Type: AWS::S3::Bucket
`)
fmt.Println(template.Map())
}
Output: map[Resources:map[Bucket:map[Type:AWS::S3::Bucket]]]
Index ¶
- Constants
- func File(fileName string) (cft.Template, error)
- func Map(input map[string]interface{}) (cft.Template, error)
- func Node(n *yaml.Node) (cft.Template, error)
- func NormalizeNode(n *yaml.Node) error
- func Reader(r io.Reader) (cft.Template, error)
- func String(input string) (cft.Template, error)
- func Verify(source cft.Template, output string) error
- type SubWord
Examples ¶
Constants ¶
View Source
const ( DATA rune = ' ' // Any other rune DOLLAR rune = '$' OPEN rune = '{' CLOSE rune = '}' BANG rune = '!' )
View Source
const ( STR wordtype = iota // A literal string fragment REF // ${ParamOrResourceName} AWS // ${AWS::X} RAIN // ${Rain::X} GETATT // ${X.Y} )
View Source
const ( READSTR state = iota MAYBE READVAR READLIT )
Variables ¶
This section is empty.
Functions ¶
func NormalizeNode ¶ added in v1.8.0
func NormalizeNode(n *yaml.Node) error
NormalizeNode takes a *yaml.Node and convert tag-style names into map-style, and converts other scalars into a canonical format
Types ¶
type SubWord ¶ added in v1.8.0
type SubWord struct {
T wordtype
W string // Does not include the ${} if it's not a STR
}
func ParseSub ¶ added in v1.8.0
ParseSub returns a slice of words, based on a string argument to the Fn::Sub intrinsic function.
"ABC-${XYZ}-123"
returns a slice containing:
SubWord { T: STR, W: "ABC-" }
SubWord { T: REF, W: "XYZ" }
SubWord { T: STR, W: "-123" }
Invalid syntax like "${AAA" returns an error
Click to show internal directories.
Click to hide internal directories.