Documentation
¶
Overview ¶
ForEach (aka Map) processing for modules
This file implements !Rain::Module
Package pkg provides functionality similar to the AWS CLI cloudformation package command but has greater flexibility, allowing content to be included anywhere in a template
To include content into your templates, use any of the following either as YAML tags or as one-property objects, much as AWS intrinsic functions are used, e.g. "Fn::Join"
`Rain::Include`: insert the content of the file into the template directly. The file must be in YAML or JSON format.
`Rain::Env`: inserts environmental variable value into the template as a string. Variable must be set.
`Rain::Embed`: insert the content of the file as a string
`Rain::S3Http`: uploads the file or directory (zipping it first) to S3 and returns the HTTP URI (i.e. `https://bucket.s3.region.amazonaws.com/key`)
`Rain::S3`: a string value uploads the file or directory (zipping it first) to S3 and returns the S3 URI (i.e. `s3://bucket/key`)
`Rain::S3`: an object with the following properties
`Path`: path to the file or directory. If a directory is supplied, it will be zipped before uploading to S3 `BucketProperty`: Name of returned property that will contain the bucket name `KeyProperty`: Name of returned property that will contain the object key `VersionProperty`: (optional) Name of returned property that will contain the object version
`Rain::Module`: Supply a URL to a rain module
The file has functions related to resolving refs in modules ¶
Package pkg provides functionality similar to the AWS CLI cloudformation package command but has greater flexibility, allowing content to be included anywhere in a template
To include content into your templates, use any of the following either as YAML tags or as one-property objects, much as AWS instrinsic functions are used, e.g. "Fn::Join"
`Rain::Include`: insert the content of the file into the template directly. The file must be in YAML or JSON format. `Rain::Env`: inserts environmental variable value into the template as a string. Variable must be set. `Rain::Embed`: insert the content of the file as a string `Rain::S3Http`: uploads the file or directory (zipping it first) to S3 and returns the HTTP URI (i.e. `https://bucket.s3.region.amazonaws.com/key`) `Rain::S3`: a string value uploads the file or directory (zipping it first) to S3 and returns the S3 URI (i.e. `s3://bucket/key`) `Rain::S3`: an object with the following properties
`Path`: path to the file or directory. If a directory is supplied, it will be zipped before uploading to S3 `BucketProperty`: Name of returned property that will contain the bucket name `KeyProperty`: Name of returned property that will contain the object key `VersionProperty`: (optional) Name of returned property that will contain the object version `Extension`: (optional) Extension appended to the end of the Object Key in S3
Index ¶
- Constants
- Variables
- func ConvertCsvToSequence(csv string) *yaml.Node
- func DownloadFromZip(uriString string, verifyHash string, path string) ([]byte, error)
- func ExtraIntrinsics(n *yaml.Node, basePath string) error
- func File(path string) (*cft.Template, error)
- func FnInsertFile(n *yaml.Node, basePath string) error
- func FnJoin(n *yaml.Node) error
- func FnMerge(n *yaml.Node) error
- func FnSelect(n *yaml.Node) error
- func ProcessOutputArrays(t *cft.Template) error
- func Template(t *cft.Template, rootDir string, fs *embed.FS) (*cft.Template, error)
- func Unzip(f *os.File, dest string) error
- type EvalResult
- type Module
- func (module *Module) CheckOutputGetAtt(s string, outputName string, outputVal any) (*yaml.Node, error)
- func (module *Module) Conditions() map[string]any
- func (module *Module) EvalAnd(n *yaml.Node) (EvalResult, error)
- func (module *Module) EvalCond(name string, val *yaml.Node) (EvalResult, error)
- func (module *Module) EvalEquals(n *yaml.Node) (EvalResult, error)
- func (module *Module) EvalNot(n *yaml.Node) (EvalResult, error)
- func (module *Module) EvalOr(n *yaml.Node) (EvalResult, error)
- func (module *Module) FnInvoke(n *yaml.Node) error
- func (module *Module) GetArrayIndexFromString(s string) (int, error)
- func (module *Module) InitNodes()
- func (module *Module) Modules() map[string]any
- func (module *Module) OutputGetAtt(outputName string, outputVal any, n *yaml.Node) error
- func (module *Module) OutputSub(outputName string, outputVal any, n *yaml.Node) error
- func (module *Module) Outputs() map[string]any
- func (module *Module) Parameters() map[string]any
- func (module *Module) ProcessConditions() error
- func (module *Module) ProcessFnIf(n *yaml.Node, unResolved []string) (bool, error)
- func (module *Module) ProcessOutputs() error
- func (module *Module) ProcessOverrides(resourceName string, resource *yaml.Node, clonedResource *yaml.Node) error
- func (module *Module) ProcessResources(outputNode *yaml.Node) error
- func (module *Module) Resolve(n *yaml.Node) error
- func (module *Module) ResolveGetAtt(n *yaml.Node) error
- func (module *Module) ResolveRef(n *yaml.Node) error
- func (module *Module) ResolveSub(n *yaml.Node) error
- func (module *Module) Resources() map[string]any
- func (module *Module) ValidateOverrides() error
- type ModuleContent
- type ParsedModule
Constants ¶
const ( MI = "$Index" MV = "$Identifier" )
const ( Metadata = "Metadata" IfParam = "IfParam" IfNotParam = "IfNotParam" Overrides = "Overrides" DependsOn = "DependsOn" Properties = "Properties" CreationPolicy = "CreationPolicy" UpdatePolicy = "UpdatePolicy" DeletionPolicy = "DeletionPolicy" UpdateReplacePolicy = "UpdateReplacePolicy" Condition = "Condition" Default = "Default" Source = "Source" ForEach = "ForEach" )
const ( Hash string = "Hash" Location string = "Location" )
const AWSToolsMetrics = "AWSToolsMetrics"
const Rain = "Rain"
Variables ¶
var Experimental bool
Experimental must be set to true to enable !Rain::Module
var HasModules bool
var HasRainSection bool
var NoAnalytics bool
Functions ¶
func ConvertCsvToSequence ¶ added in v1.4.4
Convert a comma delimted string to a sequence node
func DownloadFromZip ¶ added in v1.20.0
DownloadFromZip retrieves a single file from a zip file hosted on a URI
func File ¶
File opens path as a CloudFormation template and returns a cft.Template with assets included as per AWS CLI packaging rules and any Rain:: functions used
func FnInsertFile ¶ added in v1.22.0
FnInsertFile inserts the contents of a local file into the template
func FnMerge ¶ added in v1.22.0
FnMerge merges objects and lists together. The arguments must be fully resolvable client-side
func FnSelect ¶ added in v1.22.0
FnSelect reduces Fn::Select to a scalar if it can be fully resolved
func ProcessOutputArrays ¶ added in v1.22.0
After processing normal outputs, go back and look for array references like Content[].Arn. Values for these should be stored on the template.
Types ¶
type EvalResult ¶ added in v1.23.0
type EvalResult string
const ( Equals EvalResult = "==" NotEquals EvalResult = "!=" UnResolved EvalResult = "?" )
type Module ¶ added in v1.22.0
type Module struct {
Config *cft.ModuleConfig
ParametersNode *yaml.Node
ResourcesNode *yaml.Node
OutputsNode *yaml.Node
Node *yaml.Node
ParentTemplate *cft.Template
ConditionsNode *yaml.Node
ConditionValues map[string]bool
ModulesNode *yaml.Node
Parsed *ParsedModule
ParentModule *Module
}
Module represents a complete module, including parent config
func (*Module) CheckOutputGetAtt ¶ added in v1.22.0
func (module *Module) CheckOutputGetAtt(s string, outputName string, outputVal any) (*yaml.Node, error)
CheckOutputGetAtt checks to see if a GetAtt string matches an Output. Returns nil if it's not a match.
func (*Module) Conditions ¶ added in v1.22.0
Conditions returns the Conditions node as a map
func (*Module) EvalAnd ¶ added in v1.23.0
func (module *Module) EvalAnd(n *yaml.Node) (EvalResult, error)
EvalAnd evaluates an Fn::And condition
func (*Module) EvalCond ¶ added in v1.23.0
EvalCond evaluates a condition expression and returns its boolean value
func (*Module) EvalEquals ¶ added in v1.23.0
func (module *Module) EvalEquals(n *yaml.Node) (EvalResult, error)
EvalEquals evaluates an Fn::Equals condition
func (*Module) EvalNot ¶ added in v1.23.0
func (module *Module) EvalNot(n *yaml.Node) (EvalResult, error)
EvalNot evaluates an Fn::Not condition
func (*Module) EvalOr ¶ added in v1.23.0
func (module *Module) EvalOr(n *yaml.Node) (EvalResult, error)
EvalOr evaluates an Fn::Or condition
func (*Module) FnInvoke ¶ added in v1.22.0
FnInvoke allows treating a module like a function, returning its outputs with modified parameters
func (*Module) GetArrayIndexFromString ¶ added in v1.23.0
GetArrayIndexFromString extracts an integer array index from a string with embedded brackets. For example, from "Content[1].Arn" it would return 1. Returns an error if no valid index is found.
func (*Module) OutputGetAtt ¶ added in v1.22.0
A GetAtt to a module output. For example, !GetAtt A.B, where A is a module name, and B is a module output. B could be anything, a Scalar or an Object. It is also possible to reference module Maps (duplicate copies of a module), by using array brackets in the name, like A[0].B to reference a single instance of the module's Output, or A[].B, to get all module Outputs that have that name and return a Sequence with all of the Output values.
func (*Module) OutputSub ¶ added in v1.22.0
OutputSub checks a Sub to see if it refers to a module Output. A Sub string can refer to an output scalar value. The reference needs to be like a GetAtt. For example, !Sub ${A.B} refers to module A, output B.
func (*Module) Parameters ¶ added in v1.22.0
Parameters returns the Parameters node as a map
func (*Module) ProcessConditions ¶ added in v1.22.0
ProcessConditions evaluates conditions in the module and removes Modules and Resources that should be omitted by a Condition that evaluates to false. It then looks for Fn::If function calls that reference the condition and resolves them, removing false nodes.
func (*Module) ProcessFnIf ¶ added in v1.23.0
ProcessFnIf processes Fn::If functions in a node and its children Returns true if the node should be removed from its parent
func (*Module) ProcessOutputs ¶ added in v1.22.0
processModuleOutputs looks for any references in the parent template to the module's outputs and replaces them.
func (*Module) ProcessOverrides ¶ added in v1.22.0
func (module *Module) ProcessOverrides( resourceName string, resource *yaml.Node, clonedResource *yaml.Node) error
processOverrides copies module properties to the new node and checks to see if the template overrides anything
func (*Module) ProcessResources ¶ added in v1.22.0
ProcessResources injects the module's resources into the output node
func (*Module) Resolve ¶ added in v1.22.0
Resolve resolves Ref, Sub, and GetAtt in the node, using module config Properties, Parameter defaults, and other Resource names within the module.
func (*Module) ResolveGetAtt ¶ added in v1.22.0
func (*Module) ResolveSub ¶ added in v1.22.0
Resolve a Sub string in a module.
Sub strings can contain several types of variables. We leave intrinsics like ${AWS::Region} alone. ${Foo} is treated like a Ref to Foo ${Foo.Bar} is treated like a GetAtt.
func (*Module) ValidateOverrides ¶ added in v1.22.0
validateOverrides returns an error if one of the Overrides isn't found