tfbridge

package
v3.83.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 59 Imported by: 607

Documentation

Index

Constants

View Source
const (
	// FileAsset turns the asset into a file on disk and passes the filename in its place.
	FileAsset = info.FileAsset
	// BytesAsset turns the asset into a []byte and passes it directly in-memory.
	BytesAsset = info.BytesAsset
	// FileArchive turns the archive into a file on disk and passes the filename in its place.
	FileArchive = info.FileArchive
	// BytesArchive turns the asset into a []byte and passes that directly in-memory.
	BytesArchive = info.BytesArchive
)
View Source
const (
	MPL20LicenseType      = info.MPL20LicenseType
	MITLicenseType        = info.MITLicenseType
	Apache20LicenseType   = info.Apache20LicenseType
	UnlicensedLicenseType = info.UnlicensedLicenseType
)
View Source
const RenamedEntitySuffix = info.RenamedEntitySuffix
View Source
const TerraformUnknownVariableValue = "74D93920-ED26-11E3-AC10-0800200C9A66"

TerraformUnknownVariableValue is the sentinal defined in github.com/hashicorp/terraform/configs/hcl2shim, representing a variable whose value is not known at some particular time. The value is duplicated here in order to prevent an additional dependency - it is unlikely to ever change upstream since that would break rather a lot of things.

Variables

View Source
var ErrSchemaDefaultValue = fmt.Errorf("default values not supported")

ErrSchemaDefaultValue is used internally to avoid a panic in pf/schemashim.DefaultValue(). See https://github.com/pulumi/pulumi-terraform-bridge/issues/1329

View Source
var ManagedByPulumi = &DefaultInfo{Value: "Managed by Pulumi"}

ManagedByPulumi is a default used for some managed resources, in the absence of something more meaningful.

Functions

func ApplyAutoAliases added in v3.81.0

func ApplyAutoAliases(info *ProviderInfo) error

Automatically applies backwards compatibility best practices.

Specifically, ApplyAutoAliases may perform the following actions:

- Call [ProviderInfo.RenameResourceWithAlias] or [ProviderInfo.RenameDataSource] - Edit [ResourceInfo.Aliases] - Edit [SchemaInfo.MaxItemsOne]

The goal is to always maximize backwards compatibility and reduce breaking changes for the users of the Pulumi providers.

Resource aliases help mask TF provider resource renames or changes in mapped tokens so older programs continue to work. See [ResourceInfo.RenameResourceWithAlias] and [ResourceInfo.Aliases] for more details.

[SchemaInfo.MaxItemsOne] changes are also important because they involve flattening and pluralizing names. Collections (lists or sets) marked with MaxItems=1 are projected as scalar types in Pulumi SDKs. Therefore changes to the MaxItems property may be breaking the compilation of programs as the type changes from `T to List[T]` or vice versa. To avoid these breaking changes, this method undoes any upstream changes to MaxItems using [SchemaInfo.MaxItemsOne] overrides. This happens until a major version change is detected, and then overrides are cleared. Effectively this makes sure that upstream MaxItems changes are deferred until the next major version.

func BoolRef added in v3.12.0

func BoolRef(b bool) *bool

BoolRef returns a reference to the bool argument.

func CoerceTerraformString

func CoerceTerraformString(schType shim.ValueType, ps *SchemaInfo, stringValue string) (interface{}, error)

CoerceTerraformString coerces a string value to a Go value whose type is the type requested by the Terraform schema type or the Pulumi SchemaInfo. We prefer the SchemaInfo overrides as it's an explicit call to action over the Terraform Schema. Returns an error if the string can't be successfully coerced to the requested type.

func ComputeAutoNameDefault added in v3.56.0

func ComputeAutoNameDefault(
	ctx context.Context,
	options AutoNameOptions,
	defaultOptions ComputeDefaultOptions,
) (interface{}, error)

func ConfigArrayValue added in v3.30.1

func ConfigArrayValue(vars resource.PropertyMap, prop resource.PropertyKey, envs []string) []string

ConfigArrayValue takes an array value from a property map, then from environment vars; defaults to an empty array

func ConfigBoolValue added in v3.30.1

func ConfigBoolValue(vars resource.PropertyMap, prop resource.PropertyKey, envs []string) bool

ConfigBoolValue takes a bool value from a property map, then from environment vars; defaults to false

func ConfigStringValue added in v3.30.1

func ConfigStringValue(vars resource.PropertyMap, prop resource.PropertyKey, envs []string) string

ConfigStringValue gets a string value from a property map, then from environment vars; defaults to empty string ""

func DiffConfig added in v3.75.0

func DiffConfig(
	config shim.SchemaMap, configInfos map[string]*SchemaInfo,
) func(
	urn resource.URN, oldInputs, oldOutputs, newInputs resource.PropertyMap,
	allowUnknowns bool, ignoreChanges []string,
) (plugin.DiffResult, error)

Re-exported to reuse for Plugin Framework based providers.

func ExtractInputsFromOutputs added in v3.43.0

func ExtractInputsFromOutputs(oldInputs, outs resource.PropertyMap,
	tfs shim.SchemaMap, ps map[string]*SchemaInfo, isRefresh bool) (resource.PropertyMap, error)

func False

func False() *bool

False is used for interactions in the providers that require a pointer to false

func FromName

func FromName(options AutoNameOptions) func(res *PulumiResource) (interface{}, error)

FromName automatically propagates a resource's URN onto the resulting default info.

func GetModuleMajorVersion

func GetModuleMajorVersion(version string) string

Calculates the major version of a go sdk go module paths only care about appending a version when the version is 2 or greater. github.com/org/my-repo/sdk/v1/go is not a valid go module path but github.com/org/my-repo/sdk/v2/go is

func GetUrn added in v3.81.0

func GetUrn(ctx context.Context) resource.URN

GetUrn gets a resource URN from context.

urn := GetUrn(ctx)

GetUrn is available on any context associated with a resource. Calling GetUrn on a context associated with an Invoke will panic.

func IsMaxItemsOne

func IsMaxItemsOne(tfs shim.Schema, info *SchemaInfo) bool

IsMaxItemsOne returns true if the schema/info pair represents a TypeList or TypeSet which should project as a scalar, else returns false.

func Main

func Main(pkg string, version string, prov ProviderInfo, pulumiSchema []byte)

Main launches the tfbridge plugin for a given package pkg and provider prov.

func MakeDataSource added in v3.12.0

func MakeDataSource(pkg string, mod string, name string) tokens.ModuleMember

MakeDataSource manufactures a standard Pulumi function token given a package, module, and data source name. It automatically uses the main package and names the file by simply lower casing the data source's first character.

Invalid inputs panic.

func MakeMember deprecated added in v3.12.0

func MakeMember(pkg string, mod string, mem string) tokens.ModuleMember

MakeMember manufactures a type token for the package and the given module and type.

Deprecated: Use MakeResource or call into the `tokens` module in "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" directly.

func MakeResource added in v3.12.0

func MakeResource(pkg string, mod string, res string) tokens.Type

MakeResource manufactures a standard resource token given a package, module and resource name. It automatically uses the main package and names the file by simply lower casing the resource's first character.

Invalid inputs panic.

func MakeTerraformConfigFromInputs

func MakeTerraformConfigFromInputs(
	ctx context.Context, p shim.Provider, inputs map[string]interface{},
) shim.ResourceConfig

MakeTerraformConfigFromInputs creates a new Terraform configuration object from a set of Terraform inputs.

func MakeTerraformOutput

func MakeTerraformOutput(
	ctx context.Context,
	p shim.Provider,
	v interface{},
	tfs shim.Schema,
	ps *SchemaInfo,
	assets AssetTable,
	supportsSecrets bool,
) resource.PropertyValue

MakeTerraformOutput takes a single Terraform property and returns the Pulumi equivalent.

func MakeTerraformOutputs

func MakeTerraformOutputs(
	ctx context.Context,
	p shim.Provider,
	outs map[string]interface{},
	tfs shim.SchemaMap,
	ps map[string]*SchemaInfo,
	assets AssetTable,
	supportsSecrets bool,
) resource.PropertyMap

MakeTerraformOutputs takes an expanded Terraform property map and returns a Pulumi equivalent. This respects the property maps so that results end up with their correct Pulumi names when shipping back to the engine.

func MakeTerraformResult

func MakeTerraformResult(
	ctx context.Context,
	p shim.Provider,
	state shim.InstanceState,
	tfs shim.SchemaMap,
	ps map[string]*SchemaInfo,
	assets AssetTable,
	supportsSecrets bool,
) (resource.PropertyMap, error)

MakeTerraformResult expands a Terraform state into an expanded Pulumi resource property map. This respects the property maps so that results end up with their correct Pulumi names when shipping back to the engine.

func MakeTerraformState

func MakeTerraformState(
	ctx context.Context, res Resource, id string, m resource.PropertyMap,
) (shim.InstanceState, error)

MakeTerraformState converts a Pulumi property bag into its Terraform equivalent. This requires flattening everything and serializing individual properties as strings. This is a little awkward, but it's how Terraform represents resource properties (schemas are simply sugar on top).

func MakeType deprecated added in v3.12.0

func MakeType(pkg string, mod string, typ string) tokens.Type

MakeType manufactures a type token for the package and the given module and type.

Deprecated: Use MakeResource or call into the `tokens` module in "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" directly.

func MarkSchemaSecrets added in v3.47.0

func MarkSchemaSecrets(ctx context.Context, schemaMap shim.SchemaMap, configInfos map[string]*SchemaInfo,
	pv resource.PropertyValue) resource.PropertyValue

Ensures resource.MakeSecret is used to wrap any nested values that correspond to secret properties in the schema. A property is considered secret if it is declared Sensitive in the SchemaMap in the upstream provider. Users may also override a matching SchemaInfo.Secret setting to force a property to be considered secret or non-secret.

func MustTraverseProperties added in v3.81.0

func MustTraverseProperties(
	prov *ProviderInfo, traversalID string, visitor PropertyVisitor,
	opts ...TraversalOption)

A wrapper around TraverseProperties that panics on error. See TraverseProperties for documentation.

func NewCheckFailure added in v3.49.0

func NewCheckFailure(
	reasonType CheckFailureReason,
	reason string,
	pp *CheckFailurePath,
	urn resource.URN,
	isProvider bool,
	configPrefix string,
	schemaMap shim.SchemaMap,
	schemaInfos map[string]*SchemaInfo,
) plugin.CheckFailure

Formats a CheckFailure to report an issue with a resource or provider configuration. This method is made public to facilitate cross-package use by the bridge framework and is not intended for use by provider authors.

func NewProvider

func NewProvider(ctx context.Context, host *provider.HostClient, module, version string,
	tf shim.Provider, info ProviderInfo, pulumiSchema []byte,
) pulumirpc.ResourceProviderServer

NewProvider creates a new Pulumi RPC server wired up to the given host and wrapping the given Terraform provider.

func PulumiToTerraformName

func PulumiToTerraformName(name string, tfs shim.SchemaMap, ps map[string]*SchemaInfo) string

PulumiToTerraformName performs a standard transformation on the given name string, from Pulumi's PascalCasing or camelCasing, to Terraform's underscore_casing.

func ReplaceConfigProperties added in v3.66.0

func ReplaceConfigProperties(msg string, config map[string]*SchemaInfo, schema shim.SchemaMap) (string, error)

ReplaceConfigProperties replaces all Terraform config property names in the given message with their Pulumi equivalents. This method is made public to facilitate cross-package use by the bridge framework and is not intended for use by provider authors. This only works for top-level properties currently. TODO https://github.com/pulumi/pulumi-terraform-bridge/issues/1533

func SchemaPathToPropertyPath added in v3.70.0

func SchemaPathToPropertyPath(
	schemaPath SchemaPath,
	schemaMap shim.SchemaMap,
	schemaInfos map[string]*SchemaInfo) resource.PropertyPath

Translate a a bridged provider schema path into a Pulumi property path.

The function hides the complexity of mapping Terraform names to Pulumi property names, joining Schema with user overrides in [SchemaInfo]s, and accounting for MaxItems=1 situations where Pulumi flattens collections to plain values.

SchemaPathToPropertyPath may return nil if there is no matching schema found. This may happen when drilling down to values of unknown type, attributes not tracked in schema, or when there is a type mismatch between the path and the schema.

## Element handling

[SchemaPath]s can be either attributes or existential elements. .Element() segments are existential because they represent some element access, but not a specific element access. For example:

NewSchemaPath().GetAttr("x").Element().GetAttr("y")

[resource.PropertyPath]s have attributes or instantiated elements. Elements are instantiated because they represent a specific element access. For example:

x[3].y

SchemaPathToPropertyPath translates all existential elements into the "*" (_universal_) element. For example:

NewSchemaPath().GetAttr("x").Element().GetAttr("y") => x["*"].y

This is information preserving, but "*"s are not usable in all functions that accept resource.PropertyPath.

func Serve

func Serve(module, version string, info ProviderInfo, pulumiSchema []byte) error

Serve fires up a Pulumi resource provider listening to inbound gRPC traffic, and translates calls from Pulumi into actions against the provided Terraform Provider.

func StringValue added in v3.12.0

func StringValue(vars resource.PropertyMap, prop resource.PropertyKey) string

StringValue gets a string value from a property map if present, else ""

func TerraformToPulumiName deprecated

func TerraformToPulumiName(name string, sch shim.Schema, ps *SchemaInfo, upper bool) string

TerraformToPulumiName performs a standard transformation on the given name string, from Terraform's underscore_casing to Pulumi's PascalCasing (if upper is true) or camelCasing (if upper is false).

Deprecated: Convert to TerraformToPulumiNameV2, see comment for conversion instructions.

TerraformToPulumiNameV2 includes enough information for a bijective mapping between Terraform attributes and Pulumi properties. If the full naming context cannot be acquired, you can construct a partial naming context:

TerraformToPulumiNameV2(name,
	schema.SchemaMap(map[string]shim.Schema{name: sch}),
	map[string]*SchemaInfo{name: ps})

If the previous (non-invertable) camel casing is necessary, it must be implemented manually:

name := TerraformToPulumiNameV2(key, sch, ps)
name = strings(uniode.ToUpper(rune(name[0]))) + name[1:]

func TerraformToPulumiNameAtPath added in v3.48.0

func TerraformToPulumiNameAtPath(
	path walk.SchemaPath,
	sch shim.SchemaMap,
	ps map[string]*SchemaInfo,
) (string, error)

A helper method to perform TerraformToPulumiNameV2 translation at nested property positions easily. The path argument specifies the nested location of the current property within the schema; sch and ps arguments specify top-level resource, data source or provider SchemaMap and field SchemaInfo overrides. This method automatically finds the approproate nested SchemaMap and field overrides for the property and performs the name translation.

func TerraformToPulumiNameV2 added in v3.39.2

func TerraformToPulumiNameV2(name string, sch shim.SchemaMap, ps map[string]*SchemaInfo) string

TerraformToPulumiNameV2 performs a standard transformation on the given name string, from Terraform's underscore_casing to Pulumi's camelCasing.

func TransformJSONDocument

func TransformJSONDocument(v resource.PropertyValue) (resource.PropertyValue, error)

TransformJSONDocument permits either a string, which is presumed to represent an already-stringified JSON document, or a map/array, which will be transformed into its JSON representation.

func TraverseProperties added in v3.81.0

func TraverseProperties(
	prov *ProviderInfo, traversalID string, visitor PropertyVisitor,
	opts ...TraversalOption,
) error

_Efficiently_ traverse all property fields in a provider.

Each property is rooted in a resource, data source or provider config. Roots themselves are not visited, only properties.

TraverseProperties operates in two stages:

  • During `make tfgen` time, all fields in the provider are visited. TraverseProperties builds a list of fields where `VisitResult{ HasEffect: true }` is returned.

  • During the provider's normal runtime, only "effectful" fields are visited.

traversalId must be unique for each traversal within a `make tfgen`, but the same between `make tfgen` and the provider runtime. A simple descriptive string like `"apply labels"` works great here.

func True

func True() *bool

True is used for interactions in the providers that require a pointer to true

func UnmarshalTerraformState

func UnmarshalTerraformState(
	ctx context.Context, r Resource, id string, m *pbstruct.Struct, l string,
) (shim.InstanceState, error)

UnmarshalTerraformState unmarshals a Terraform instance state from an RPC property map.

func XWithUrn added in v3.81.0

func XWithUrn(ctx context.Context, urn resource.URN) context.Context

XWithUrn returns a copy of ctx with the resource URN value.

XWithUrn is unstable and may be changed or removed in any release.

Types

type AliasInfo

type AliasInfo = info.Alias

AliasInfo is a partial description of prior named used for a resource. It can be processed in the context of a resource creation to determine what the full aliased URN would be.

It can be used by Pulumi resource providers to change the aspects of it (i.e. what module it is contained in), without causing resources to be recreated for customers who migrate from the original resource to the current resource.

type AssetTable

type AssetTable map[*SchemaInfo]resource.PropertyValue

AssetTable is used to record which properties in a call to MakeTerraformInputs were assets so that they can be marshaled back to assets by MakeTerraformOutputs.

func MakeTerraformConfig

func MakeTerraformConfig(ctx context.Context, p *Provider, m resource.PropertyMap,
	tfs shim.SchemaMap, ps map[string]*SchemaInfo) (shim.ResourceConfig, AssetTable, error)

MakeTerraformConfig creates a Terraform config map, used in state and diff calculations, from a Pulumi property map.

func MakeTerraformInputs

func MakeTerraformInputs(
	ctx context.Context, instance *PulumiResource, config resource.PropertyMap,
	olds, news resource.PropertyMap, tfs shim.SchemaMap, ps map[string]*SchemaInfo,
) (map[string]interface{}, AssetTable, error)

func UnmarshalTerraformConfig

func UnmarshalTerraformConfig(ctx context.Context, p *Provider, m *pbstruct.Struct,
	tfs shim.SchemaMap, ps map[string]*SchemaInfo,
	label string) (shim.ResourceConfig, AssetTable, error)

UnmarshalTerraformConfig creates a Terraform config map from a Pulumi RPC property map. Unused internally.

type AssetTranslation

type AssetTranslation = info.AssetTranslation

AssetTranslation instructs the bridge how to translate assets into something Terraform can use.

type AssetTranslationKind

type AssetTranslationKind = info.AssetTranslationKind

AssetTranslationKind may be used to choose from various source and dest translation targets.

type AutoNameOptions

type AutoNameOptions = info.AutoNameOptions

AutoNameOptions provides parameters to AutoName to control how names will be generated

type CSharpInfo

type CSharpInfo = info.CSharp

CSharpInfo contains optional overlay information for C# code-generation.

type CheckFailureError added in v3.72.0

type CheckFailureError struct {
	Failures []CheckFailureErrorElement
}

CheckFailureError can be returned from a PreConfigureCallback to indicate that the configuration is invalid along with an actionable error message. These will be returned as failures in the CheckConfig response instead of errors.

func (CheckFailureError) Error added in v3.72.0

func (e CheckFailureError) Error() string

type CheckFailureErrorElement added in v3.72.0

type CheckFailureErrorElement struct {
	Reason   string
	Property string
}

type CheckFailurePath added in v3.49.0

type CheckFailurePath struct {
	// contains filtered or unexported fields
}

Identifies a path to the property that is failing checks. See NewCheckFailure.

func NewCheckFailurePath added in v3.49.0

func NewCheckFailurePath(
	schemaMap shim.SchemaMap, schemaInfos map[string]*SchemaInfo, prop string,
) CheckFailurePath

func (CheckFailurePath) Attribute added in v3.49.0

func (p CheckFailurePath) Attribute(name string) CheckFailurePath

func (CheckFailurePath) ListElement added in v3.49.0

func (p CheckFailurePath) ListElement(n int64) CheckFailurePath

func (CheckFailurePath) MapElement added in v3.49.0

func (p CheckFailurePath) MapElement(s string) CheckFailurePath

func (CheckFailurePath) SetElement added in v3.49.0

func (p CheckFailurePath) SetElement() CheckFailurePath

type CheckFailureReason added in v3.49.0

type CheckFailureReason int64

Enumerates categories of failing checks. See NewCheckFailure.

const (
	MiscFailure CheckFailureReason = 0
	MissingKey  CheckFailureReason = 1
	InvalidKey  CheckFailureReason = 2
)

type ComputeDefaultOptions added in v3.56.0

type ComputeDefaultOptions = info.ComputeDefaultOptions

Configures [DefaultInfo.ComputeDefault].

type ComputeID added in v3.80.0

type ComputeID = info.ComputeID

func DelegateIDField added in v3.80.0

func DelegateIDField(field resource.PropertyKey, providerName, repoURL string) ComputeID

func DelegateIDProperty added in v3.83.0

func DelegateIDProperty(prop resource.PropertyPath, providerName, repoURL string) ComputeID

type ConfigEncoding added in v3.47.0

type ConfigEncoding struct {
	// contains filtered or unexported fields
}

func NewConfigEncoding added in v3.47.0

func NewConfigEncoding(config shim.SchemaMap, configInfos map[string]*SchemaInfo) *ConfigEncoding

func (*ConfigEncoding) MarshalProperties added in v3.47.0

func (enc *ConfigEncoding) MarshalProperties(props resource.PropertyMap) (*structpb.Struct, error)

Inverse of UnmarshalProperties, with additional support for secrets. Since the encoding cannot represent nested secrets, any nested secrets will be approximated by making the entire top-level property secret.

func (*ConfigEncoding) UnmarshalProperties added in v3.47.0

func (enc *ConfigEncoding) UnmarshalProperties(props *structpb.Struct) (resource.PropertyMap, error)

Inline from plugin.UnmarshalProperties substituting plugin.UnmarshalPropertyValue.

type ConfigInfo

type ConfigInfo = info.Config

ConfigInfo represents a synthetic configuration variable that is Pulumi-only, and not passed to Terraform.

type DataSource

type DataSource struct {
	Schema *DataSourceInfo // optional provider overrides.
	TF     shim.Resource   // the Terraform data source schema.
	TFName string          // the Terraform resource name.
}

DataSource wraps both the Terraform data source (resource) type info plus the overlay resource info.

type DataSourceInfo

type DataSourceInfo = info.DataSource

DataSourceInfo can be used to override a data source's standard name mangling and argument/return information.

type DataSourceStrategy added in v3.39.0

type DataSourceStrategy = info.ElementStrategy[DataSourceInfo]

A strategy for generating missing datasources.

type DefaultInfo

type DefaultInfo = info.Default

DefaultInfo lets fields get default values at runtime, before they are even passed to Terraform.

type DocInfo

type DocInfo = info.Doc

DocInfo contains optional overrides for finding and mapping TF docs.

type DocRuleInfo added in v3.47.0

type DocRuleInfo = info.DocRule

DocRuleInfo controls file discovery and edits for any subset of docs in a provider.

type DocsEdit added in v3.47.0

type DocsEdit = info.DocsEdit

type DocsPathInfo added in v3.47.0

type DocsPathInfo = info.DocsPath

Information for file lookup.

type GolangInfo

type GolangInfo = info.Golang

GolangInfo contains optional overlay information for Golang code-generation.

type HclExampler added in v3.20.0

type HclExampler = info.HclExampler

HclExampler represents a supplemental HCL example for a given resource or function.

type InlineHclExample added in v3.20.0

type InlineHclExample struct {
	// Token is the Pulumi identifier for the resource or function to which the example pertains, e.g.
	// "provider:module/getFoo:getFoo" (function), or
	// "provider:module/bar:Bar" (resource)
	Token string
	// Title is title of the example, e.g. "Basic Something", "Advanced Something with Something Else".
	Title string
	// Contents is the HCL that comprises the example with no surrounding Markdown constructs (e.g. “`hcl`).
	Contents string
}

InlineHclExample represents a literal HCL example and is primarily used for testing the Bridge.

func (InlineHclExample) GetMarkdown added in v3.20.0

func (e InlineHclExample) GetMarkdown() (string, error)

func (InlineHclExample) GetToken added in v3.20.0

func (e InlineHclExample) GetToken() string

type JavaInfo added in v3.24.0

type JavaInfo = info.Java

See https://github.com/pulumi/pulumi-java/blob/main/pkg/codegen/java/package_info.go#L35C1-L108C1 documenting supported options.

type JavaScriptInfo

type JavaScriptInfo = info.JavaScript

JavaScriptInfo contains optional overlay information for Python code-generation.

type LocalFileHclExample added in v3.20.0

type LocalFileHclExample struct {
	// Token is the Pulumi identifier for the resource or function to which the example pertains, e.g.
	// "provider:module/getFoo:getFoo" (function), or
	// "provider:module/bar:Bar" (resource)
	Token string
	// Title is title of the example, e.g. "Basic Something", "Advanced Something with Something Else".
	Title string
	// RelativePath is the path to the file in the Pulumi repo relative to the repo root.
	RelativePath string
}

LocalFileHclExample represents a supplemental HCL example that is on a relative path within the Pulumi provider repo.

func (LocalFileHclExample) GetMarkdown added in v3.20.0

func (e LocalFileHclExample) GetMarkdown() (string, error)

func (LocalFileHclExample) GetToken added in v3.20.0

func (e LocalFileHclExample) GetToken() string

type Log added in v3.57.0

type Log interface {
	Debug(msg string)
	Info(msg string)
	Warn(msg string)
	Error(msg string)
}

The set of logs available to show to the user

type LogRedirector

type LogRedirector struct {
	// contains filtered or unexported fields
}

LogRedirector creates a new redirection writer that takes as input plugin stderr output, and routes it to the correct Pulumi stream based on the standard Terraform logging output prefixes.

func NewTerraformLogRedirector

func NewTerraformLogRedirector(ctx context.Context, hostClient *provider.HostClient) *LogRedirector

func (*LogRedirector) Disable deprecated

func (lr *LogRedirector) Disable()

Deprecated: this function is not in use and will be removed.

func (*LogRedirector) Enable deprecated

func (lr *LogRedirector) Enable()

Deprecated: this function is not in use and will be removed.

func (*LogRedirector) Write

func (lr *LogRedirector) Write(p []byte) (n int, err error)

Implement io.Writer, parse lines, parse [TRACE], [DEBUG], [INFO], [WARN], and [ERROR] prefixes, and route.

type Logger added in v3.57.0

type Logger interface {
	Log

	// Convert to sending ephemeral status logs to the user.
	Status() Log
}

Send logs or status logs to the user.

Logged messages are pre-associated with the resource they are called from.

func GetLogger added in v3.57.0

func GetLogger(ctx context.Context) Logger

Get access to the Logger associated with this context.

type MakeEditRules added in v3.47.0

type MakeEditRules = info.MakeEditRules

The function used to produce the set of edit rules for a provider.

For example, if you want to skip default edits, you would use the function:

func([]DocsEdit) []DocsEdit { return nil }

If you wanted to incorporate custom edits, default edits, and then a check that the resulting document is valid, you would use the function:

func(defaults []DocsEdit) []DocsEdit {
	return append(customEdits, append(defaults, validityCheck)...)
}

type MarshallableDataSourceInfo

type MarshallableDataSourceInfo = info.MarshallableDataSource

MarshallableDataSourceInfo is the JSON-marshallable form of a Pulumi DataSourceInfo value.

func MarshalDataSourceInfo

func MarshalDataSourceInfo(d *DataSourceInfo) *MarshallableDataSourceInfo

MarshalDataSourceInfo converts a Pulumi DataSourceInfo value into a MarshallableDataSourceInfo value.

type MarshallableDefaultInfo

type MarshallableDefaultInfo = info.MarshallableDefault

MarshallableDefaultInfo is the JSON-marshallable form of a Pulumi DefaultInfo value.

func MarshalDefaultInfo

func MarshalDefaultInfo(d *DefaultInfo) *MarshallableDefaultInfo

MarshalDefaultInfo converts a Pulumi DefaultInfo value into a MarshallableDefaultInfo value.

type MarshallableElem

type MarshallableElem = info.MarshallableElemShim

MarshallableElem is the JSON-marshallable form of a Terraform schema's element field.

func MarshalElem

func MarshalElem(e interface{}) *MarshallableElem

MarshalElem converts a Terraform schema's element field into a MarshallableElem.

type MarshallableProvider

type MarshallableProvider = info.MarshallableProviderShim

MarshallableProvider is the JSON-marshallable form of a Terraform provider schema.

func MarshalProvider

func MarshalProvider(p shim.Provider) *MarshallableProvider

MarshalProvider converts a Terraform provider schema into a MarshallableProvider.

type MarshallableProviderInfo

type MarshallableProviderInfo = info.MarshallableProvider

MarshallableProviderInfo is the JSON-marshallable form of a Pulumi ProviderInfo value.

func MarshalProviderInfo

func MarshalProviderInfo(p *ProviderInfo) *MarshallableProviderInfo

MarshalProviderInfo converts a Pulumi ProviderInfo value into a MarshallableProviderInfo value.

type MarshallableResource

type MarshallableResource = info.MarshallableResourceShim

MarshallableResource is the JSON-marshallable form of a Terraform resource schema.

func MarshalResource

func MarshalResource(r shim.Resource) MarshallableResource

MarshalResource converts a Terraform resource schema into a MarshallableResource.

type MarshallableResourceInfo

type MarshallableResourceInfo = info.MarshallableResource

MarshallableResourceInfo is the JSON-marshallable form of a Pulumi ResourceInfo value.

func MarshalResourceInfo

func MarshalResourceInfo(r *ResourceInfo) *MarshallableResourceInfo

MarshalResourceInfo converts a Pulumi ResourceInfo value into a MarshallableResourceInfo value.

type MarshallableSchema

type MarshallableSchema = info.MarshallableSchemaShim

MarshallableSchema is the JSON-marshallable form of a Terraform schema.

func MarshalSchema

func MarshalSchema(s shim.Schema) *MarshallableSchema

MarshalSchema converts a Terraform schema into a MarshallableSchema.

type MarshallableSchemaInfo

type MarshallableSchemaInfo = info.MarshallableSchema

MarshallableSchemaInfo is the JSON-marshallable form of a Pulumi SchemaInfo value.

func MarshalSchemaInfo

func MarshalSchemaInfo(s *SchemaInfo) *MarshallableSchemaInfo

MarshalSchemaInfo converts a Pulumi SchemaInfo value into a MarshallableSchemaInfo value.

type MetadataInfo added in v3.43.0

type MetadataInfo = info.Metadata

Information necessary to persist and use provider level metadata.

func ExtractRuntimeMetadata added in v3.81.0

func ExtractRuntimeMetadata(info *MetadataInfo) *MetadataInfo

trim the metadata to just the keys required for the runtime phase in the future this method might also substitute compressed contents within some keys

func NewProviderMetadata added in v3.43.0

func NewProviderMetadata(bytes []byte) *MetadataInfo

Describe a metadata file called `bridge-metadata.json`.

`bytes` is the embedded metadata file.

type MuxProvider added in v3.71.0

type MuxProvider = info.MuxProvider

MuxProvider defines an interface which must be implemented by providers that shall be used as mixins of a wrapped Terraform provider

type OverlayInfo

type OverlayInfo = info.Overlay

OverlayInfo contains optional overlay information. Each info has a 1:1 correspondence with a module and permits extra files to be included from the overlays/ directory when building up packs/. This allows augmented code-generation for convenient things like helper functions, modules, and gradual typing.

type PreCheckCallback added in v3.56.0

type PreCheckCallback = info.PreCheckCallback

type PreConfigureCallback

type PreConfigureCallback = info.PreCheckCallback

PreConfigureCallback is a function to invoke prior to calling the TF provider Configure

type PreConfigureCallbackWithLogger added in v3.30.0

type PreConfigureCallbackWithLogger = info.PreConfigureCallbackWithLogger

PreConfigureCallbackWithLogger is a function to invoke prior to calling the T

type PreStateUpgradeHook added in v3.42.0

type PreStateUpgradeHook = info.PreStateUpgradeHook

If specified, the hook will run just prior to executing Terraform state upgrades to transform the resource state as stored in Pulumi. It can be used to perform idempotent corrections on corrupt state and to compensate for Terraform-level state upgrade not working as expected. Returns the corrected resource state and version. To be used with care.

See also: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/resource/schema#Schema.Version

type PreStateUpgradeHookArgs added in v3.42.0

type PreStateUpgradeHookArgs = info.PreStateUpgradeHookArgs

If specified, the hook will run just prior to executing Terraform state upgrades to transform the resource state as stored in Pulumi. It can be used to perform idempotent corrections on corrupt state and to compensate for Terraform-level state upgrade not working as expected. Returns the corrected resource state and version. To be used with care.

See also: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/resource/schema#Schema.Version

type PropertyTransform added in v3.61.0

type PropertyTransform = info.PropertyTransform

type PropertyVisitInfo added in v3.70.0

type PropertyVisitInfo struct {
	Root VisitRoot
	// contains filtered or unexported fields
}

func (*PropertyVisitInfo) EnclosingSchemaInfoMap added in v3.70.0

func (v *PropertyVisitInfo) EnclosingSchemaInfoMap() map[string]*SchemaInfo

func (*PropertyVisitInfo) EnclosingSchemaMap added in v3.70.0

func (v *PropertyVisitInfo) EnclosingSchemaMap() shim.SchemaMap

func (*PropertyVisitInfo) SchemaInfo added in v3.70.0

func (v *PropertyVisitInfo) SchemaInfo() *SchemaInfo

func (*PropertyVisitInfo) SchemaPath added in v3.70.0

func (v *PropertyVisitInfo) SchemaPath() SchemaPath

func (*PropertyVisitInfo) ShimSchema added in v3.70.0

func (v *PropertyVisitInfo) ShimSchema() shim.Schema

type PropertyVisitResult added in v3.70.0

type PropertyVisitResult struct {
	// If the visitor has done something.
	//
	// Visits will only be replayed during runtime startup if `HasEffect: true`.
	HasEffect bool
}

type PropertyVisitor added in v3.70.0

type PropertyVisitor = func(PropertyVisitInfo) (PropertyVisitResult, error)

type Provider

type Provider struct {
	pulumirpc.UnimplementedResourceProviderServer
	// contains filtered or unexported fields
}

Provider implements the Pulumi resource provider operations for any Terraform plugin.

func (*Provider) Attach added in v3.21.0

func (p *Provider) Attach(context context.Context, req *pulumirpc.PluginAttach) (*emptypb.Empty, error)

func (*Provider) Call added in v3.4.0

Call dynamically executes a method in the provider associated with a component resource.

func (*Provider) Cancel

func (p *Provider) Cancel(ctx context.Context, req *pbempty.Empty) (*pbempty.Empty, error)

Cancel requests that the provider cancel all ongoing RPCs. For TF, this is a no-op.

func (*Provider) Check

Check validates that the given property bag is valid for a resource of the given type.

func (*Provider) CheckConfig

CheckConfig validates the configuration for this Terraform provider.

func (*Provider) Configure

Configure configures the underlying Terraform provider with the live Pulumi variable state.

NOTE that validation and calling PreConfigureCallbacks are not called here but are called in CheckConfig. Pulumi will always call CheckConfig first and call Configure with validated (or extended) results of CheckConfig.

func (*Provider) Construct

Construct creates a new instance of the provided component resource and returns its state.

func (*Provider) Create

Create allocates a new instance of the provided resource and returns its unique ID afterwards. (The input ID must be blank.) If this call fails, the resource must not have been created (i.e., it is "transactional").

func (*Provider) Delete

func (p *Provider) Delete(ctx context.Context, req *pulumirpc.DeleteRequest) (*pbempty.Empty, error)

Delete tears down an existing resource with the given ID. If it fails, the resource is assumed to still exist.

func (*Provider) Diff

Diff checks what impacts a hypothetical update will have on the resource's properties.

func (*Provider) DiffConfig

func (p *Provider) DiffConfig(
	ctx context.Context, req *pulumirpc.DiffRequest,
) (*pulumirpc.DiffResponse, error)

A DiffConfig implementation enables the Pulumi provider to detect when provider configuration is changing and suggest a replacement plans when some properties require a replace. Replacing a provider then replaces all resources provisioned against this provider. See also the section on Explicit Provider Configuration in the docs:

https://www.pulumi.com/docs/concepts/resources/providers/

There is no matching context in Terraform so this remains a Pulumi-level feature.

func (*Provider) GetMapping added in v3.34.0

func (*Provider) GetPluginInfo

func (p *Provider) GetPluginInfo(ctx context.Context, req *pbempty.Empty) (*pulumirpc.PluginInfo, error)

GetPluginInfo implements an RPC call that returns the version of this plugin.

func (*Provider) GetSchema

GetSchema returns the JSON-encoded schema for this provider's package.

func (*Provider) Invoke

Invoke dynamically executes a built-in function in the provider.

func (*Provider) Read

Read the current live state associated with a resource. Enough state must be include in the inputs to uniquely identify the resource; this is typically just the resource ID, but may also include some properties.

func (*Provider) StreamInvoke

StreamInvoke dynamically executes a built-in function in the provider. The result is streamed back as a series of messages.

func (*Provider) Update

Update updates an existing resource with new values. Only those values in the provided property bag are updated to new values. The resource ID is returned and may be different if the resource had to be recreated.

type ProviderInfo

type ProviderInfo = info.Provider

ProviderInfo contains information about a Terraform provider plugin that we will use to generate the Pulumi metadata. It primarily contains a pointer to the Terraform schema, but can also contain specific name translations.

type ProviderMetadata added in v3.43.0

type ProviderMetadata = info.ProviderMetadata

A KV store persisted between `tfgen` and a running provider.

The store is read-write when the schema is being generated, and is persisted to disk with schema.json. During normal provider operation (pulumi-resource-${PKG}), the store if not persisted (making it effectively read-only).

type PulumiInputValidator added in v3.82.0

type PulumiInputValidator struct {
	// contains filtered or unexported fields
}

func NewInputValidator added in v3.82.0

func NewInputValidator(urn resource.URN, schema pschema.PackageSpec) *PulumiInputValidator

NewInputValidator creates a new input validator for a given resource and package schema

func (*PulumiInputValidator) ValidateInputs added in v3.82.0

func (v *PulumiInputValidator) ValidateInputs(resourceToken tokens.Type, inputs resource.PropertyMap) []TypeFailure

ValidateInputs will validate a set of inputs against the pulumi schema. It will return a list of type failures if any are found

type PulumiResource

type PulumiResource = info.PulumiResource

PulumiResource is just a little bundle that carries URN, seed and properties around.

type PythonInfo

type PythonInfo = info.Python

PythonInfo contains optional overlay information for Python code-generation.

type Resource

type Resource struct {
	Schema *ResourceInfo // optional provider overrides.
	TF     shim.Resource // the Terraform resource schema.
	TFName string        // the Terraform resource name.
}

Resource wraps both the Terraform resource type info plus the overlay resource info.

type ResourceInfo

type ResourceInfo = info.Resource

ResourceInfo is a top-level type exported by a provider. This structure can override the type to generate. It can also give custom metadata for fields, using the SchemaInfo structure below. Finally, a set of composite keys can be given; this is used when Terraform needs more than just the ID to uniquely identify and query for a resource.

type ResourceOrDataSourceInfo

type ResourceOrDataSourceInfo = info.ResourceOrDataSource

ResourceOrDataSourceInfo is a shared interface to ResourceInfo and DataSourceInfo mappings

type ResourceStrategy added in v3.38.1

type ResourceStrategy = info.ElementStrategy[ResourceInfo]

A strategy for generating missing resources.

type SchemaInfo

type SchemaInfo = info.Schema

SchemaInfo contains optional name transformations to apply.

func AutoName

func AutoName(name string, maxlength int, separator string) *SchemaInfo

AutoName configures a property to automatically populate with auto-computed names when no values are given to it by the user program.

The auto-computed names will be based on the resource name extracted from the resource URN, and have a random suffix. The lifecycle of automatic names is tied to the Pulumi resource lifecycle, so the automatic name will not change during normal updates and will persist until the resource is replaced.

If a required property is configured with AutoName, it becomes optional in the Pulumi Package Schema. Therefore removing AutoName from a required property is a breaking change.

For a quick example, consider aws.ec2.Keypair that has this code in its definition:

ResourceInfo{
    	Fields: map[string]*SchemaInfo{
    		"key_name": AutoName("keyName", 255, "-"),
    	},
}

Deploying a KeyPair allocates an automatic keyName without the user having to specify it:

const deployer = new aws.ec2.KeyPair("deployer", {publicKey: pubKey});
export const keyName = deployer.keyName;

Running this example produces:

Outputs:
   keyName: "deployer-6587896"

Note how the automatic name combines the resource name from the program with a random suffix.

func AutoNameTransform

func AutoNameTransform(name string, maxlen int, transform func(string) string) *SchemaInfo

AutoNameTransform creates custom schema for a Terraform name property which is automatically populated from the resource's URN name, with an 8 character random suffix ("-"+7 random chars), maximum length maxlen, and optional transformation function. This makes it easy to propagate the Pulumi resource's URN name part as the Terraform name as a convenient default, while still permitting it to be overridden.

func AutoNameWithCustomOptions

func AutoNameWithCustomOptions(name string, options AutoNameOptions) *SchemaInfo

AutoNameWithCustomOptions is similar to AutoName but exposes more options for configuring the generated names.

func LookupSchemaInfoMapPath added in v3.47.0

func LookupSchemaInfoMapPath(
	schemaPath SchemaPath,
	schemaInfos map[string]*SchemaInfo,
) *SchemaInfo

Drill down a path from a map of SchemaInfo objects and find a matching SchemaInfo if any.

func LookupSchemaInfoPath added in v3.47.0

func LookupSchemaInfoPath(schemaPath SchemaPath, schemaInfo *SchemaInfo) *SchemaInfo

Drill down a path from a SchemaInfo object and find a matching SchemaInfo if any.

func LookupSchemas added in v3.47.0

func LookupSchemas(schemaPath SchemaPath,
	schemaMap shim.SchemaMap,
	schemaInfos map[string]*SchemaInfo) (shim.Schema, *SchemaInfo, error)

Convenience method to lookup both a Schema and a SchemaInfo by path.

type SchemaPath added in v3.47.0

type SchemaPath = walk.SchemaPath

func PropertyPathToSchemaPath added in v3.47.0

func PropertyPathToSchemaPath(
	propertyPath resource.PropertyPath,
	schemaMap shim.SchemaMap,
	schemaInfos map[string]*SchemaInfo) SchemaPath

Translate a Pulumi property path to a bridged provider schema path.

The function hides the complexity of mapping Pulumi property names to Terraform names, joining Schema with user overrides in SchemaInfos, and accounting for MaxItems=1 situations where Pulumi flattens collections to plain values. and therefore SchemaPath values are longer than the PropertyPath values.

PropertyPathToSchemaPath may return nil if there is no matching schema found. This may happen when drilling down to values of unknown type, attributes not tracked in schema, or when there is a type mismatch between the path and the schema.

type SkipExamplesArgs added in v3.45.0

type SkipExamplesArgs = info.SkipExamplesArgs

EXPERIMENTAL: the signature may change in minor releases.

type Strategy added in v3.38.1

type Strategy = tokens.Strategy

Describe the mapping from TF resource and datasource tokens to Pulumi resources and datasources.

type TFProviderLicense

type TFProviderLicense = info.TFProviderLicense

TFProviderLicense is a way to be able to pass a license type for the upstream Terraform provider.

func SetProviderLicense

func SetProviderLicense(license TFProviderLicense) *TFProviderLicense

SetProviderLicense is used to pass a license type to a provider metadata

type Transformer

type Transformer = info.Transformer

Transformer is given the option to transform a value in situ before it is processed by the bridge. This transformation must be deterministic and idempotent, and any value produced by this transformation must be a legal alternative input value. A good example is a resource that accepts either a string or JSON-stringable map; a resource provider may opt to store the raw string, but let users pass in maps as a convenience mechanism, and have the transformer stringify them on the fly. This is safe to do because the raw string is still accepted as a possible input value.

type TraversalOption added in v3.70.0

type TraversalOption func(*traversalOptions)

func TraverseForEffect added in v3.70.0

func TraverseForEffect(forEffect bool) TraversalOption

Set TraverseProperties to run in a specific mode.

If forEffect is `false`, then TraverseProperties will always touch every field, regardless of runtime.

If forEffect is `true`, then TraverseProperties will only touch fields based off of the "effectful" list contained in [prov.MetadataInfo].

type TypeFailure added in v3.82.0

type TypeFailure struct {
	// The Reason for the type failure
	Reason string

	// The path to the property that failed
	ResourcePath string
}

type VisitConfigRoot added in v3.70.0

type VisitConfigRoot struct {
	// contains filtered or unexported fields
}

func (VisitConfigRoot) PulumiToken added in v3.70.0

func (r VisitConfigRoot) PulumiToken() tokens.Type

type VisitDataSourceRoot added in v3.70.0

type VisitDataSourceRoot struct {
	Info *DataSourceInfo

	TfToken string
	// contains filtered or unexported fields
}

func (VisitDataSourceRoot) PulumiToken added in v3.70.0

func (r VisitDataSourceRoot) PulumiToken() tokens.Type

type VisitResourceRoot added in v3.70.0

type VisitResourceRoot struct {
	Info   *ResourceInfo
	Schema shim.Resource

	TfToken string
	// contains filtered or unexported fields
}

func (VisitResourceRoot) PulumiToken added in v3.70.0

func (r VisitResourceRoot) PulumiToken() tokens.Type

type VisitRoot added in v3.70.0

type VisitRoot interface {
	PulumiToken() tokens.Type
	// contains filtered or unexported methods
}

Directories

Path Synopsis
[info] contains the types that bridged provider authors use to describe the mapping between Pulumi and Terraform providers.
[info] contains the types that bridged provider authors use to describe the mapping between Pulumi and Terraform providers.
x
Experimental extensions to the tfbridge module.
Experimental extensions to the tfbridge module.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL