-
Notifications
You must be signed in to change notification settings - Fork 17
helper/resource: add ImportBlockWithResourceIdentity kind
#480
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
e96524f
Error on use of ImportStatePersist with plannable import
bbasata 12842ab
Error on use of ImportStateVerify with plannable import
bbasata 91b5a0c
Rename test functions for consistency and for running by pattern
bbasata 2456d71
Import block works for a resource with a dependency
bbasata ccff991
Simplify no-op action check
bbasata 35f3b06
Add prerelease changelog entries
bbasata 90f5656
Add a catch-up prerelease changelog entry
bbasata e472964
Refactor test provider functions
bbasata cde5001
Fix 'No changes. Your infrastructure matches the configuration.' fals…
bbasata 372066c
Log (or do not log) consistently
bbasata 526853c
Fix format string syntax
bbasata c2a5b46
helper/resource: add ImportBlockWithResourceIdentity kind
bbasata 971fa87
ImportBlockWithResourceIdentity requires Terraform 1.12.0+
bbasata 30f231c
ImportBlockWithResourceIdentity requires Terraform 1.12.0+
bbasata d64375f
ImportBlockWithResourceIdentity requires Terraform 1.12.0+
bbasata d32eeda
Add changelog entry
bbasata 836b3e6
Merge remote-tracking branch 'origin/main' into import-block-with-res…
bbasata dd2d50b
Update .changes/unreleased/NOTES-20250414-095537.yaml
bbasata 7847b70
Update helper/resource/testing.go
bbasata 9c6616f
Nicer version check
bbasata 33e8faf
Remove incidental test steps
bbasata 09e574a
Add type awareness to import block generating
bbasata 82377fd
fixup! Add type awareness to import block generating
bbasata e374f8e
Add more list types to example resource identity schema
bbasata bc1ba78
Merge remote-tracking branch 'origin/main' into import-block-with-res…
bbasata 20e4a75
Update ImportState tests that have inline config
bbasata f76430c
fixup! Update ImportState tests that have inline config
bbasata 3f8f2ca
Use the correct working directory for apply + show
bbasata 37a2c16
Fix identity values comparison when using ConfigFile
bbasata b5a1d3c
fixup! Fix identity values comparison when using ConfigFile
bbasata 1826a6c
fixup! Fix identity values comparison when using ConfigFile
bbasata 7fe7dac
Update .changes/unreleased/NOTES-20250414-095537.yaml
bbasata File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| kind: BREAKING CHANGES | ||
| body: 'importstate: `ImportStatePersist` and `ImportStateVerify` are not supported for plannable import (`ImportBlockWith*`) and will return an error' | ||
| time: 2025-04-04T17:06:56.900935-04:00 | ||
| custom: | ||
| Issue: "476" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| kind: BREAKING CHANGES | ||
| body: 'importstate: renamed `ImportStateWithId` to `ImportStateWithID` and renamed `ImportCommandWithId` to `ImportCommandWithID`.' | ||
| time: 2025-04-04T17:10:48.525611-04:00 | ||
| custom: | ||
| Issue: "465" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| kind: BUG FIXES | ||
| body: 'importstate: plannable import (`ImportBlockWith*`) fixed for a resource with a dependency' | ||
| time: 2025-04-04T17:07:34.428542-04:00 | ||
| custom: | ||
| Issue: "476" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| kind: NOTES | ||
| body: 'This alpha pre-release adds support for managed resource identity, which can be used with Terraform v1.12.0-beta1. Acceptance tests can use the `ImportBlockWithResourceIdentity` kind to exercise the import of a managed resource using its resource identity object values instead of using a string identifier.' | ||
| time: 2025-04-14T09:55:37.938453-04:00 | ||
| custom: | ||
| Issue: "480" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
helper/resource/importstate/import_block_for_resource_with_a_dependency_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright (c) HashiCorp, Inc. | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| package importstate_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-go/tfprotov6" | ||
| r "github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
| "github.com/hashicorp/terraform-plugin-testing/internal/testing/testprovider" | ||
| "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver" | ||
| "github.com/hashicorp/terraform-plugin-testing/tfversion" | ||
| ) | ||
|
|
||
| func TestImportBlockForResourceWithADependency(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| config := ` | ||
| resource "examplecloud_zone" "zone" { | ||
| name = "example.net" | ||
| } | ||
|
|
||
| resource "examplecloud_zone_record" "record" { | ||
| zone_id = examplecloud_zone.zone.id | ||
| name = "www" | ||
| } | ||
| ` | ||
| r.UnitTest(t, r.TestCase{ | ||
| TerraformVersionChecks: []tfversion.TerraformVersionCheck{ | ||
| tfversion.SkipBelow(tfversion.Version1_5_0), // ImportBlockWithID requires Terraform 1.5.0 or later | ||
| }, | ||
| ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ | ||
| "examplecloud": providerserver.NewProviderServer(testprovider.Provider{ | ||
| Resources: map[string]testprovider.Resource{ | ||
| "examplecloud_zone": examplecloudZone(), | ||
| "examplecloud_zone_record": examplecloudZoneRecord(), | ||
| }, | ||
| }), | ||
| }, | ||
| Steps: []r.TestStep{ | ||
| { | ||
| Config: config, | ||
| }, | ||
| { | ||
| ImportState: true, | ||
| ImportStateKind: r.ImportBlockWithID, | ||
| ResourceName: "examplecloud_zone_record.record", | ||
| }, | ||
| }, | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.