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

Terraform Plugin SDK V2 Changes Affecting Provider Code Development #14551

Closed
bflad opened this issue Aug 11, 2020 · 2 comments
Closed

Terraform Plugin SDK V2 Changes Affecting Provider Code Development #14551

bflad opened this issue Aug 11, 2020 · 2 comments
Labels
provider Pertains to the provider itself, rather than any interaction with AWS. technical-debt Addresses areas of the codebase that need refactoring or redesign.

Comments

@bflad
Copy link
Contributor

bflad commented Aug 11, 2020

Description

Version 2 of the Terraform Plugin SDK has been released and this codebase has been migrated to this newer version in order to support future enhancements such as:

  • Performing acceptance testing against Terraform 0.13
  • Gracefully interrupting Terraform operations (e.g. Control-c)
  • Allowing resources to provide warning messages in the Terraform user interface
  • Allowing schema validation to provide the file and line numbers of failing Terraform configuration source code

This type of change mostly affects open pull requests adjusting Go code import statements and new data sources/resources. The fix is generally just to update the SDK imports.

For example, given the previous code imports in a pull request:

	"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
	"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
	"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
	"github.com/hashicorp/terraform-plugin-sdk/terraform"

Can be replaced with their version 2 counterpart:

	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
	"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

Additionally, some version 1 code imports are now internalized. Given these previous imports:

	"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
	"github.com/hashicorp/terraform-plugin-sdk/helper/mutexkv"

They can be replaced with their internal counterpart:

	"github.com/terraform-providers/terraform-provider-aws/aws/internal/hashcode"
	"github.com/terraform-providers/terraform-provider-aws/aws/internal/mutexkv"

Some example errors when a pull request contains an older version of the SDK while the current code contains the newer version of the SDK includes:

cannot use headersConf() (value of type *"github.com/hashicorp/terraform-plugin-sdk/helper/schema".Set) as *"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema".Set value in argument to expandStringSet
cannot use testAccProviders (variable of type map[string]*schema.Provider) as map[string]"github.com/hashicorp/terraform-plugin-sdk/terraform".ResourceProvider value in struct literal
panic: gob: registering duplicate types for "*tfdiags.rpcFriendlyDiag": *tfdiags.rpcFriendlyDiag != *tfdiags.rpcFriendlyDiag

An automated bot response will occur for pull requests containing the old imports that are updated after today, however existing pull requests may require the import updates above.

References

@bflad bflad added the technical-debt Addresses areas of the codebase that need refactoring or redesign. label Aug 11, 2020
@ghost ghost added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Aug 11, 2020
@bflad bflad pinned this issue Aug 11, 2020
@bflad bflad removed bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Aug 11, 2020
@ghost ghost added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Aug 18, 2020
@bflad bflad added provider Pertains to the provider itself, rather than any interaction with AWS. hashibot/ignore and removed bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Aug 18, 2020
@bflad
Copy link
Contributor Author

bflad commented Sep 14, 2020

Closing as this does not need to remain open.

@bflad bflad closed this as completed Sep 14, 2020
@bflad bflad unpinned this issue Sep 15, 2020
brittandeyoung pushed a commit to brittandeyoung/terraform-provider-aws that referenced this issue Feb 24, 2021
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
provider Pertains to the provider itself, rather than any interaction with AWS. technical-debt Addresses areas of the codebase that need refactoring or redesign.
Projects
None yet
Development

No branches or pull requests

1 participant