Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions content/docs/iac/guides/basics/language-essentials/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,20 @@ for the decision itself, and
for the full walkthrough, including packaging it for other languages to
consume.

## Frequently asked questions

### Do I need to know object-oriented programming to use Pulumi?

No. Classes are entirely optional in Pulumi, and most day-to-day infrastructure code is plain functions and resource declarations. You only reach for a class when you want to package resources into a reusable, named component that other code can create and reference as a unit.

### What is a ComponentResource?

A `ComponentResource` is a resource that groups a set of child resources under one logical parent and exposes their combined outputs through a single interface, using `registerOutputs` (`RegisterOutputs` in C#). Consumers of the [component](/docs/iac/concepts/components/) interact with that simple interface instead of wiring up each child resource themselves.

### Can I use a component written in another language?

Yes, if it's packaged as a source-based package. Consumers run `pulumi package add` against its Git URL, and Pulumi generates an SDK in whichever language they're using, YAML included. A plain npm- or PyPI-style native language package, by contrast, only works in the language it was published for.

## Next steps

Continue to
Expand Down
14 changes: 14 additions & 0 deletions content/docs/iac/guides/basics/language-essentials/conditionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,20 @@ in an `if` statement; see
[working with outputs](/docs/iac/concepts/inputs-outputs/apply/) for how that
works.

## Frequently asked questions

### How do I make a resource conditional in Pulumi?

Wrap the resource declaration in a plain `if` statement in your programming language. There's no special conditional-resource construct to learn: the same branching you already use for any other decision in your code decides whether Pulumi sees the resource declaration at all, using ordinary values like [stack configuration](/docs/iac/concepts/config/).

### What replaces `count = 0` in Pulumi?

Nothing special is needed; an ordinary `if` statement takes its place. Because you're working with a real language rather than a declarative block, references to a conditionally created resource stay single values instead of becoming zero-or-one-element lists the way Terraform's `count` produces, which keeps the rest of your program simpler.

### Can I branch on a resource output?

No, not directly. A resource [output](/docs/iac/concepts/inputs-outputs/) isn't known while your program runs, so an `if` can only branch on values known at that time, such as the stack name, configuration, or plain inputs. If a decision genuinely depends on a value produced by another resource, make it inside an [`apply`](/docs/iac/concepts/inputs-outputs/apply/) callback instead of at the top level of your program.

## Next steps

Continue to [loops and iteration](/docs/iac/guides/basics/language-essentials/loops/)
Expand Down
14 changes: 14 additions & 0 deletions content/docs/iac/guides/basics/language-essentials/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ does, that's the signal to move to a class-based
[component](/docs/iac/guides/basics/language-essentials/classes/)
instead.

## Frequently asked questions

### When should I use a function instead of a component?

Reach for a plain function when you just want to group or parameterize a handful of resource declarations, and reach for a [component](/docs/iac/concepts/components/) once that group needs its own identity, combined outputs, or the ability to be referenced elsewhere in the program as a single unit. A function is the lighter-weight option; a component is the one that behaves like a resource itself.

### Are Pulumi functions the same as Terraform modules?

Not quite. The closest analogue to a Terraform module is a Pulumi component resource, which gets its own name, state entry, and combined outputs. A plain function in your programming language is a lighter-weight grouping mechanism with no state identity of its own; it just runs code and returns values.

### Can I pass a resource output into a function?

Yes. Accept it as an ordinary function parameter and pass it straight through to whatever resource properties need it. You don't need to unwrap an [output](/docs/iac/concepts/inputs-outputs/) before handing it to a function; Pulumi resolves it later, once its value is known.

## Next steps

Continue to
Expand Down
14 changes: 14 additions & 0 deletions content/docs/iac/guides/basics/language-essentials/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,20 @@ See [working with outputs](/docs/iac/concepts/inputs-outputs/apply/) and
[combining outputs](/docs/iac/concepts/inputs-outputs/all/) for the full
picture in every language.

## Frequently asked questions

### How do I replace `for_each` when I move from Terraform to Pulumi?

With a normal loop or comprehension over a list or map in your programming language. There's no separate meta-argument to learn: you iterate over the same data structure you'd use anywhere else in your code, and each iteration declares one resource.

### How do I keep resource names stable when I create resources in a loop?

Build each resource's logical name from a stable key drawn from your data, such as an item's identifier, rather than from the loop's iteration order or index. Pulumi tracks resources by their [logical name](/docs/iac/concepts/resources/names/), so changing that name causes Pulumi to replace the resource, and a name derived from iteration order shifts whenever the underlying list is reordered or resized.

### Can I loop over a resource output?

Not directly, since an [output](/docs/iac/concepts/inputs-outputs/) isn't a concrete value while your program runs. Call [`.apply()`](/docs/iac/concepts/inputs-outputs/apply/) on a single output, or [`pulumi.all([...])`](/docs/iac/concepts/inputs-outputs/all/) to combine several, and do the iteration inside the callback once the values are resolved.

## Next steps

Continue to [functions](/docs/iac/guides/basics/language-essentials/functions/) to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ your organization and shouldn't be public, Pulumi Cloud supports private
packages, so you get the same install-and-import experience internally
without publishing anything externally.

## Frequently asked questions

### Do I still need to run `pulumi plugin install`?

Usually not. The Pulumi CLI installs any missing provider plugins automatically the first time you run `pulumi preview` or `pulumi up` in a project. Manual installation is for cases like pre-fetching plugins in CI, working offline, or pinning a specific plugin version ahead of time; it isn't a step you need in ordinary day-to-day development.

### How do I add a Pulumi provider to my project?

Through your language's own package manager: `npm install @pulumi/aws` in TypeScript, `pip install pulumi-aws` in Python, a Go module dependency, `Pulumi.Aws` through NuGet, or `com.pulumi.aws` through Maven. You can also run `pulumi package add` to generate a local SDK directly from a plugin or schema, which is the same mechanism source-based component packages use.

### How do I share a component privately with my organization?

Publish it to the Pulumi Private Registry with `pulumi package publish` against a tagged Git repository. Teammates can then discover the package in the registry and generate an SDK for it in whichever language they're using, the same way they would consume any first-party provider.

## Next steps

Revisit the [series overview](/docs/iac/guides/basics/language-essentials/) or apply
Expand Down
14 changes: 14 additions & 0 deletions content/docs/iac/guides/basics/language-essentials/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,20 @@ works, and each language's interpolation helper, such as `pulumi.interpolate`
in TypeScript or `pulumi.Output.format()` in Python, for building strings out
of them.

## Frequently asked questions

### What replaces Terraform locals and variables in Pulumi?

An ordinary variable in your programming language plays the role Terraform's `locals` and `variable` blocks play. Per-stack inputs that used to live in a `variable` block instead come from [stack configuration](/docs/iac/concepts/config/), which you read at the top of your program and assign to a regular variable.

### Why doesn't string interpolation work on a resource output?

Because an output value isn't known while your program runs; it only resolves once the resource is created or updated. Standard string interpolation needs a value in hand immediately, so each language SDK provides an [output](/docs/iac/concepts/inputs-outputs/)-aware helper instead: `pulumi.interpolate` in TypeScript, `Output.format()` in Python and Java, `pulumi.Sprintf()` in Go, and `Output.Format()` in C#.

### Do I have to declare a type for every variable?

No. Type inference handles most cases, so you can assign a value and let the compiler work out its type. Declaring a type explicitly still pays off for public function signatures and component inputs, where it gives you IDE completion and catches mismatches at compile time rather than at deployment time.

## Next steps

Continue to [conditionals](/docs/iac/guides/basics/language-essentials/conditionals/)
Expand Down
Loading