tfbridge

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanTerraformSchema added in v0.15.0

func CleanTerraformSchema(tfs map[string]*schema.Schema) map[string]*schema.Schema

CleanTerraformSchema recursively removes "Removed" properties from a map[string]*schema.Schema.

func CoerceTerraformString added in v0.18.0

func CoerceTerraformString(schType schema.ValueType, stringValue string) (interface{}, error)

CoerceTerraformString coerces a string value to a Go value whose type is the type requested by the Terraform schema type. Returns an error if the string can't be successfully coerced to the requested type.

func FromName

func FromName(rand bool, maxlen int, transform func(string) string) func(res *PulumiResource) (interface{}, error)

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

func IsMaxItemsOne

func IsMaxItemsOne(tfs *schema.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)

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

func MakeTerraformAttributes

func MakeTerraformAttributes(res *schema.Resource, m resource.PropertyMap,
	tfs map[string]*schema.Schema, ps map[string]*SchemaInfo, config resource.PropertyMap,
	defaults bool) (map[string]string, map[string]interface{}, error)

MakeTerraformAttributes 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 MakeTerraformAttributesFromInputs

func MakeTerraformAttributesFromInputs(inputs map[string]interface{},
	tfs map[string]*schema.Schema) (map[string]string, error)

MakeTerraformAttributesFromInputs creates a flat Terraform map from a structured set of Terraform inputs.

func MakeTerraformAttributesFromRPC

func MakeTerraformAttributesFromRPC(res *schema.Resource, m *pbstruct.Struct,
	tfs map[string]*schema.Schema, ps map[string]*SchemaInfo, config resource.PropertyMap,
	allowUnknowns, defaults bool, label string) (map[string]string, map[string]interface{}, error)

MakeTerraformAttributesFromRPC unmarshals an RPC property map and calls through to MakeTerraformAttributes.

func MakeTerraformConfig

func MakeTerraformConfig(res *PulumiResource, m resource.PropertyMap,
	tfs map[string]*schema.Schema, ps map[string]*SchemaInfo,
	config resource.PropertyMap, defaults bool) (*terraform.ResourceConfig, error)

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

func MakeTerraformConfigFromInputs

func MakeTerraformConfigFromInputs(inputs map[string]interface{}) (*terraform.ResourceConfig, error)

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

func MakeTerraformConfigFromRPC

func MakeTerraformConfigFromRPC(res *PulumiResource, m *pbstruct.Struct,
	tfs map[string]*schema.Schema, ps map[string]*SchemaInfo,
	config resource.PropertyMap, allowUnknowns, defaults bool, label string) (*terraform.ResourceConfig, error)

MakeTerraformConfigFromRPC creates a Terraform config map from a Pulumi RPC property map.

func MakeTerraformInput

func MakeTerraformInput(res *PulumiResource, name string,
	old, v resource.PropertyValue, tfs *schema.Schema, ps *SchemaInfo, assets AssetTable, config resource.PropertyMap,
	defaults, rawNames bool) (interface{}, error)

MakeTerraformInput takes a single property plus custom schema info and does whatever is necessary to prepare it for use by Terraform. Note that this function may have side effects, for instance if it is necessary to spill an asset to disk in order to create a name out of it. Please take care not to call it superfluously!

func MakeTerraformInputs

func MakeTerraformInputs(res *PulumiResource, olds, news resource.PropertyMap,
	tfs map[string]*schema.Schema, ps map[string]*SchemaInfo, assets AssetTable, config resource.PropertyMap,
	defaults, useRawNames bool) (map[string]interface{}, error)

MakeTerraformInputs takes a property map plus custom schema info and does whatever is necessary to prepare it for use by Terraform. Note that this function may have side effects, for instance if it is necessary to spill an asset to disk in order to create a name out of it. Please take care not to call it superfluously!

func MakeTerraformOutput

func MakeTerraformOutput(v interface{},
	tfs *schema.Schema, ps *SchemaInfo, assets AssetTable, rawNames bool) resource.PropertyValue

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

func MakeTerraformOutputs

func MakeTerraformOutputs(outs map[string]interface{},
	tfs map[string]*schema.Schema, ps map[string]*SchemaInfo, assets AssetTable, rawNames 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(state *terraform.InstanceState,
	tfs map[string]*schema.Schema, ps map[string]*SchemaInfo) (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 PulumiToTerraformName

func PulumiToTerraformName(name string, tfs map[string]*schema.Schema) string

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

func Serve

func Serve(module string, version string, info ProviderInfo) 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 TerraformToPulumiName

func TerraformToPulumiName(name string, sch *schema.Schema, 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).

func TransformJSONDocument added in v0.15.1

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, which will be transformed into its JSON representation.

Types

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.

type AssetTranslation

type AssetTranslation struct {
	Kind      AssetTranslationKind   // the kind of translation to perform.
	Format    resource.ArchiveFormat // an archive format, required if this is an archive.
	HashField string                 // a field to store the hash into, if any.
}

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

func (*AssetTranslation) IsArchive

func (a *AssetTranslation) IsArchive() bool

IsArchive returns true if the translation deals with an archive (rather than asset).

func (*AssetTranslation) IsAsset

func (a *AssetTranslation) IsAsset() bool

IsAsset returns true if the translation deals with an asset (rather than archive).

func (*AssetTranslation) TranslateArchive

func (a *AssetTranslation) TranslateArchive(archive *resource.Archive) (interface{}, error)

TranslateArchive translates the given archive using the directives provided by the translation info.

func (*AssetTranslation) TranslateAsset

func (a *AssetTranslation) TranslateAsset(asset *resource.Asset) (interface{}, error)

TranslateAsset translates the given asset using the directives provided by the translation info.

func (*AssetTranslation) Type

func (a *AssetTranslation) Type() string

Type fetches the Pulumi runtime type corresponding to values of this asset kind.

type AssetTranslationKind

type AssetTranslationKind int

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

const (
	// FileAsset turns the asset into a file on disk and passes the filename in its place.
	FileAsset AssetTranslationKind = iota
	// BytesAsset turns the asset into a []byte and passes it directly in-memory.
	BytesAsset
	// FileArchive turns the archive into a file on disk and passes the filename in its place.
	FileArchive
	// BytesArchive turns the asset into a []byte and passes that directly in-memory.
	BytesArchive
)

type ConfigInfo added in v0.18.0

type ConfigInfo struct {
	// Info is the Pulumi schema for this variable.
	Info *SchemaInfo
	// Schema is the Terraform schema for this variable.
	Schema *schema.Schema
}

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     *schema.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 struct {
	Tok    tokens.ModuleMember
	Fields map[string]*SchemaInfo
	Docs   *DocInfo // overrides for finding and mapping TF docs.
}

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

type DefaultInfo

type DefaultInfo struct {
	// AutoNamed is true if this default represents an autogenerated name.
	AutoNamed bool
	// Config uses a configuration variable from this package as the default value.
	Config string
	// From applies a transformation from other resource properties.
	From func(res *PulumiResource) (interface{}, error)
	// Value injects a raw literal value as the default.
	Value interface{}
	// EnvVars to use for defaults. If none of these variables have values at runtime, the value of `Value` (if any)
	// will be used as the default.
	EnvVars []string
}

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

type DocInfo

type DocInfo struct {
	Source                         string // an optional override to locate TF docs; "" uses the default.
	IncludeAttributesFrom          string // optionally include attributes from another raw resource for docs.
	IncludeArgumentsFrom           string // optionally include arguments from another raw resource for docs.
	IncludeAttributesFromArguments string // optionally include attributes from another raw resource's arguments.
}

DocInfo contains optional overrids for finding and mapping TD docs.

type GolangInfo

type GolangInfo struct {
	Overlay *OverlayInfo // optional overlay information for augmented code-generation.
}

GolangInfo contains optional overlay information for Golang code-generation.

type JavaScriptInfo

type JavaScriptInfo struct {
	Dependencies     map[string]string // NPM dependencies to add to package.json.
	DevDependencies  map[string]string // NPM dev-dependencies to add to package.json.
	PeerDependencies map[string]string // NPM peer-dependencies to add to package.json.
	Overlay          *OverlayInfo      // optional overlay information for augmented code-generation.
}

JavaScriptInfo contains optional overlay information for Python code-generation.

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 added in v0.18.0

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

NewLogRedirector returns a new LogRedirector with the (unexported) writers field set to the given map.

func (*LogRedirector) Disable

func (lr *LogRedirector) Disable()

Disable disables most of the specific logging levels, but it retains debug logging.

func (*LogRedirector) Enable

func (lr *LogRedirector) Enable()

Enable turns on full featured logging. This is the default.

func (*LogRedirector) Write

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

type MarshallableDataSourceInfo added in v0.15.0

type MarshallableDataSourceInfo struct {
	Tok    tokens.ModuleMember                `json:"tok"`
	Fields map[string]*MarshallableSchemaInfo `json:"fields"`
}

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

func MarshalDataSourceInfo added in v0.15.0

func MarshalDataSourceInfo(d *DataSourceInfo) *MarshallableDataSourceInfo

MarshalDataSourceInfo converts a Pulumi DataSourceInfo value into a MarshallableDataSourceInfo value.

func (*MarshallableDataSourceInfo) Unmarshal added in v0.15.0

Unmarshal creates a mostly-=initialized Pulumi DataSourceInfo value from the given MarshallableDataSourceInfo.

type MarshallableDefaultInfo added in v0.18.0

type MarshallableDefaultInfo struct {
	AutoNamed bool        `json:"autonamed,omitempty"`
	IsFunc    bool        `json:"isFunc,omitempty"`
	Value     interface{} `json:"value,omitempty"`
	EnvVars   []string    `json:"envvars,omitempty"`
}

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

func MarshalDefaultInfo added in v0.18.0

func MarshalDefaultInfo(d *DefaultInfo) *MarshallableDefaultInfo

MarshalDefaultInfo converts a Pulumi DefaultInfo value into a MarshallableDefaultInfo value.

func (*MarshallableDefaultInfo) Unmarshal added in v0.18.0

func (m *MarshallableDefaultInfo) Unmarshal() *DefaultInfo

Unmarshal creates a mostly-initialized Pulumi DefaultInfo value from the given MarshallableDefaultInfo.

type MarshallableElem added in v0.15.0

type MarshallableElem struct {
	Schema   *MarshallableSchema  `json:"schema,omitempty"`
	Resource MarshallableResource `json:"resource,omitempty"`
}

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

func MarshalElem added in v0.15.0

func MarshalElem(e interface{}) *MarshallableElem

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

func (*MarshallableElem) Unmarshal added in v0.15.0

func (m *MarshallableElem) Unmarshal() interface{}

Unmarshal creates a Terraform schema element from a MarshallableElem.

type MarshallableProvider added in v0.15.0

type MarshallableProvider struct {
	Schema      map[string]*MarshallableSchema  `json:"schema,omitempty"`
	Resources   map[string]MarshallableResource `json:"resources,omitempty"`
	DataSources map[string]MarshallableResource `json:"dataSources,omitempty"`
}

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

func MarshalProvider added in v0.15.0

func MarshalProvider(p *schema.Provider) *MarshallableProvider

MarshalProvider converts a Terraform provider schema into a MarshallableProvider.

func (*MarshallableProvider) Unmarshal added in v0.15.0

func (m *MarshallableProvider) Unmarshal() *schema.Provider

Unmarshal creates a mostly-initialized Terraform provider schema from a MarshallableProvider

type MarshallableProviderInfo added in v0.15.0

type MarshallableProviderInfo struct {
	Provider    *MarshallableProvider                  `json:"provider"`
	Config      map[string]*MarshallableSchemaInfo     `json:"config,omitempty"`
	Resources   map[string]*MarshallableResourceInfo   `json:"resources,omitempty"`
	DataSources map[string]*MarshallableDataSourceInfo `json:"dataSources,omitempty"`
}

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

func MarshalProviderInfo added in v0.15.0

func MarshalProviderInfo(p *ProviderInfo) *MarshallableProviderInfo

MarshalProviderInfo converts a Pulumi ProviderInfo value into a MarshallableProviderInfo value.

func (*MarshallableProviderInfo) Unmarshal added in v0.15.0

func (m *MarshallableProviderInfo) Unmarshal() *ProviderInfo

Unmarshal creates a mostly-=initialized Pulumi ProviderInfo value from the given MarshallableProviderInfo.

type MarshallableResource added in v0.15.0

type MarshallableResource map[string]*MarshallableSchema

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

func MarshalResource added in v0.15.0

func MarshalResource(r *schema.Resource) MarshallableResource

MarshalResource converts a Terraform resource schema into a MarshallableResource.

func (MarshallableResource) Unmarshal added in v0.15.0

func (m MarshallableResource) Unmarshal() *schema.Resource

Unmarshal creates a mostly-initialized Terraform resource schema from the given MarshallableResource.

type MarshallableResourceInfo added in v0.15.0

type MarshallableResourceInfo struct {
	Tok      tokens.Type                        `json:"tok"`
	Fields   map[string]*MarshallableSchemaInfo `json:"fields"`
	IDFields []string                           `json:"idFields"`
}

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

func MarshalResourceInfo added in v0.15.0

func MarshalResourceInfo(r *ResourceInfo) *MarshallableResourceInfo

MarshalResourceInfo converts a Pulumi ResourceInfo value into a MarshallableResourceInfo value.

func (*MarshallableResourceInfo) Unmarshal added in v0.15.0

func (m *MarshallableResourceInfo) Unmarshal() *ResourceInfo

Unmarshal creates a mostly-=initialized Pulumi ResourceInfo value from the given MarshallableResourceInfo.

type MarshallableSchema added in v0.15.0

type MarshallableSchema struct {
	Type          schema.ValueType  `json:"type"`
	Optional      bool              `json:"optional,omitempty"`
	Required      bool              `json:"required,omitempty"`
	Computed      bool              `json:"computed,omitempty"`
	ForceNew      bool              `json:"forceNew,omitempty"`
	Elem          *MarshallableElem `json:"element,omitempty"`
	MaxItems      int               `json:"maxItems,omitempty"`
	MinItems      int               `json:"minItems,omitempty"`
	PromoteSingle bool              `json:"promoteSingle,omitempty"`
}

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

func MarshalSchema added in v0.15.0

func MarshalSchema(s *schema.Schema) *MarshallableSchema

MarshalSchema converts a Terraform schema into a MarshallableSchema.

func (*MarshallableSchema) Unmarshal added in v0.15.0

func (m *MarshallableSchema) Unmarshal() *schema.Schema

Unmarshal creates a mostly-initialized Terraform schema from the given MarshallableSchema.

type MarshallableSchemaInfo added in v0.15.0

type MarshallableSchemaInfo struct {
	Name        string                             `json:"name,omitempty"`
	Type        tokens.Type                        `json:"typeomitempty"`
	AltTypes    []tokens.Type                      `json:"altTypes,omitempty"`
	Elem        *MarshallableSchemaInfo            `json:"element,omitempty"`
	Fields      map[string]*MarshallableSchemaInfo `json:"fields,omitempty"`
	Asset       *AssetTranslation                  `json:"asset,omitempty"`
	Default     *MarshallableDefaultInfo           `json:"default,omitempty"`
	MaxItemsOne *bool                              `json:"maxItemsOne,omitempty"`
}

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

func MarshalSchemaInfo added in v0.15.0

func MarshalSchemaInfo(s *SchemaInfo) *MarshallableSchemaInfo

MarshalSchemaInfo converts a Pulumi SchemaInfo value into a MarshallableSchemaInfo value.

func (*MarshallableSchemaInfo) Unmarshal added in v0.15.0

func (m *MarshallableSchemaInfo) Unmarshal() *SchemaInfo

Unmarshal creates a mostly-=initialized Pulumi SchemaInfo value from the given MarshallableSchemaInfo.

type OverlayInfo

type OverlayInfo struct {
	Files     []string                // additional files to include in the index file.
	DestFiles []string                // like Files, but the overlays must already exist in the destination.
	Modules   map[string]*OverlayInfo // extra modules to inject into the structure.
}

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 PreConfigureCallback

type PreConfigureCallback func(vars resource.PropertyMap, config *terraform.ResourceConfig) error

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

type Provider

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

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

func NewProvider

func NewProvider(ctx context.Context, host *provider.HostClient, module string, version string,
	tf *schema.Provider, info ProviderInfo) *Provider

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

func (*Provider) Cancel added in v0.15.0

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 added in v0.18.0

CheckConfig validates the configuration for this Terraform provider.

func (*Provider) Configure

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

Configure configures the underlying Terraform provider with the live Pulumi variable 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 "transacational").

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 added in v0.18.0

DiffConfig diffs the configuration for this Terraform provider.

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) 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) 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 struct {
	P              *schema.Provider           // the TF provider/schema.
	Name           string                     // the TF provider name (e.g. terraform-provider-XXXX).
	ResourcePrefix string                     // the prefix on resources the provider exposes, if different to `Name`.
	GitHubOrg      string                     // the GitHub org of the provider. Defaults to `terraform-providers`.
	Description    string                     // an optional descriptive overview of the package (a default will be given).
	Keywords       []string                   // an optional list of keywords to help discovery of this package.
	License        string                     // the license, if any, the resulting package has (default is none).
	Homepage       string                     // the URL to the project homepage.
	Repository     string                     // the URL to the project source code repository.
	Config         map[string]*SchemaInfo     // a map of TF name to config schema overrides.
	ExtraConfig    map[string]*ConfigInfo     // a list of Pulumi-only configuration variables.
	Resources      map[string]*ResourceInfo   // a map of TF name to Pulumi name; standard mangling occurs if no entry.
	DataSources    map[string]*DataSourceInfo // a map of TF name to Pulumi resource info.
	JavaScript     *JavaScriptInfo            // optional overlay information for augmented JavaScript code-generation.
	Python         *PythonInfo                // optional overlay information for augmented Python code-generation.
	Golang         *GolangInfo                // optional overlay information for augmented Golang code-generation.

	PreConfigureCallback PreConfigureCallback // a provider-specific callback to invoke prior to TF Configure
}

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.

func (ProviderInfo) GetGitHubOrg added in v0.18.0

func (info ProviderInfo) GetGitHubOrg() string

func (ProviderInfo) GetResourcePrefix added in v0.18.0

func (info ProviderInfo) GetResourcePrefix() string

GetResourcePrefix returns the resource prefix for the provider: info.ResourcePrefix if that is set, or info.Name if not. This is to avoid unexpected behaviour with providers which have no need to set ResourcePrefix following its introduction.

type PulumiResource

type PulumiResource struct {
	URN        resource.URN
	Properties resource.PropertyMap
}

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

type PythonInfo

type PythonInfo struct {
	Requires map[string]string // Pip install_requires information.
	Overlay  *OverlayInfo      // optional overlay information for augmented code-generation.
}

PythonInfo contains optional overlay information for Python code-generation.

type Resource

type Resource struct {
	Schema *ResourceInfo    // optional provider overrides.
	TF     *schema.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 struct {
	Tok                 tokens.Type            // a type token to override the default; "" uses the default.
	Fields              map[string]*SchemaInfo // a map of custom field names; if a type is missing, uses the default.
	IDFields            []string               // an optional list of ID alias fields.
	Docs                *DocInfo               // overrides for finding and mapping TF docs.
	DeleteBeforeReplace bool                   // if true, Pulumi will delete before creating new replacement resources.
}

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 SchemaInfo

type SchemaInfo struct {
	// a name to override the default; "" uses the default.
	Name string

	// a type to override the default; "" uses the default.
	Type tokens.Type

	// alternative types that can be used instead of the override.
	AltTypes []tokens.Type

	// an optional idemponent transformation, applied before passing to TF.
	Transform Transformer

	// a schema override for elements for arrays, maps, and sets.
	Elem *SchemaInfo

	// a map of custom field names; if a type is missing, the default is used.
	Fields map[string]*SchemaInfo

	// a map of asset translation information, if this is an asset.
	Asset *AssetTranslation

	// an optional default directive to be applied if a value is missing.
	Default *DefaultInfo

	// to override whether a property is stable or not.
	Stable *bool

	// to override whether this property should project as a scalar or array.
	MaxItemsOne *bool

	// to remove empty object array elements
	SuppressEmptyMapElements *bool
}

SchemaInfo contains optional name transformations to apply.

func AutoName

func AutoName(name string, maxlen int) *SchemaInfo

AutoName 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), and maximum length of maxlen. 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 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 (SchemaInfo) HasDefault

func (info SchemaInfo) HasDefault() bool

HasDefault returns true if there is a default value for this property.

type Transformer added in v0.15.1

type Transformer func(resource.PropertyValue) (resource.PropertyValue, error)

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.

Jump to

Keyboard shortcuts

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