Documentation
¶
Overview ¶
Package cft provides the Template type that models a CloudFormation template.
The sub-packages of cft contain various tools for working with templates
Index ¶
- Constants
- Variables
- func AppendStateMap(state *Template) *yaml.Node
- func IsRef(n *yaml.Node) bool
- func ReplaceIdentifier(s, k, identifier string) string
- type Comment
- type FnForEach
- type Intrinsic
- type ModuleConfig
- type PackageAlias
- type Resource
- type Section
- type Template
- func (t Template) AddComments(comments []*Comment) error
- func (t Template) AddMapSection(section Section) (*yaml.Node, error)
- func (t *Template) AddMappedModule(copiedConfig *ModuleConfig)
- func (t *Template) AddResolvedModuleNode(n *yaml.Node)
- func (t Template) AddScalarSection(section Section, val string) error
- func (t Template) GetNode(section Section, name string) (*yaml.Node, error)
- func (t Template) GetParameter(name string) (*yaml.Node, error)
- func (t Template) GetResource(name string) (*yaml.Node, error)
- func (t Template) GetResourcesOfType(typeName string) []*Resource
- func (t Template) GetSection(section Section) (*yaml.Node, error)
- func (t Template) GetTypes() ([]string, error)
- func (t Template) HasSection(section Section) bool
- func (t Template) Map() map[string]interface{}
- func (t *Template) ModuleAlreadyResolved(n *yaml.Node) bool
- func (t *Template) ParseModuleConfig(name string, n *yaml.Node) (*ModuleConfig, error)
- func (t Template) RemoveEmptySections()
- func (t Template) RemoveSection(section Section) error
Constants ¶
const ( Source string = "Source" Properties string = "Properties" Overrides string = "Overrides" ForEach string = "Fn::ForEach" )
Variables ¶
var Tags = map[string]string{
"!And": "Fn::And",
"!Base64": "Fn::Base64",
"!Cidr": "Fn::Cidr",
"!Equals": "Fn::Equals",
"!FindInMap": "Fn::FindInMap",
"!GetAZs": "Fn::GetAZs",
"!GetAtt": "Fn::GetAtt",
"!If": "Fn::If",
"!ImportValue": "Fn::ImportValue",
"!Join": "Fn::Join",
"!Not": "Fn::Not",
"!Or": "Fn::Or",
"!Select": "Fn::Select",
"!Split": "Fn::Split",
"!Sub": "Fn::Sub",
"!Ref": "Ref",
"!Condition": "Condition",
"!Rain::Embed": "Rain::Embed",
"!Rain::Include": "Rain::Include",
"!Rain::Env": "Rain::Env",
"!Rain::S3Http": "Rain::S3Http",
"!Rain::S3": "Rain::S3",
"!Rain::Module": "Rain::Module",
"!Rain::Constant": "Rain::Constant",
"!Invoke": "Fn::Invoke",
"!InsertFile": "Fn::InsertFile",
"!Merge": "Fn::Merge",
}
Tags is a mapping from YAML short tags to full instrincic function names
Functions ¶
func AppendStateMap ¶ added in v1.7.0
func AppendStateMap(state *Template) *yaml.Node
AppendStateMap appends a "State" section to the template
func IsRef ¶ added in v1.23.0
func IsRef(n *yaml.Node) bool
IsRef returns true if the node is a 2-length Mapping node that starts with "Ref"
func ReplaceIdentifier ¶ added in v1.23.0
ReplaceIdentifier replaces instance of the identifier in s for collection key k
Types ¶
type Comment ¶
type Comment struct { Path []interface{} Value string }
Comment represents a path to a node and a comment string to attach to it
type FnForEach ¶ added in v1.23.0
type FnForEach struct { LoopName string Identifier string Collection *yaml.Node OutputKey string OutputValue *yaml.Node }
func (*FnForEach) OutputKeyHasIdentifier ¶ added in v1.23.0
OutputKeyHasIdentifier returns true if the key uses the identifier
type ModuleConfig ¶ added in v1.22.0
type ModuleConfig struct { // Name is the name of the module, which is used as a logical id prefix Name string // Source is the URI for the module, a local file or remote URL Source string // PropertiesNode is the yaml node for the Properties PropertiesNode *yaml.Node // OverridesNode is the yaml node for overrides OverridesNode *yaml.Node // Node is the yaml node for the Module config mapping node Node *yaml.Node // Map is the node for mapping (duplicating) the module based on a CSV Map *yaml.Node // OriginalName is the Name of the module before it got Mapped (duplicated) OriginalName string // If this module was duplicated because of the Map attribute, store the index MapIndex int // If this module was duplicated because of the Map attribute, store the key MapKey string // IsMapCopy will be true if this instance was a duplicate of a Mapped module IsMapCopy bool // The root directory of the template that configures this module ParentRootDir string // If this module is wrapped in Fn::ForEach, this will be populated FnForEach *FnForEach }
ModuleConfig is the configuration of the module in the parent template.
func (*ModuleConfig) Overrides ¶ added in v1.22.0
func (c *ModuleConfig) Overrides() map[string]any
func (*ModuleConfig) Properties ¶ added in v1.22.0
func (c *ModuleConfig) Properties() map[string]any
func (*ModuleConfig) ResourceOverridesNode ¶ added in v1.22.0
func (c *ModuleConfig) ResourceOverridesNode(name string) *yaml.Node
ResourceOverridesNode returns the Overrides node for the given resource if it exists
type PackageAlias ¶ added in v1.20.0
type PackageAlias struct { // Alias is a simple string like "aws" Alias string // Location is the URI where the package is stored Location string // Hash is an optional hash for zipped packages hosted on a URL Hash string }
PackageAlias is an alias to a module package location A Rain package is a directory of modules, which are single yaml files. See the main README for more
type Section ¶ added in v1.8.0
type Section string
Section represents a top level section of a template, like Resources
const ( AWSTemplateFormatVersion Section = "AWSTemplateFormatVersion" Resources Section = "Resources" Description Section = "Description" Metadata Section = "Metadata" Parameters Section = "Parameters" Rules Section = "Rules" Mappings Section = "Mappings" Conditions Section = "Conditions" Transform Section = "Transform" Outputs Section = "Outputs" State Section = "State" Rain Section = "Rain" Modules Section = "Modules" Packages Section = "Packages" Constants Section = "Constants" )
type Template ¶
type Template struct { FileName string Name string Node *yaml.Node Constants map[string]*yaml.Node Packages map[string]*PackageAlias ModuleMapNames map[string][]string ModuleMaps map[string]*ModuleConfig ModuleOutputs map[string]*yaml.Node ModuleResolved []*yaml.Node }
Template represents a CloudFormation template. The Template type is minimal for now but will likely grow new features as needed by rain.
Node is the only member that is guaranteed to exist after parsing a template.
func (Template) AddComments ¶
AddComments applies a set of comments to the template
func (Template) AddMapSection ¶ added in v1.8.0
AddMapSection adds a section like Resources to the template
func (*Template) AddMappedModule ¶ added in v1.22.0
func (t *Template) AddMappedModule(copiedConfig *ModuleConfig)
AddMappedModule adds a reference to a module that was mapped to a CSV of keys, which duplicates the module in the template. We store a reference here so that we can resolve references like Content[0].Arn, which points to the first mapped instance of a Module called Content, with an Output called Arn.
func (*Template) AddResolvedModuleNode ¶ added in v1.22.0
func (t *Template) AddResolvedModuleNode(n *yaml.Node)
func (Template) AddScalarSection ¶ added in v1.8.0
AddScalarSection adds a section like Description to the template
func (Template) GetParameter ¶ added in v1.8.0
GetParameter returns the yaml node for a parameter by name
func (Template) GetResource ¶ added in v1.8.0
GetResource returns the yaml node for a resource by logical id
func (Template) GetResourcesOfType ¶ added in v1.9.0
func (Template) GetSection ¶ added in v1.8.0
GetSection returns the yaml node for the section
func (Template) GetTypes ¶ added in v1.8.0
GetTypes returns all unique type names for resources in the template
func (Template) HasSection ¶ added in v1.22.0
HasSection returns true if the template has the section
func (*Template) ModuleAlreadyResolved ¶ added in v1.22.0
func (*Template) ParseModuleConfig ¶ added in v1.22.0
func (t *Template) ParseModuleConfig( name string, n *yaml.Node) (*ModuleConfig, error)
parseModuleConfig parses a single module configuration from the Modules section in the template
func (Template) RemoveEmptySections ¶ added in v1.21.0
func (t Template) RemoveEmptySections()
RemoveEmptySections removes sections from the template that have no content
func (Template) RemoveSection ¶ added in v1.17.0
RemoveSection removes a section node from the template
Directories
¶
Path | Synopsis |
---|---|
Package diff provides the Diff class that can be used to compare CloudFormation templates
|
Package diff provides the Diff class that can be used to compare CloudFormation templates |
Package format contains functionality to render a cft.Template into YAML or JSON
|
Package format contains functionality to render a cft.Template into YAML or JSON |
Package graph provides functionality to build a graph of connected nodes with a cfn.Template
|
Package graph provides functionality to build a graph of connected nodes with a cfn.Template |
Package parse provides functions for parsing CloudFormation templates from JSON and YAML inputs.
|
Package parse provides functions for parsing CloudFormation templates from JSON and YAML inputs. |
ForEach (aka Map) processing for modules
|
ForEach (aka Map) processing for modules |