Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Data-driven Terraform Configuration #4961

Closed
wants to merge 10 commits into from
Closed

Conversation

apparentlymart
Copy link
Contributor

@apparentlymart apparentlymart commented Feb 2, 2016

This is where I'm working on the implementation of the proposal from #4169.

  • DataSource type in the config module
  • Loading of data blocks from configuration files
  • Validation of data blocks
  • Interpolation variables of the form data.TYPE.NAME.ATTR, with the same multi-capabilities as resources
    • Parsing (in config package)
    • Resolving (in terraform package)
  • Introduction of data sources in the main terraform module
  • New RefreshData method on the ResourceProvider interface
  • RefreshData support in helper/schema
  • Graph node and eval implementations for data sources:
    • Refresh
    • Plan
    • Apply
  • Change resource count implementation to allow any non-computed variable, which will then include attributes of any data instances that do not depend on resource creation
  • Backward-compatibility shim in helper/schema, allowing specific data source implementations to be aliased as resource implementations
    • terraform_remote_state data source based on the existing resource, as an initial example
    • Deprecation warning when using shimmed data sources as resources
  • User-oriented documentation

@apparentlymart
Copy link
Contributor Author

@phinze here's the same changeset but in the main repo. Feel free to pick up the reins!

I'll check in here again when things calm down for me and see if there's anything I can do to help finish this up.

@phinze
Copy link
Contributor

phinze commented Feb 2, 2016

Thanks @apparentlymart! Will dig in soon.

@stack72
Copy link
Contributor

stack72 commented Feb 3, 2016

after @jen20 explained what this means, I am very excited to see it - this will mean that I can ditch so many custom modules that do lookups :)

@phinze phinze changed the title Data-driven Terraform Configuration [WIP] Data-driven Terraform Configuration Feb 9, 2016
@phinze phinze removed the wip label Feb 9, 2016
@nickithewatt
Copy link
Contributor

This functionality is much required and looking forward to it! Do we have any rough release that we think this will make it into?

@phinze
Copy link
Contributor

phinze commented Feb 29, 2016

@nickithewatt We're currently targeting 0.7 - Terraform's next major release.

Not sure on the timeline quite yet, but suffice it to say this one is high on our list of core improvements!

This represents a data source configuration.
This allows the config loader to read "data" blocks from the config and
turn them into DataSource objects.

This just reads the data from the config file. It doesn't validate the
data nor do anything useful with it.
This will undoubtedly evolve as implementation continues, but this is some
initial documentation based on the design doc.
This is a breaking change to the ResourceProvider interface to add the
new new methods DataSources and RefreshData, which are the two provider
functions related to data sources.

Along with breaking the interface, we also fix up the RPC client/server
and helper/schema implementations of it, which are all of the callers
used when provider plugins use helper/schema. This would be a breaking
change for any provider plugin that directly implements the provider
interface, but no known plugins do this and it is not recommended.

The helper/schema implementation is currently a no-op stub which will be
elaborated in a later change.
The namespaces of data sources and resources are separate, but at this
layer they both share the "Resource" implementation, with data sources
differing from resources only in that they are not permitted to provide
Create, Update or Delete implementations.
This is a further breaking change to the ResourceProvider interface, and
the updates to all of its significant implementations to support the new
method.
In the "schema" layer a Resource is just any "thing" that has a schema
and supports some or all of the CRUD operations. Data sources introduce
a new use of Resource to represent read-only resources, which require
some different InternalValidate logic.
Historically we've had some "read-only" and "logical" resources. With the
addition of the data source concept these will gradually become data
sources, but we need to retain backward compatibility with existing
configurations that use the now-deprecated resources.

This shim is intended to allow us to easily create a resource from a
data source implementation. It adjusts the schema as needed and adds
stub Create and Delete implementations.

This would ideally also produce a deprecation warning whenever such a
shimmed resource is used, but the schema system doesn't currently have
a mechanism for resource-specific validation, so that remains just a TODO
for the moment.
As a first example of a real-world data source, the pre-existing
terraform_remote_state resource is adapted to be a data source. The
original resource is shimmed to wrap the data source for backward
compatibility.
This allows ${data.TYPE.NAME.FIELD} interpolation syntax at the
configuration level, though there is not yet any implementation of
resolving these things in the core package.
@apparentlymart apparentlymart deleted the data-sources branch April 30, 2016 22:19
@apparentlymart
Copy link
Contributor Author

I rebased this onto the dev-0.7 branch and started a new PR #6430. Follow me over there, if you'd like! 😀

@ghost
Copy link

ghost commented Apr 26, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants