helper/resource: Remove data source and resource id
attribute requirement
#164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #84
The resource instance state identifier was a Terraform versions 0.11 and earlier concept which helped core and the then SDK determine if the resource should be removed and as an identifier value in the human readable output. This concept unfortunately carried over to the testing logic when the testing logic was mostly changed to use the public, machine-readable JSON interface with Terraform, rather than reusing prior internal logic from Terraform. Using the
id
attribute value for this identifier was the default implementation and therefore those older versions of Terraform required the attribute. This is no longer necessary after Terraform versions 0.12 and later. This testing logic only supports Terraform version 0.12.26 and later.The remaining resource instance identifier and
id
attribute usage in the testing logic was:TestStep
typeImportStateVerify
field is enabled, the instance state identifier between prior resource state and import resource state are compared to find the correct resource.TestStep
typeImportStateIdFunc
andImportStateId
fields are empty as the import ID for callingterraform import
command.terraform
package referencesFor the first case, a new
TestStep
typeImportStateVerifyIdentiferAttribute
field is added, which defaults to the priorid
attribute. This preserves the existing behavior while enabling developers to choose a different identifier attribute if omitted from the resource so they can still use theImportStateVerify
functionality.For the second case, developers can use the
ImportStateId*
fields to choose/create the correct import identifier value.For the final cases, no action is needed as the
terraform
package is not intended for external usage and any usage of this identifier is mainly for equality and printing debugging information which is not accessed by the testing logic. These functions will be marked with Go documentation deprecation comments in a subsequent change.