What is the main reason to use mock providers when writing tests for Terraform modules?
Think about why you might want to avoid real cloud calls in tests.
Mock providers simulate cloud provider responses so tests run quickly and safely without creating real resources or incurring costs.
Which Terraform configuration snippet correctly defines a mock provider for testing?
Look for the standard way to specify provider version in Terraform.
Terraform providers are declared with a provider block and a version constraint. The other options use invalid attributes.
When using a mock provider in Terraform tests, what is the expected behavior during terraform plan and terraform apply?
Consider what mock means in testing context.
Mock providers simulate resource creation and state changes without real cloud interaction, so plan and apply succeed but do not affect real infrastructure.
What is a key security advantage of using mock providers when testing Terraform modules?
Think about what happens if tests use real providers with credentials.
Mock providers avoid real cloud calls, so real credentials are not used or exposed during tests, reducing risk.
In a Terraform test using a mock provider, if the mock provider returns resource attributes that do not match the module's expected schema, what is the likely outcome?
Consider how Terraform validates resource data during plan and apply.
Terraform validates resource attributes against the provider schema. Mismatches cause errors to prevent invalid state.