pulumi/docs
Will Jones 996afa5388
Support parameterized mappings when converting code (#18671)
`pulumi convert` enables users to convert existing programs written in
other languages and tools, such as Terraform, to Pulumi programs which
manage the same infrastructure. In order to support Pulumi's wide array
of target languages and providers, and the possible multitude of source
programs (Terraform, CloudFormation, and so on), conversion is
architected as follows:

* When invoked through `pulumi convert`, the Pulumi CLI boots up a
*converter plugin* responsible for handling the source language. E.g. in
the case of converting `--from terraform`, the
`pulumi-converter-terraform` plugin will be run.

* Converter plugins implement a common gRPC service, which the CLI will
call to ask for a PCL (Pulumi configuration language; Pulumi's internal
representation) program based on the source.

* As part of producing the PCL program, the converter may ask the CLI to
*map* names from the source language (e.g. `aws_s3_bucket` in a
Terraform program) to equivalent Pulumi names (e.g.
`aws:s3/bucket:Bucket`).

* As is often the case, when it comes to mapping names, the CLI does not
do any work itself -- it instead brokers mapping requests to the set of
plugins installed. So in the above example, the CLI might find the
`pulumi-resource-aws` plugin and ask it to service the mapping request,
before returning to the converter plugin so it can continue to produce
PCL.

* When PCL is produced, the CLI can proceed with code generation
("Programgen"), driven by an appropriate language host and its
`GenerateProgram`/`GenerateProject` gRPC methods.

This changeset focuses on the ability for converter plugins to request
mappings from the CLI, specifically in the case of *parameterized
provider plugins*. A parameterized provider plugin is a plugin that can
be sent some data ("parameterization") before any of its other interface
methods (e.g. `GetSchema`, `Configure`, and in this case `GetMappings`
or `GetMapping`) are called. Parameterized providers underpin Pulumi's
"Any Terraform provider" features, in which Terraform providers are
dynamically bridged at runtime by the
`pulumi-resource-terraform-provider` plugin in response to a
parameterization request.

When a converter plugin requests mappings, it can offer a "hint" to the
CLI as to the plugin that it thinks will provide such a mapping. So e.g.
when the Terraform converter sees `aws_s3_bucket`, it will currently
send a hint `"aws"` to the CLI so that the CLI will search for (and
prioritise) asking a plugin named `aws` for its mappings (as opposed to
e.g. enumerating the random set of other plugins it might encounter
first). Here, we modify the `Mapper` interface so that hints can be full
package descriptors. In doing so, we will be able to modify the
converter to ask for the `terraform-provider` *plugin*, but with
*parameterization* that causes it to dynamically bridge a Terraform
provider such that it can return mappings for that provider. These
changes will be made to the `pulumi-converter-terraform` codebase
separately after this work is merged and released (the bridge may also
need to accommodate this change to the interface, but it should be
mechanical).

As part of this change, it should be noted that the way mappings are
*cached* has been changed. Prior to this work, we would aggressively
cache mappings, including those we retrieved "en route" to finding a
correct one. So, for instance, if we were asked for `"gcp"` mappings, in
the absence of a hint we might first ask for such mappings from the
`aws` and `azure` providers (say). Even though these mappings wouldn't
match, we'd cache them so that if someone later came to us asking for
`aws` mappings, we'd just return them from the cache instead of booting
up plugins and making gRPC calls. In the presence of parameterization,
it's not clear that being this aggressive is safe any more. There's no
guarantee, for instance, that a provider which has provided a set of
mappings will never later be able to provide a different set due to e.g.
a different parameterization. This change thus refactors the caching
behaviour to cache providers that have been requested (and succeeded),
but not to cache mappings "found along the way". Hopefully this should
still cover the majority of common cases without significant performance
costs (regression behaviour such as not double installing plugins should
be preserved, for instance).

Part of #18187
2025-02-21 15:02:08 +00:00
..
architecture document PULUMI_INTEGRATION_REBUILD_BINARIES (#18585) 2025-02-13 13:48:39 +00:00
contributing Update `mise` quickstart instructions (#18629) 2025-02-18 17:37:28 +00:00
debugging Add PULUMI_DEBUG_LANGUAGES support to go, python, and nodejs. (#17821) 2024-12-11 08:50:52 +00:00
documentation Add Mise to `pulumi/pulumi` (#18626) 2025-02-18 12:32:42 +00:00
references Clean up documentation to support the bridge (#17784) 2024-11-15 14:41:07 +00:00
sphinx Clean up documentation to support the bridge (#17784) 2024-11-15 14:41:07 +00:00
.gitignore Generate reference documentation from Protobufs (#17120) 2024-08-30 17:04:16 +00:00
Makefile Generate reference documentation from Protobufs (#17120) 2024-08-30 17:04:16 +00:00
README.md Add Mise to `pulumi/pulumi` (#18626) 2025-02-18 12:32:42 +00:00
diagrams.md Clean up documentation to support the bridge (#17784) 2024-11-15 14:41:07 +00:00
documentation.md Document developer documentation deployments (#17119) 2024-08-30 16:17:46 +00:00
make.py Support parameterized mappings when converting code (#18671) 2025-02-21 15:02:08 +00:00
requirements.txt Bump jinja2 from 3.1.4 to 3.1.5 in /docs in the pip group across 1 directory (#18110) 2024-12-24 22:23:20 +00:00
writing.md Explain how to contribute to dev docs (#17604) 2024-10-23 20:58:18 +00:00

README.md

Pulumi developer documentation

Welcome to the Pulumi developer documentation! This site is designed to provide complete documentation for maintainers of and contributors to Pulumi.

:::{toctree} :maxdepth: 2 :titlesonly:

Home /docs/contributing/README /docs/architecture/README /docs/references/README :::