Documentation ¶
Index ¶
- func DetectVariables(expr hcl.Expression) []hcl.Traversal
- type DynAccountAZs
- type DynBase64
- type DynEquals
- type DynExpr
- type DynGetAttr
- type DynIf
- type DynIndex
- type DynJoin
- type DynLiteral
- type DynLogical
- type DynLogicalOp
- type DynMappingLookup
- type DynNot
- type DynRef
- type DynSplit
- type EachState
- type FlatOutput
- type FlatParameter
- type FlatResource
- type FlatTemplate
- type ModuleContext
- func (mctx *ModuleContext) DetectVariables(expr hcl.Expression) []hcl.Traversal
- func (mctx *ModuleContext) EvalConstant(expr hcl.Expression, ty cty.Type, each EachState) (cty.Value, hcl.Diagnostics)
- func (mctx *ModuleContext) EvalDynamic(expr hcl.Expression, each EachState) (DynExpr, hcl.Diagnostics)
- func (mctx *ModuleContext) IsRootModule() bool
- func (mctx *ModuleContext) TypeCheck(expr hcl.Expression, each EachState) (cty.Type, hcl.Diagnostics)
- func (mctx *ModuleContext) VisitDownstreamModules(cb ModuleVisitor)
- func (mctx *ModuleContext) VisitModules(cb ModuleVisitor)
- type ModuleEach
- type ModuleVisitor
- type RootContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectVariables ¶
func DetectVariables(expr hcl.Expression) []hcl.Traversal
DetectVariables returns all of the traversals in the given expression that are not for named constants. The result is nil if there are no such traversals.
Types ¶
type DynAccountAZs ¶
type DynAccountAZs struct { // RegionName must be either a DynLiteral or a DynRef RegionName DynExpr SrcRange hcl.Range // contains filtered or unexported fields }
DynAccountAZs returns a list of availability zones that are supported in the region where the CloudFormation template is being applied, for the AWS account that is applying the template.
type DynBase64 ¶
type DynBase64 struct { String DynExpr SrcRange hcl.Range // contains filtered or unexported fields }
DynBase64 returns a base64-encoded version of a given string.
type DynEquals ¶
type DynEquals struct {
// A and B must both be either DynLiteral or DynRef.
A, B DynExpr
SrcRange hcl.Range
// contains filtered or unexported fields
}
DynEquals is a boolean expression (to be used in named conditionals only) that returns true if the two given values are equal.
type DynExpr ¶
type DynExpr interface {
// contains filtered or unexported methods
}
DynExpr represents an expression that can be evaluated dynamically by CloudFormation when applying a template.
This type represents the subset of operations that we can encode as expressions into CloudFormation JSON for dynamic evaluation. DynExpr instances are produced by translating hclsyntax.Expression nodes that have analogs in the CloudFormation language.
type DynGetAttr ¶
type DynGetAttr struct { LogicalID string Attrs []DynExpr SrcRange hcl.Range // contains filtered or unexported fields }
DynGetAttr represents an attribute exported by a particular resource.
type DynIf ¶
type DynIf struct { ConditionName string If, Else DynExpr SrcRange hcl.Range // contains filtered or unexported fields }
DynIf returns one of two values depending on the result of a named condition defined in the template.
type DynIndex ¶
type DynIndex struct { List DynExpr // Index may only be DynLiteral, DynRef or DynMappingLookup. Index DynExpr SrcRange hcl.Range // contains filtered or unexported fields }
DynIndex looks up a single item from a list expression by its index.
type DynJoin ¶
type DynJoin struct { Delimiter string Exprs []DynExpr SrcRange hcl.Range // contains filtered or unexported fields }
DynJoin joins several expressions together with a delimiter.
type DynLiteral ¶
type DynLiteral struct { Value cty.Value SrcRange hcl.Range // contains filtered or unexported fields }
DynLiteral represents a literal value within our dynamic expression intermediate language.
The name is of course a bit of a misnomer since a literal can't be dynamic, but this type allows dynamic expressions to make use of literals.
type DynLogical ¶
type DynLogical struct { Op DynLogicalOp Values []DynExpr SrcRange hcl.Range // contains filtered or unexported fields }
DynLogical is a boolean expression (to be used in named conditionals only) that performs the logical AND or OR operation on a number of other boolean expressions.
type DynLogicalOp ¶
type DynLogicalOp rune
const ( DynLogicalAnd DynLogicalOp = '&' DynLogicalOr DynLogicalOp = '|' )
func (DynLogicalOp) String ¶
func (i DynLogicalOp) String() string
type DynMappingLookup ¶
type DynMappingLookup struct { MappingName string // FirstKey and SecondKey may only use DynLiteral, DynRef, and nested DynMappingLookup. FirstKey, SecondKey DynExpr SrcRange hcl.Range // contains filtered or unexported fields }
DynMappingLookup looks up a value from a named mapping table defined within the template.
type DynNot ¶
DynNot is a boolean expression (to be used in named conditionals only) that returns the boolean inverse of another boolean expression.
type DynRef ¶
type DynRef struct { LogicalID string SrcRange hcl.Range // contains filtered or unexported fields }
DynRef represents the name or id returned by a particular reference or pseudo-reference in the CloudFormation language.
type DynSplit ¶
type DynSplit struct { Delimiter string String DynExpr SrcRange hcl.Range // contains filtered or unexported fields }
DynSplit splits a string by a given delimiter to produce a list.
type FlatOutput ¶
type FlatParameter ¶
type FlatResource ¶
type FlatTemplate ¶
type ModuleContext ¶
type ModuleContext struct { // Global is a reference to the RootContext that this context belongs to. Global *RootContext // Path is the absolute path of the module instance that this context // belongs to. This can be used as part of identifiers that need to be // globally-unique in the resulting flattened CloudFormation JSON. Path addr.ModulePath // Root is a reference to the ModuleContext for the root module. The // root ModuleContext points to itself. Root *ModuleContext // Parent is a reference to the ModuleContext for the parent module. // The root module has a nil Parent. Parent *ModuleContext // Children contains references to ModuleContexts for child modules, // keyed by the module name given in configuration. Since a single // Module block can fan out to many instances with ForEach, the children // are accessed through a ModuleEach. Children map[string]*ModuleEach // Config is the configuration for the module that this context // belongs to. A Config should not be modified once it is included // in a ModuleContext. Config *config.Module // Constants is a map of values of all of the named constants // for the module. Constants map[string]cty.Value }
func (*ModuleContext) DetectVariables ¶
func (mctx *ModuleContext) DetectVariables(expr hcl.Expression) []hcl.Traversal
DetectVariables is like the global function of the same name, except that it additionally follows references to locals and includes them only if they transitively refer to variables.
func (*ModuleContext) EvalConstant ¶
func (mctx *ModuleContext) EvalConstant(expr hcl.Expression, ty cty.Type, each EachState) (cty.Value, hcl.Diagnostics)
EvalConstant evaluates the given expression to produce a constant value, which is then converted to the requested type.
When evaluating in this mode, only constant values and named constants can be accessed. If any other scope traversals are detected then error diagnostics will be returned and the result will probably be a null value.
If EachState is set to anything other than NoEachState then the "Each" object is also available for use, exposing the values in the given EachState.
func (*ModuleContext) EvalDynamic ¶
func (mctx *ModuleContext) EvalDynamic(expr hcl.Expression, each EachState) (DynExpr, hcl.Diagnostics)
EvalDynamic evaluates the given expression to produce a DynExpr, which can then be serialized as a value in CloudFormation JSON.
If EachState is set to anything other than NoEachState then the "Each" object is also available for use, exposing the values in the given EachState.
func (*ModuleContext) IsRootModule ¶
func (mctx *ModuleContext) IsRootModule() bool
func (*ModuleContext) TypeCheck ¶
func (mctx *ModuleContext) TypeCheck(expr hcl.Expression, each EachState) (cty.Type, hcl.Diagnostics)
TypeCheck verifies the internal type consistency of the given expression and then, if successful, returns the expression's own result type.
TypeCheck relies on the type rules as defined by HCL and so does not enforce the additional constraints that apply when lowering to CloudFormation dynamic expressions using EvalDynamic, which arise from the limitations of the CloudFormation expression language.
The result may be cty.DynamicPseudoType if insufficient information is available to produce a result, which can occur if there are inconsistencies or errors elsewhere in the configuration. For best results, ensure that all of the referenceable configuration constructs are correct before type-checking references to them. For example, we assume that a prior check has detected resources with invalid type names and reported them, and so TypeCheck will treat these as being DynamicPseudoType.
If any type inconsistencies are found then they are returned as error diagnostics. The returned type is always valid, but may not be accurate in the precence of error diagnostics. cty.DynamicPseudoType is returned if errors prevent type resolution altogether.
func (*ModuleContext) VisitDownstreamModules ¶
func (mctx *ModuleContext) VisitDownstreamModules(cb ModuleVisitor)
func (*ModuleContext) VisitModules ¶
func (mctx *ModuleContext) VisitModules(cb ModuleVisitor)
type ModuleEach ¶
type ModuleEach struct { // EachType is the type of index being used for ForEach on this collection // of module instances, or addr.NoEach if ForEach is not in use. EachType addr.EachType // Modules contains a reference to the ModuleContext for each known index. // If not in ForEach mode, this map contains only a single member whose // key is addr.NoEachIndex. // // To iterate over all module instances, use the values of this map // and disregard the keys. Modules map[addr.EachIndex]*ModuleContext }
ModuleEach represents either a single child ModuleContext or the multiple indexed ModuleContexts created when ForEach is used in a module block.
Use IsForEach to determine whether ForEach mode is in use, since this dictates which methods may be used on a particular instance.
func (*ModuleEach) Index ¶
func (e *ModuleEach) Index(key addr.EachIndex) *ModuleContext
func (*ModuleEach) Single ¶
func (e *ModuleEach) Single() *ModuleContext
type ModuleVisitor ¶
type ModuleVisitor func(*ModuleContext) bool
type RootContext ¶
type RootContext struct { // RootModule is a reference to the ModuleContext for the root module. RootModule *ModuleContext // Schema is a representation of the resource type schema provided by // AWS to describe the available resource types and their properties and // attributes. Schema *schema.Schema }
func NewRootContext ¶
func NewRootContext(parser *config.Parser, rootPath string, constants hcl.Attributes, sch *schema.Schema) (*RootContext, hcl.Diagnostics)
NewRootContext creates a RootContext by loading a module configuration from the given path (which may be either a directory containing .awsup files or a single .awsup file) and then loading the tree of descendent modules referenced by the root by following Source values given in Module blocks.
If the returned hcl.Diagnostics contains errors then the returned context may not be complete, but is still returned to allow for cautious use by analysis use-cases such as text editor integrations.
func (*RootContext) Build ¶
func (ctx *RootContext) Build() (*FlatTemplate, hcl.Diagnostics)
func (*RootContext) VisitModules ¶
func (ctx *RootContext) VisitModules(cb ModuleVisitor)