You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when using a mock provider in Terraform tests (e.g., mock_provider "aws" {}), the entire provider is mocked. This approach is limiting in certain situations where logic is being computed directly in a data block. It would be great to add functionality to selectively exclude specific resources or data sources from being mocked within a mock provider.
Testing Custom Logic in Data Sources: Some data sources contain custom logic that a user may want to test directly. For example:
Inline Logic Data Sources: Certain data sources, like the aws provider iam_policy_document do not perform external lookups but instead use the data block construct to define inline logic. It would be very useful often want to test and validate this logic directly in Terraform tests.
Add a new configuration option within the mock_provider block to specify resources or data sources that should be excluded from mocking. This could be implemented in multiple ways:
Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!
Terraform Version
Use Cases
Currently, when using a mock provider in Terraform tests (e.g., mock_provider "aws" {}), the entire provider is mocked. This approach is limiting in certain situations where logic is being computed directly in a data block. It would be great to add functionality to selectively exclude specific resources or data sources from being mocked within a mock provider.
iam_policy_document
do not perform external lookups but instead use the data block construct to define inline logic. It would be very useful often want to test and validate this logic directly in Terraform tests.https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document
Attempted Solutions
N/A.
Proposal
Add a new configuration option within the mock_provider block to specify resources or data sources that should be excluded from mocking. This could be implemented in multiple ways:
Option 1
Option 2
References
No response
The text was updated successfully, but these errors were encountered: