|
|
|
|
@ -25,6 +25,7 @@ const (
|
|
|
|
|
// for interpolations such as `aws_instance.foo.bar`.
|
|
|
|
|
type Interpolater struct {
|
|
|
|
|
Operation walkOperation
|
|
|
|
|
Meta *ContextMeta
|
|
|
|
|
Module *module.Tree
|
|
|
|
|
State *State
|
|
|
|
|
StateLock *sync.RWMutex
|
|
|
|
|
@ -87,6 +88,8 @@ func (i *Interpolater) Values(
|
|
|
|
|
err = i.valueSelfVar(scope, n, v, result)
|
|
|
|
|
case *config.SimpleVariable:
|
|
|
|
|
err = i.valueSimpleVar(scope, n, v, result)
|
|
|
|
|
case *config.TerraformVariable:
|
|
|
|
|
err = i.valueTerraformVar(scope, n, v, result)
|
|
|
|
|
case *config.UserVariable:
|
|
|
|
|
err = i.valueUserVar(scope, n, v, result)
|
|
|
|
|
default:
|
|
|
|
|
@ -309,6 +312,25 @@ func (i *Interpolater) valueSimpleVar(
|
|
|
|
|
n)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (i *Interpolater) valueTerraformVar(
|
|
|
|
|
scope *InterpolationScope,
|
|
|
|
|
n string,
|
|
|
|
|
v *config.TerraformVariable,
|
|
|
|
|
result map[string]ast.Variable) error {
|
|
|
|
|
if v.Field != "env" {
|
|
|
|
|
return fmt.Errorf(
|
|
|
|
|
"%s: only supported key for 'terraform.X' interpolations is 'env'", n)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if i.Meta == nil {
|
|
|
|
|
return fmt.Errorf(
|
|
|
|
|
"%s: internal error: nil Meta. Please report a bug.", n)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result[n] = ast.Variable{Type: ast.TypeString, Value: i.Meta.Env}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (i *Interpolater) valueUserVar(
|
|
|
|
|
scope *InterpolationScope,
|
|
|
|
|
n string,
|
|
|
|
|
|