-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Standardizing the Use of Coupled Attributes in Terraform Configuration #35749
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
TL;DR
We need to standardize the use of coupled attributes in Terraform configuration, considering scenarios where users may expect outcomes that diverge from their configurations. While Terraform's declarative approach typically aims for perfect convergence between user configurations and actual outcomes, the flexibility of partial configurations and the abstraction of cloud services necessitate a nuanced approach. Intentional use of coupled attributes provide users with access to both their configured values and the precise outcomes, enhancing flexibility and precision in complex systems.
Definition
"Coupled attributes" are two or more Terraform provider attributes that relate to a single aspect of configuration but provide differing views. They are useful where users reasonably anticipate valid outcomes that deviate from their configurations. For example, imagine a Terraform provider allows a user to configure the
version
of a database engine. In some situations, the user may want to abstract away some detail by providing only the major version. In other situations, the user provides a detailed version. Regardless, the user also wants to know the details of the resulting configuration and checks the coupled attribute,version_actual
, to find out the exact version AWS selected.Goal
We need to standardize the use of coupled attributes in Terraform configuration defining:
Why not use coupled attributes
Although we propose that there are valid reasons for using couple attributes, there are also good reasons to not use them:
Why use coupled attributes
At the core of Terraform's declarative approach lies the expectation that user configurations precisely match the resulting outcomes. However, this notion encounters limitations when dealing with partial configurations and the inherent abstraction of cloud services. Users often define only key aspects of their desired outcomes, relying on the Terraform provider and associated cloud service to fill in the gaps as necessary, such as with optional arguments. Additionally, users frequently receive feedback--"output"--on specific details of the outcome, including information that may not have been directly configured.
While a single attribute aligns well with scenarios where user-configured values are expected to perfectly converge with actual outcomes, it falls short in situations where users provide imprecise information and anticipate precision in outcomes. For instance, users may request a major version (such as "8.0") of a database from a cloud provider, expecting a more precise version number (such as "8.0.44") in return. A single "version" attribute, computed and optional, does not adequately capture this expectation, leading to discrepancies between original configured value and actual value.
In complex systems where resources depend on each other and precision is paramount, users should have the flexibility to connect dependencies to either the original configured value or the actual value. Coupled attributes offer a solution by providing users with access to both their configured values and the precise outcomes, enhancing flexibility and precision in configuration management.
Because coupled attributes can lead to messy configurations, they should be used sparingly and only in situations where a user, in reasonable circumstances, expects additional information to be returned.
In addition, coupled attributes should not be used as a workaround for API bugs. For example, if the API expects a setting to be in all caps, such as "RADIAL_PATTERN," but returns the settings in all lowercase, "radial_pattern," using coupled attributes to workaround this glitch is a bad idea. It confuses a user, leads to unnecessary clutter, and is not based on a user's reasonable expectation of additional information. Instead, rather than coupled attributes, we should pursue other workarounds and bug fixes in the API.
Proposal
We propose adopting coupled attributes in scenarios where cloud services allow users to imprecisely define configurations, and users reasonably expect outcomes to deviate from their initial configurations. By incorporating coupled attributes into Terraform configuration standards, users gain greater control over their configurations and ensure alignment with actual outcomes.
Current usage and examples
While coupled attributes already exist for some arguments, they currently follow different naming standards, highlighting the need for standardization and consistent implementation across Terraform configurations.
Below are examples of coupled attributes and the basic pattern of naming:
version
version_actual
version
effective_version
version
version_returned
version
version_api_value
initial_version
version
version
effective_version
References
The text was updated successfully, but these errors were encountered: