-
Notifications
You must be signed in to change notification settings - Fork 50
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
HCPF-704: Fix Missing/Incorrect Resource-level project_id
Implementations
#522
HCPF-704: Fix Missing/Incorrect Resource-level project_id
Implementations
#522
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for Boundary.
Thanks for making the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good to me. I have a few questions about the location data and a request for one or more test to HCP Packer.
Squashed commit of the following: commit ba0cd45a6e7b2b51f439848c415890cfdabc823a Author: Aidan Mundy <[email protected]> Date: Mon Jun 5 20:50:23 2023 -0400 Final changes commit 18f6991 Author: Aidan Mundy <[email protected]> Date: Mon Jun 5 20:32:11 2023 -0400 Readd forcenew for resource commit fae8926 Author: Aidan Mundy <[email protected]> Date: Mon Jun 5 20:29:27 2023 -0400 Mark old fields as deprecated commit 14018b3 Author: Aidan Mundy <[email protected]> Date: Mon Jun 5 20:14:58 2023 -0400 Regen docs commit ca737a0 Author: Aidan Mundy <[email protected]> Date: Mon Jun 5 20:13:48 2023 -0400 Remove unnecessary HVN Peering fields
75ab87d
to
cc5f815
Compare
ForceNew: true, | ||
ValidateFunc: validation.IsUUID, | ||
Computed: true, | ||
Description: "The ID of the HCP project where the HVN route is located. Always matches the project ID in `hvn_link`. Setting this attribute is deprecated, but it will remain usable in read-only form.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, when computed
can this field be set in the resource even though when overwritten?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Computed
informs that the provider may calculate (or pull from API) a value for that attribute, usually for when it isn't provided by the user. However, even when it is provided by the user in the configuration, the provider is still able to override the value in two ways:
- In state only, by setting the value as part of the
Read
,Create
, orUpdate
steps.- This can cause TF to generate new plans every time
terraform apply
is called. - Maintains consistency between config and plans, but not state.
- This can cause TF to generate new plans every time
- In the planning process, by using
CustomizeDiff
- This can create a situation where changes to the configuration file don't result in a plan being generated.
- Maintains consistency between plans and state, but not config.
With the changes here, if the user provides a value for provider_id
, it will be ignored in the planning process using CustomizeDiff
and the provider will calculate the correct value from the required hvn_link
attribute, outputting it to provider_id
. This does create a situation where the configuration file could contain provider_id = "1234"
, but the value of {resource}.provider_id
is "abcd"
(or similar). However, this is acceptable because previously the field could cause errors/crashes/incorrect behavior, but that is now fixed alongside a deprecation warning from the CLI any time the attribute is manually set by the user and any downstream uses of {resource}.provider_id
in Terraform would generate a plan which will inform the user that the value has changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hcp packer channel resource code looks good considering the known issue that will be addressed in another PR. 👍🏼
Reflects deprecation of unused `hvn_2` attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done. LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you very much for working through this.
🛠️ Description
Fixes missing/incorrect resource-specific, resource-level
project_id
implementations for:hcp_packer_channel
hcp_azure_peering_connection
data.hcp_azure_peering_connection
hcp_hvn_route
hcp_vault_cluster_admin_token
loc
)hcp_consul_cluster_root_token
data.consul_agent_helm_config
hcp_boundary_cluster
Deprecates some unnecessary fields on some resources and data sources:
project_id
attribute is no longer settable forhcp_hvn_peering_connection
anddata.hcp_hvn_peering_connection
.hvn_1
and will now be automatically determined instead.project_id
field from the configuration for affected resources and data sources before the end of the deprecation period.project_id
attribute is no longer settable forhcp_hvn_route
anddata.hcp_hvn_route
.hvn_link
and will now be automatically determined instead.project_id
field from the configuration for affected resources and data sources before the end of the deprecation period.hvn_2
attribute is no longer settable fordata.hcp_hvn_peering_connection
.hvn_2
, which may result in unintended behavior or unexpected errors downstream. The value will now be populated automatically.hvn_2
attribute from the configuration for affected data sources before the end of the deprecation period.Also, minor code cleanliness changes for accessing the OrgID in some of the above (and some other) resources.
Modified resources and data sources may experience a minor regression with the following symptoms (Note: they may already experience these symptoms):
project_id
attribute was set at some point, but later removed from the configuration file, will continue to use the last known user-supplied value for the resource-levelproject_id
attribute, regardless of any provider-levelproject_id
value.project_id
attribute will use the provider-levelproject_id
value that was present when the resource was created. Updates to the provider-levelproject_id
will not affect these resources.This behavior is already present in some forms on some resources and data sources, and will be fixed in a later update. The regression is considered acceptable in this case because the missing/incorrect implementations for resource-level
project_id
s have undefined behavior that is potentially dangerous/destructive.🏗️ Acceptance tests
Output from acceptance testing:
I don't have an environment configured for running acceptance tests on the provider other than for HCP Packer. If someone else can run the remaining tests, that would be greatly appreciated.