package
3.153.1
Repository: https://github.com/pulumi/pulumi.git
Documentation: pkg.go.dev

# README

(pcl)=

Pulumi Configuration Language (PCL)

Pulumi Configuration Language (PCL) is an internal representation of Pulumi programs which supports all core concepts of the Pulumi programming model in a minimal form. Although not exposed directly to users today, this intermediate representation is used to support a variety of program conversion tasks, from and to various supported Pulumi languages.

Pulumi supports a number of operations pertaining to PCL programs:

  • Lexing and parsing, in which PCL source is parsed into an abstract syntax tree (AST).

  • Type checking and binding, in which a PCL AST is verified to be well-formed (describing resources, outputs, and so on), associated with ("bound to") a set of Pulumi schema, and type checked and resolved.

  • Code generation ("programgen"), in which a PCL program is converted into a program written in a supported target language. Much of this underpins the core of tools such as pulumi convert.

(pcl-program)=

PCL programs

PCL programs are comprised of PCL source files which typically have the suffix .pp. This repository contains a large number of examples -- in particular, a large amount of PCL is used to drive language conformance tests. PCL programs support the following concepts:

(pcl-resource)=

Resources

Resources are defined as blocks of type resource. They correspond to stack resource registrations (see resource registration and for more). A resource block must have exactly two labels -- the first is the resource's name, to be used both as a reference to it elsewhere in the program and as its name in the resulting Pulumi stack (see the sections in this documentation on URNs and resource registration). The resource's body contains a set of attributes, which correspond to the resource's input properties. An optional options block may be used to specify resource options (e.g. provider, protect, ignoreChanges, etc.).

resource "r" "pkg:index:Resource" {
    name = "r"

    options {
        protect = true
    }
}

(pcl-component)=

Components

A component in the context of a PCL program is equivalent to the notion of a "local" component resource in a Pulumi program. Components are defined as blocks of type component. A component block must have two labels. The first is the component's name, to be used both as a reference to it elsewhere in the program and as its name in the resulting Pulumi stack. The second is a path to a directory containing a PCL program (set of .pp files) that defines the component's implementation. The component's body contains a set of attributes, which correspond to the component's input properties. An optional options block may be used to specify component options (e.g. provider, protect, etc.).

component "c" "./c" {
    name = "c"
    value = 42
}

Program generation for components results in e.g. the generation of local component types, such as those extending the ComponentResource class in SDKs exposing that type.

(pcl-output)=

Outputs

Outputs are defined as blocks of type output. They correspond exactly to exported stack outputs, such as pulumi.export in Python or ctx.Export in Go, which correspond to on the stack resource under the hood. Output blocks must have exactly one label, which is the output's name. The output's body must contain a single attribute, value, which is the output's value.

resource "r" "pkg:index:Resource" {
    name = "r"
}

output "o" {
    value = r.name
}

(pcl-config)=

Configuration

Configuration variables define the names and schema of values that are expected to be supplied to a program through Pulumi configuration (e.g. from a Pulumi.<stack>.yaml). They are defined as blocks of type config, with each block taking labels for the variable's name and type. The block's body may be used to specify other aspects of the variable, such as a description and default value. config blocks are typically used to generate program code for referring to Pulumi configuration, e.g. by creating and using a pulumi.Config() object in NodeJS.

config "key" "string" {
  description = "The key to use when encrypting data"
  default     = ""
}

(pcl-invoke)=

invoke

The invoke intrinsic is used to express provider function calls and corresponds to the 's method.

result1 = invoke("pkg:index:Function", { x = 3, y = 4 })

result2 = invoke("pkg:index:Function", { z = 5 }, { parent = p })

(pcl-call)=

call

The call intrinsic is used to express a method invocation on a resource and corresponds to the 's method.

resource "c" "pkg:index:Component" {
    ...
}

result = call(c, "method", { x = 3, y = 4 })

(pcl-builtin-function)=

Built-in functions

PCL offers a number of built-in functions for use in expressions. These are captured by the pulumiBuiltins function in .

:::{toctree} :maxdepth: 1 :titlesonly:

Syntax and type checking </pkg/codegen/hcl2/README> Binding </pkg/codegen/pcl/binding> :::

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Used by language plugins to bind a PCL program in the given directory.
BindProgram performs semantic analysis on the given set of HCL2 files that represent a single program.
No description provided by the author
No description provided by the author
ComponentProgramBinderFromFileSystem returns the default component program binder which uses the file system to parse and bind PCL files into a program.
No description provided by the author
No description provided by the author
EnumMember returns the name of the member that matches the given `value`.
No description provided by the author
No description provided by the author
GenEnum is a helper function when generating an enum.
GenerateMultiArguments takes the input bag (object) of a function invoke and spreads the values of that object into multi-argument function call.
GetDiscriminatedUnionObjectMapping calculates a map of type names to object types for a given union type.
GetSchemaForType extracts the schema.Type associated with a model.Type, if any.
No description provided by the author
inferVariableName infers a variable name from the given traversal expression.
Detects invoke calls that use an output version of a function.
Linearize performs a topological sort of the nodes in the program so that they can be processed by tools that need to see all of a node's dependencies before the node itself (e.g.
LiteralValueString evaluates the given expression and returns the string value if it is a literal value expression otherwise returns an empty string for anything else.
No description provided by the author
Lookup a PCL invoke token in a schema.
Lookup a PCL resource token in a schema.
LowerConversion lowers a conversion for a specific value, such that converting `from` to a value of the returned type will produce valid code.
Remaps the "pulumi:providers:$Package" token style to "$Package:index:Provider", consistent with code generation.
NewApplyCall returns a new expression that represents a call to IntrinsicApply.
NewConvertCall returns a new expression that represents a call to IntrinsicConvert.
No description provided by the author
NonStrictBindOptions returns a set of bind options that make the binder lenient about type checking.
ParseApplyCall extracts the apply arguments and the continuation from a call to the apply intrinsic.
ParseConvertCall extracts the value being converted and the type it is being converted to from a call to the convert intrinsic.
/ ParseDirectory parses all of the PCL files in the given directory into the state of the parser.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ReadPackageDescriptors reads the package blocks in the given file and returns a map of package names to the package.
Pattern matches to recognize an encoded call to an output-versioned invoke, such as `invoke(token, __convert(objCons(..)))`.
Pattern matches to recognize `__convert(objCons(..))` pattern that is used to annotate object constructors with appropriate nominal types.
RewriteApplies transforms all expressions that observe the resolved values of outputs and promises into calls to the __apply intrinsic.
No description provided by the author
RewriteConversions wraps automatic conversions indicated by the HCL2 spec and conversions to schema-annotated types in calls to the __convert intrinsic.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SortedFunctionParameters returns a list of properties of the input type from the schema for an invoke function call which has multi argument inputs.
No description provided by the author
No description provided by the author
UnwrapOption returns type T if the input is an Option(T).
VariableAccessed returns whether the given variable name is accessed in the given expression.

# Constants

Call is the name of the PCL `call` intrinsic, which can be used to invoke methods on resources.
IntrinsicApply is the name of the apply intrinsic.
IntrinsicConvert is the name of the conversion intrinsic.
Invoke is the name of the PCL `invoke` intrinsic, which can be used to invoke provider functions.
No description provided by the author

# Variables

ArchiveType represents the set of Pulumi Archive values.
AssetOrArchiveType represents the set of Pulumi Archive values.
AssetType represents the set of Pulumi Asset values.
ResourcePropertyType represents a resource property reference.

# Structs

Component represents a component reference in a program.
No description provided by the author
ConfigVariable represents a program- or component-scoped input variable.
No description provided by the author
LocalVariable represents a program- or component-scoped local variable.
OutputVariable represents a program- or component-scoped output variable.
No description provided by the author
No description provided by the author
Program represents a semantically-analyzed Pulumi HCL2 program.
Resource represents a resource instantiation inside of a program or component.
ResourceAnnotation is a type that can be used to annotate ObjectTypes that represent resources with their corresponding Resource node.
ResourceOptions represents a resource instantiation's options.
ResourceProperty represents a resource property.

# Interfaces

No description provided by the author
Node represents a single definition in a program or component.

# Type aliases

No description provided by the author
No description provided by the author