schema is a high-level framework for easily writing new providers for Terraform. Usage of schema is recommended over attempting to write to the low-level plugin interfaces manually.
schema breaks down provider creation into simple CRUD operations for resources. The logic of diffing, destroying before creating, updating or creating, etc. is all handled by the framework. The plugin author only needs to implement a configuration schema and the CRUD operations and everything else is meant to just work.
A good starting point is to view the Provider structure.
const ( TimeoutCreate = "create" TimeoutRead = "read" TimeoutUpdate = "update" TimeoutDelete = "delete" TimeoutDefault = "default" )View Source
const TimeoutKey = "e2bfb730-ecaa-11e6-8f88-34363bc7c4c0"View Source
var ReservedDataSourceFields = []string{ "connection", "count", "depends_on", "lifecycle", "provider", "provisioner", }View Source
var ReservedResourceFields = []string{ "connection", "count", "depends_on", "lifecycle", "provider", "provisioner", }
ApplyDiff takes a cty.Value state and applies a terraform.InstanceDiff to get a new cty.Value state. This is used to convert the diff returned from the legacy provider Diff method to the state required for the new PlanResourceChange method.
could be time.Duration, int64 or float64
DiffFromValues takes the current state and desired state as cty.Values and derives a terraform.InstanceDiff to give to the legacy providers. This is used to take the states provided by the new ApplyResourceChange method and convert them to a state+diff required for the legacy Apply method.
func HashInt(v interface{}) int
HashInt hashes integers. If you want a Set of integers, this is the SchemaSetFunc you want.
func HashString(v interface{}) int
HashString hashes strings. If you want a Set of strings, this is the SchemaSetFunc you want.
JSONMapToStateValue takes a generic json map[string]interface{} and converts it to the specific type, ensuring that the values conform to the schema.
Noop is a convenience implementation of resource function which takes no action and returns no error.
NoopContext is a convenience implementation of context aware resource function which takes no action and returns no error.
RemoveFromState is a convenience implementation of a resource function which sets the resource ID to empty string (to remove it from state) and returns no error.
SerializeValueForHash appends a serialization of the given resource config to the given buffer, guaranteeing deterministic results given the same value and schema.
Its primary purpose is as input into a hashing function in order to hash complex substructures when used in sets, and so the serialization is not reversible.
SetUnknowns takes a cty.Value, and compares it to the schema setting any null values which are computed to unknown.
StateValueFromInstanceState converts a terraform.InstanceState to a cty.Value as described by the provided cty.Type, and maintains the resource ID as the "id" attribute.
StateValueToJSONMap converts a cty.Value to generic JSON map via the cty JSON encoding.
StopContext returns a context safe for global use that will cancel when Terraform requests a stop. This function should only be called within a ConfigureContextFunc, passing in the request scoped context received in that method.
Deprecated: The use of a global context is discouraged. Please use the new context aware CRUD methods.
BasicMapReader implements MapReader for a single map.
ConfigFieldReader reads fields out of an untyped map[string]string to the best of its ability. It also applies defaults from the Schema. (The other field readers do not need default handling because they source fully populated data structures.)
ConfigureContextFunc is the function used to configure a Provider.
The interface{} value returned by this function is stored and passed into the subsequent resources as the meta parameter. This return value is usually used to pass along a configured API client, a configuration structure, etc.
ConfigureFunc is the function used to configure a Provider.
Deprecated: Please use ConfigureContextFunc
type ConfigureProviderRequest struct { DeferralAllowed bool ResourceData *ResourceData }
See Resource documentation.
The following function types are of the legacy CRUD operations.
Deprecated: Please use the context aware equivalents instead.
See Resource documentation.
Deferred is used to indicate to Terraform that a resource or data source is not able to be applied yet and should be skipped (deferred). After completing an apply that has deferred actions, the practitioner can then execute additional plan and apply “rounds” to eventually reach convergence where there are no remaining deferred actions.
NOTE: This functionality is related to deferred action support, which is currently experimental and is subject to change or break without warning. It is not protected by version compatibility guarantees.
type DeferredReason int32
DeferredReason represents different reasons for deferring a change.
NOTE: This functionality is related to deferred action support, which is currently experimental and is subject to change or break without warning. It is not protected by version compatibility guarantees.
MAINTAINER NOTE: Only PROVIDER_CONFIG_UNKNOWN (enum value 2 in the plugin-protocol) is relevant for SDKv2. Since (Deferred).Reason is mapped directly to the plugin-protocol, the other enum values are intentionally omitted here.
See Resource documentation.
Deprecated: Please use the context aware equivalents instead.
DiffFieldReader reads fields out of a diff structures.
It also requires access to a Reader that reads fields from the structure that the diff was derived from. This is usually the state. This is required because a diff on its own doesn't have complete data about full objects such as maps.
The Source MUST be the data that the diff was derived from. If it isn't, the behavior of this struct is undefined.
Reading fields from a DiffFieldReader is identical to reading from Source except the diff will be applied to the end result.
The "Exists" field on the result will be set to true if the complete field exists whether its from the source, diff, or a combination of both. It cannot be determined whether a retrieved value is composed of diff elements.
type Equal interface { Equal(interface{}) bool }
Equal is an interface that checks for deep equality between two objects.
Deprecated: Please use the context aware equivalents instead.
type FieldReadResult struct { Value interface{} ValueProcessed interface{} Exists bool Computed bool }
FieldReadResult encapsulates all the resulting data from reading a field.
ValueOrZero returns the value of this result or the zero value of the schema type, ensuring a consistent non-nil return value.
FieldReaders are responsible for decoding fields out of data into the proper typed representation. ResourceData uses this to query data out of multiple sources: config, state, diffs, etc.
type FieldWriter interface { WriteField([]string, interface{}) error }
FieldWriters are responsible for writing fields by address into a proper typed representation. ResourceData uses this to write new data into existing sources.
type GRPCProviderServer struct { }
GRPCProviderServer handles the server, or plugin side of the rpc connection.
StopContext derives a new context from the passed in grpc context. It creates a goroutine to wait for the server stop and propagates cancellation to the derived grpc context.
type IdentityData struct { }
Reading/writing data will be similar to the *schema.ResourceData flatmap
Implementation of a single identity schema version upgrade.
type InternalMap = schemaMap
InternalMap is used to aid in the transition to the new schema types and protocol. The name is not meant to convey any usefulness, as this is not to be used directly by any providers.
MapFieldReader reads fields out of an untyped map[string]string to the best of its ability.
MapFieldWriter writes data into a single map[string]string structure.
Map returns the underlying map that is being written to.
MapReader is an interface that is given to MapFieldReader for accessing a "map". This can be used to have alternate implementations. For a basic map[string]string, use BasicMapReader.
MultiLevelFieldReader reads from other field readers, merging their results along the way in a specific order. You can specify "levels" and name them in order to read only an exact level or up to a specific level.
This is useful for saying things such as "read the field from the state and config and merge them" or "read the latest value of the field".
Provider represents a resource provider in Terraform, and properly implements all of the ResourceProvider API.
By defining a schema for the configuration of the provider, the map of supporting resources, and a configuration function, the schema framework takes over and handles all the provider operations for you.
After defining the provider structure, it is unlikely that you'll require any of the methods on Provider itself.
Configure configures the provider itself with the configuration given. This is useful for setting things like access keys.
This won't be called at all if no provider configuration is given.
DataSources returns all of the available data sources that this provider implements.
GRPCProvider returns a gRPC server, for use with terraform-plugin-mux.
GetSchema returns the config schema for the main provider configuration, as would appear in a "provider" block in the configuration files.
Currently not all providers support schema. Callers must therefore first call Resources and DataSources and ensure that at least one resource or data source has the SchemaAvailable flag set.
ImportState requests that the given resource be imported.
The returned InstanceState only requires ID be set. Importing will always call Refresh after the state to complete it.
IMPORTANT: InstanceState doesn't have the resource type attached to it. A type must be specified on the state via the Ephemeral field on the state.
This function can return multiple states. Normally, an import will map 1:1 to a physical resource. However, some resources map to multiple. For example, an AWS security group may contain many rules. Each rule is represented by a separate resource in Terraform, therefore multiple states are returned.
InternalValidate should be called to validate the structure of the provider.
This should be called in a unit test for any provider to verify before release that a provider is properly configured for use with this library.
Meta returns the metadata associated with this provider that was returned by the Configure call. It will be nil until Configure is called.
Resources returns all the available resource types that this provider knows how to manage.
func (p *Provider) SetMeta(v interface{})
SetMeta can be used to forcefully set the Meta object of the provider. Note that if Configure is called the return value will override anything set here.
UserAgent returns a string suitable for use in the User-Agent header of requests generated by the provider. The generated string contains the version of Terraform, the Plugin SDK, and the provider used to generate the request. `name` should be the hyphen-separated reporting name of the provider, and `version` should be the version of the provider.
If TF_APPEND_USER_AGENT is set, its value will be appended to the returned string.
Validate is called once at the beginning with the raw configuration (no interpolation done) and can return diagnostics
This is called once with the provider configuration only. It may not be called at all if no provider configuration is given.
This should not assume that any values of the configurations are valid. The primary use case of this call is to check that required keys are set.
ValidateDataSource is called once at the beginning with the raw configuration (no interpolation done) and can return diagnostics.
This is called once per data source instance.
This should not assume any of the values in the resource configuration are valid since it is possible they have to be interpolated still. The primary use case of this call is to check that the required keys are set and that the general structure is correct.
ValidateResource is called once at the beginning with the raw configuration (no interpolation done) and can return diagnostics.
This is called once per resource.
This should not assume any of the values in the resource configuration are valid since it is possible they have to be interpolated still. The primary use case of this call is to check that the required keys are set and that the general structure is correct.
type ProviderDeferredBehavior struct { EnablePlanModification bool }
ProviderDeferredBehavior enables provider-defined logic to be executed in the case of a deferred response from provider configuration.
NOTE: This functionality is related to deferred action support, which is currently experimental and is subject to change or break without warning. It is not protected by version compatibility guarantees.
See Resource documentation.
Deprecated: Please use the context aware equivalents instead.
Resource is an abstraction for multiple Terraform concepts:
To fully implement managed resources, the Provider type ResourcesMap field should include a reference to an implementation of this type. To fully implement data resources, the Provider type DataSourcesMap field should include a reference to an implementation of this type.
Each field further documents any constraints based on the Terraform concept being implemented.
DataSourceResourceShim takes a Resource instance describing a data source (with a Read implementation and a Schema, at least) and returns a new Resource instance with additional Create and Delete implementations that allow the data source to be used as a resource.
This is a backward-compatibility layer for data sources that were formerly read-only resources before the data source concept was added. It should not be used for any *new* data sources.
The Read function for the data source *must* call d.SetId with a non-empty id in order for this shim to function as expected.
The provided Resource instance, and its schema, will be modified in-place to make it suitable for use as a full resource.
Apply creates, updates, and/or deletes a resource.
CoreConfigSchema is a convenient shortcut for calling CoreConfigSchema on the resource's schema. CoreConfigSchema adds the implicitly required "id" attribute for top level resources if it doesn't exist.
Data returns a ResourceData struct for this Resource. Each return value is a separate copy and can be safely modified differently.
The data returned from this function has no actual affect on the Resource itself (including the state given to this function).
This function is useful for unit tests and ResourceImporter functions.
Diff returns a diff of this resource.
InternalValidate should be called to validate the structure of the resource.
This should be called in a unit test for any resource to verify before release that a resource is properly configured for use with this library.
Provider.InternalValidate() will automatically call this for all of the resources it manages, so you don't need to call this manually if it is part of a Provider.
ReadDataApply loads the data for a data source, given a diff that describes the configuration arguments and desired computed attributes.
RefreshWithoutUpgrade reads the instance state, but does not call MigrateState or the StateUpgraders, since those are now invoked in a separate API call. RefreshWithoutUpgrade is part of the new plugin shims.
SchemaMap returns the schema information for this Resource whether it is defined via the SchemaFunc field or Schema field. The SchemaFunc field, if defined, takes precedence over the Schema field.
ShimInstanceStateFromValue converts a cty.Value to a terraform.InstanceState.
TestResourceData Yields a ResourceData filled with this resource's schema for use in unit testing
TODO: May be able to be removed with the above ResourceData function.
Validate validates the resource configuration against the schema.
ResourceBehavior controls SDK-specific logic when interacting with a resource.
type ResourceData struct { }
ResourceData is used to query and set the attributes of a resource.
ResourceData is the primary argument received for CRUD operations on a resource as well as configuration of a provider. It is a powerful structure that can be used to not only query data, but also check for changes
The most relevant methods to take a look at are Get and Set.
ImportStatePassthrough is an implementation of StateFunc that can be used to simply pass the ID directly through.
Deprecated: Please use the context aware ImportStatePassthroughContext instead
ImportStatePassthroughContext is an implementation of StateContextFunc that can be used to simply pass the ID directly through. This should be used only in the case that an ID-only refresh is possible. Please note that this implementation does not work when using resource identity as an Id still has to be set and the identity might contain multiple fields that are not the same as the ID.
TestResourceDataRaw creates a ResourceData from a raw configuration map.
TestResourceDataWithIdentityRaw creates a ResourceData with an identity from a raw identity map.
ConnInfo returns the connection info for this resource.
Get returns the data for the given key, or nil if the key doesn't exist in the schema.
If the key does exist in the schema but doesn't exist in the configuration, then the default value for that type will be returned. For strings, this is "", for numbers it is 0, etc.
If you want to test if something is set at all in the configuration, use GetOk.
GetChange returns the old and new value for a given key.
HasChange should be used to check if a change exists. It is possible that both the old and new value are the same if the old value was not set and the new value is. This is common, for example, for boolean fields which have a zero value of false.
GetOk returns the data for the given key and whether or not the key has been set to a non-zero value at some point.
The first result will not necessarily be nil if the value doesn't exist. The second result should be checked to determine this information.
GetOkExists can check if TypeBool attributes that are Optional with no Default value have been set.
Deprecated: usage is discouraged due to undefined behaviors and may be removed in a future version of the SDK
GetRawConfig returns the cty.Value that Terraform sent the SDK for the config. If no value was sent, or if a null value was sent, the value will be a null value of the resource's type.
GetRawConfig is considered experimental and advanced functionality, and familiarity with the Terraform protocol is suggested when using it.
GetRawConfigAt is a helper method for retrieving specific values from the RawConfig returned from GetRawConfig. It returns the cty.Value for a given cty.Path or an error diagnostic if the value at the given path does not exist.
GetRawConfigAt is considered advanced functionality, and familiarity with the Terraform protocol is suggested when using it.
GetRawPlan returns the cty.Value that Terraform sent the SDK for the plan. If no value was sent, or if a null value was sent, the value will be a null value of the resource's type.
GetRawPlan is considered experimental and advanced functionality, and familiarity with the Terraform protocol is suggested when using it.
GetRawState returns the cty.Value that Terraform sent the SDK for the state. If no value was sent, or if a null value was sent, the value will be a null value of the resource's type.
GetRawState is considered experimental and advanced functionality, and familiarity with the Terraform protocol is suggested when using it.
HasChange returns whether or not the given key has been changed.
HasChangeExcept returns whether any keys outside the given key have been changed.
This function only works with root attribute keys.
HasChanges returns whether or not any of the given keys has been changed.
HasChangesExcept returns whether any keys outside the given keys have been changed.
This function only works with root attribute keys.
Id returns the ID of the resource.
IdentityData is only available for managed resources, data sources will return an error. // TODO: return error in case of data sources
Partial is a legacy function that was used for capturing state of specific attributes if an update only partially worked. Enabling this flag without setting any specific keys with the now removed SetPartial has a useful side effect of preserving all of the resource's previous state. Although confusing, it has been discovered that during an update when an error is returned, the proposed config is set into state, even without any calls to d.Set.
In practice this default behavior goes mostly unnoticed since Terraform refreshes between operations by default. The state situation discussed is subject to further investigation and potential change. Until then, this function has been preserved for the specific usecase.
Set sets the value for the given key.
If the key is invalid or the value is not a correct type, an error will be returned.
SetConnInfo sets the connection info for a resource.
SetId sets the ID of the resource. If the value is blank, then the resource is destroyed.
SetType sets the ephemeral type for the data. This is only required for importing.
State returns the new InstanceState after the diff and any Set calls.
Timeout returns the data for the given timeout key Returns a duration of 20 minutes for any key not found, or not found and no default.
type ResourceDiff struct { }
ResourceDiff is used to query and make custom changes to an in-flight diff. It can be used to veto particular changes in the diff, customize the diff that has been created, or diff values not controlled by config.
The object functions similar to ResourceData, however most notably lacks Set, SetPartial, and Partial, as it should be used to change diff values only. Most other first-class ResourceData functions exist, namely Get, GetOk, HasChange, and GetChange exist.
All functions in ResourceDiff, save for ForceNew, can only be used on computed fields.
Clear wipes the diff for a particular key. It is called by ResourceDiff's functionality to remove any possibility of conflicts, but can be called on its own to just remove a specific key from the diff completely.
Note that this does not wipe an override. This function is only allowed on computed keys.
ForceNew force-flags ForceNew in the schema for a specific key, and re-calculates its diff, effectively causing this attribute to force a new resource.
Keep in mind that forcing a new resource will force a second run of the resource's CustomizeDiff function (with a new ResourceDiff) once the current one has completed. This second run is performed without state. This behavior will be the same as if a new resource is being created and is performed to ensure that the diff looks like the diff for a new resource as much as possible. CustomizeDiff should expect such a scenario and act correctly.
This function is a no-op/error if there is no diff.
Note that the change to schema is permanent for the lifecycle of this specific ResourceDiff instance.
Get hands off to ResourceData.Get.
GetChange gets the change between the state and diff, checking first to see if an overridden diff exists.
This implementation differs from ResourceData's in the way that we first get results from the exact levels for the new diff, then from state and diff as per normal.
GetChangedKeysPrefix helps to implement Resource.CustomizeDiff where we need to act on all nested fields without calling out each one separately. An empty prefix is supported, returning all changed keys.
GetOk functions the same way as ResourceData.GetOk, but it also checks the new diff levels to provide data consistent with the current state of the customized diff.
GetOkExists functions the same way as GetOkExists within ResourceData, but it also checks the new diff levels to provide data consistent with the current state of the customized diff.
This is nearly the same function as GetOk, yet it does not check for the zero value of the attribute's type. This allows for attributes without a default, to fully check for a literal assignment, regardless of the zero-value for that type.
GetRawConfig returns the cty.Value that Terraform sent the SDK for the config. If no value was sent, or if a null value was sent, the value will be a null value of the resource's type.
GetRawConfig is considered experimental and advanced functionality, and familiarity with the Terraform protocol is suggested when using it.
GetRawConfigAt is a helper method for retrieving specific values from the RawConfig returned from GetRawConfig. It returns the cty.Value for a given cty.Path or an error diagnostic if the value at the given path does not exist.
GetRawConfigAt is considered advanced functionality, and familiarity with the Terraform protocol is suggested when using it.
GetRawPlan returns the cty.Value that Terraform sent the SDK for the plan. If no value was sent, or if a null value was sent, the value will be a null value of the resource's type.
GetRawPlan is considered experimental and advanced functionality, and familiarity with the Terraform protocol is suggested when using it.
GetRawState returns the cty.Value that Terraform sent the SDK for the state. If no value was sent, or if a null value was sent, the value will be a null value of the resource's type.
GetRawState is considered experimental and advanced functionality, and familiarity with the Terraform protocol is suggested when using it.
HasChange checks to see if there is a change between state and the diff, or in the overridden diff.
HasChanges returns whether or not any of the given keys has been changed.
Id returns the ID of this resource.
Note that technically, ID does not change during diffs (it either has already changed in the refresh, or will change on update), hence we do not support updating the ID or fetching it from anything else other than state.
NewValueKnown returns true if the new value for the given key is available as its final value at diff time. If the return value is false, this means either the value is based of interpolation that was unavailable at diff time, or that the value was explicitly marked as computed by SetNewComputed.
SetNew is used to set a new diff value for the mentioned key. The value must be correct for the attribute's schema (mostly relevant for maps, lists, and sets). The original value from the state is used as the old value.
This function is only allowed on computed attributes.
SetNewComputed functions like SetNew, except that it blanks out a new value and marks it as computed.
This function is only allowed on computed attributes.
UpdatedKeys returns the keys that were updated by this ResourceDiff run. These are the only keys that a diff should be re-calculated for.
This is the combined result of both keys for which diff values were updated for or cleared, and also keys that were flagged to be re-diffed as a result of ForceNew.
Internal validation of provider implementation
SchemaMap returns the schema information for this resource identity defined via the SchemaFunc field.
Function signature for an identity schema version upgrade handler.
The Context parameter stores SDK information, such as loggers. It also is wired to receive any cancellation from Terraform such as a system or practitioner sending SIGINT (Ctrl-c).
The map[string]interface{} parameter contains the previous identity schema version data for a managed resource instance. The keys are top level attribute names mapped to values that can be type asserted similar to fetching values using the ResourceData Get* methods:
In certain scenarios, the map may be nil, so checking for that condition upfront is recommended to prevent potential panics.
The interface{} parameter is the result of the Provider type ConfigureFunc field execution. If the Provider does not define a ConfigureFunc, this will be nil. This parameter is conventionally used to store API clients and other provider instance specific data.
The map[string]interface{} return parameter should contain the upgraded identity schema version data for a managed resource instance. Values must align to the typing mentioned above.
ResourceImporter defines how a resource is imported in Terraform. This can be set onto a Resource struct to make it Importable. Not all resources have to be importable; if a Resource doesn't have a ResourceImporter then it won't be importable.
"Importing" in Terraform is the process of taking an already-created resource and bringing it under Terraform management. This can include updating Terraform state, generating Terraform configuration, etc.
InternalValidate should be called to validate the structure of this importer. This should be called in a unit test.
Resource.InternalValidate() will automatically call this, so this doesn't need to be called manually. Further, Resource.InternalValidate() is automatically called by Provider.InternalValidate(), so you only need to internal validate the provider.
type ResourceTimeout struct { Create, Read, Update, Delete, Default *time.Duration }
ConfigDecode takes a schema and the configuration (available in Diff) and validates, parses the timeouts into `t`
DiffEncode, StateEncode, and MetaDecode are analogous to the Go stdlib JSONEncoder interface: they encode/decode a timeouts struct from an instance diff, which is where the timeout data is stored after a diff to pass into Apply.
StateEncode encodes the timeout into the ResourceData's InstanceState for saving to state
Schema describes the structure and type information of a value, whether sourced from configuration, plan, or state data. Schema is used in Provider and Resource types (for managed resources and data resources) and is fundamental to the implementations of ResourceData and ResourceDiff.
The Type field must always be set. At least one of Required, Optional, Optional and Computed, or Computed must be enabled unless the Schema is directly an implementation of an Elem field of another Schema.
Returns a default value for this schema by either reading Default or evaluating DefaultFunc. If neither of these are defined, returns nil.
func (s *Schema) ZeroValue() interface{}
Returns a zero value for the schema.
type SchemaConfigMode int
SchemaConfigMode is used to influence how a schema item is mapped into a corresponding configuration construct, using the ConfigMode field of Schema.
type SchemaDefaultFunc func() (interface{}, error)
SchemaDefaultFunc is a function called to return a default value for a field.
EnvDefaultFunc is a helper function that returns the value of the given environment variable, if one exists, or the default value otherwise.
MultiEnvDefaultFunc is a helper function that returns the value of the first environment variable in the given list that returns a non-empty value. If none of the environment variables return a value, the default value is returned.
SchemaDiffSuppressFunc is a function which can be used to determine whether a detected diff on a schema element is "valid" or not, and suppress it from the plan if necessary.
Return true if the diff should be suppressed, false to retain it.
type SchemaSetFunc func(interface{}) int
SchemaSetFunc is a function that must return a unique ID for the given element. This unique ID is used to store the element in a hash.
HashResource hashes complex structures that are described using a *Resource. This is the default set implementation used when a set's element type is a full resource.
HashSchema hashes values that are described using a *Schema. This is the default set implementation used when a set's element type is a single schema.
type SchemaStateFunc func(interface{}) string
SchemaStateFunc is a function used to convert some type to a string to be stored in the state.
SchemaValidateDiagFunc is a function used to validate a single field in the schema and has Diagnostic support.
SchemaValidateFunc is a function used to validate a single field in the schema.
Deprecated: please use SchemaValidateDiagFunc
Set is a set data structure that is returned for elements of type TypeSet.
func CopySet(otherSet *Set) *Set
CopySet returns a copy of another set.
NewSet is a convenience method for creating a new set with the given items.
func (s *Set) Add(item interface{})
Add adds an item to the set if it isn't already in the set.
func (s *Set) Contains(item interface{}) bool
Contains checks if the set has the given item.
Difference performs a set difference of the two sets, returning a new third set that has only the elements unique to this set.
func (s *Set) Equal(raw interface{}) bool
func (s *Set) HashEqual(raw interface{}) bool
HashEqual simply checks to the keys the top-level map to the keys in the other set's top-level map to see if they are equal. This obviously assumes you have a properly working hash function - use HashResource if in doubt.
Intersection performs the set intersection of the two sets and returns a new third set.
Len returns the amount of items in the set.
func (s *Set) List() []interface{}
List returns the elements of this set in slice format.
The order of the returned elements is deterministic. Given the same set, the order of this will always be the same.
func (s *Set) Remove(item interface{})
Remove removes an item if it's already in the set. Idempotent.
Union performs the set union of the two sets and returns a new third set.
StateContextFunc is the function called to import a resource into the Terraform state. It is given a ResourceData with only ID set. This ID is going to be an arbitrary value given by the user and may not map directly to the ID format that the resource expects, so that should be validated.
This should return a slice of ResourceData that turn into the state that was imported. This might be as simple as returning only the argument that was given to the function. In other cases (such as AWS security groups), an import may fan out to multiple resources and this will have to return multiple.
To create the ResourceData structures for other resource types (if you have to), instantiate your resource and call the Data function.
ImportStatePassthroughWithIdentity creates a StateContextFunc that supports both identity-based and ID-only resource import scenarios. This function is useful when a resource can be imported either by its unique ID or by an identity attribute.
The `idAttributePath` parameter specifies the name of the identity attribute to use when importing by identity. Since identity attributes are "flat", `idAttributePath` should be a simple attribute name (e.g., "name" or "identifier"). Note that the identity attribute must be a string, as this function expects to set the resource ID using the value of the specified attribute.
If the resource is imported by ID (i.e., `d.Id()` is already set), the function simply returns the resource data as-is. Otherwise, it attempts to retrieve the identity attribute specified by `idAttributePath` and sets it as the resource ID.
Parameters:
Returns:
StateFunc is the function called to import a resource into the Terraform state.
Deprecated: Please use the context aware equivalent StateContextFunc.
See Resource documentation.
Function signature for a schema version state upgrade handler.
The Context parameter stores SDK information, such as loggers. It also is wired to receive any cancellation from Terraform such as a system or practitioner sending SIGINT (Ctrl-c).
The map[string]interface{} parameter contains the previous schema version state data for a managed resource instance. The keys are top level attribute or block names mapped to values that can be type asserted similar to fetching values using the ResourceData Get* methods:
In certain scenarios, the map may be nil, so checking for that condition upfront is recommended to prevent potential panics.
The interface{} parameter is the result of the Provider type ConfigureFunc field execution. If the Provider does not define a ConfigureFunc, this will be nil. This parameter is conventionally used to store API clients and other provider instance specific data.
The map[string]interface{} return parameter should contain the upgraded schema version state data for a managed resource instance. Values must align to the typing mentioned above.
Implementation of a single schema version state upgrade.
StringKind represents the format a string is in.
See Resource documentation.
Deprecated: Please use the context aware equivalents instead.
ValidateRawResourceConfigFunc is a function used to validate the raw resource config and has Diagnostic support. it is only valid for Managed Resource types and will not be called for Data Resource or Block types.
type ValidateResourceConfigFuncRequest struct { WriteOnlyAttributesAllowed bool RawConfig cty.Value }
type ValidateResourceConfigFuncResponse struct { Diagnostics diag.Diagnostics }
ValueType is an enum of the type that can be represented by a schema.
const ( TypeInvalid ValueType = iota TypeBool TypeInt TypeFloat TypeString TypeList TypeMap TypeSet )
Zero returns the zero value for a type.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4