Skip to content

Conversation

@bbasata
Copy link
Collaborator

@bbasata bbasata commented Apr 15, 2025

This change allows explict inline Terraform configuration in an ImportState test step. In a newly-added test, we have a scenario where it's useful to the test author to write their own import block, without resorting to ConfigFile or ConfigDirectory.

This change also adds a test to cover the use of external providers with plannable import tests.

This change allows explict inline Terraform configuration in an
`ImportState` test step. In a newly-added test, we have a scenario where
it's useful to the test author to write their own import block, without
resorting to `ConfigFile` or `ConfigDirectory`.

This change also adds a test to cover the use of external providers with
plannable import tests.
@bbasata bbasata requested a review from a team as a code owner April 15, 2025 20:03
@bbasata bbasata added this to the v1.13.0 milestone Apr 15, 2025
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

{
ImportState: true,
ImportStateKind: r.ImportBlockWithID,
Config: configWithImportBlock,
Copy link
Member

@austinvalle austinvalle Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm my understanding, provider developers wouldn't need to use a config in this scenario to do this (if the ID needing to be explicitly defined), they could just use ImportStateId:

{
	ImportState:     true,
	ImportStateKind: r.ImportBlockWithID,
	ImportStateId:   "It was a dark and stormy night.",
	ResourceName:    "random_string.mystery_message",
	ImportPlanChecks: r.ImportPlanChecks{
		PreApply: []plancheck.PlanCheck{
			plancheck.ExpectKnownValue(
				"random_string.mystery_message",
				tfjsonpath.New("result"),
				knownvalue.StringExact("It was a dark and stormy night.")),
		},
	},
},

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ImportStateId

Nice catch. We could come up with a different example here so that it better models a situation that calls for an inline config.

@bbasata bbasata merged commit 2fd4c09 into main Apr 16, 2025
1 check passed
@bbasata bbasata deleted the external-providers branch April 16, 2025 02:21
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants