mock provider
A fake version of a provider, declared with mock_provider in a test file, that returns made-up values instead of calling a real API.
In more detail
Added in Terraform 1.7, it lets tests run without cloud credentials, cost or waiting. Mocks check your module's logic, not whether the real service would accept the values, so keep a few tests against real infrastructure too.
Example
mock_provider "aws" {}Related terms
- terraform test — The command, added in Terraform 1.6, that runs the scenarios in .tftest.hcl files against a module and reports which assertions passed.
- .tftest.hcl file — A test file for terraform test, written in HCL, containing run blocks that exercise a module and assert blocks that check the results.
- provider — A plugin that teaches Terraform how to talk to one API, such as AWS or your local disk, and which resource types it offers.
Taught in
- Running Terraform In CI — Infrastructure as Code with Terraform
- Native Testing With Tftest Files — Infrastructure as Code with Terraform
- Provider Mocking For Tests — Infrastructure as Code with Terraform
- Policy As Code With OPA — Infrastructure as Code with Terraform
- Releasing The Real Cloud Artifact — Infrastructure as Code with Terraform