Which modules are checked
Switching the root module to the compliance.tf provider for AWS does not switch its child modules. This page explains which resources the provider sees, why a module that requires hashicorp/aws is not checked, and how to handle such modules. It is for platform leads planning a rollout, and for engineers who expected a warning that never came.
Where it acts
Terraform installs one provider per source address, and each module names the source it needs in its own required_providers. A child module that asks for hashicorp/aws gets hashicorp/aws, even when the root module uses registry.compliance.tf/compliancetf/aws. The compliance.tf provider never sees that module's resources, so it cannot check them.
The parts
| Where the resource is | Which provider runs it | Checked |
|---|---|---|
| The root module | compliancetf/aws | yes |
A child module that requires registry.compliance.tf/compliancetf/aws | compliancetf/aws | yes |
A child module that requires hashicorp/aws, such as every terraform-aws-modules module | hashicorp/aws | no |
A child module that declares no aws provider requirement | hashicorp/aws: Terraform reads its aws_* resources as needing hashicorp/aws | no |
An in-house module that lists hashicorp/aws or declares nothing falls in the last two rows. Run terraform providers to see which provider each module gets.
What changes in your workflow
Pick one option per module.
Switch a module you own
Add the compliance.tf provider to the module's own required_providers:
terraform {
required_providers {
aws = {
source = "registry.compliance.tf/compliancetf/aws"
}
}
}The module's resources then use the root module's compliancetf/aws configuration and are checked.
Use the compliance.tf modules
For terraform-aws-modules, change the module source to the version compliance.tf serves for your framework, for example soc2.compliance.tf/terraform-aws-modules/s3-bucket/aws. Those modules carry their controls inside the module, and a violation fails the plan without the provider. See Registry endpoints and the Migration kit.
Keep a module on hashicorp/aws
To leave a module unchecked, give it its own hashicorp/aws configuration. Add hashicorp/aws under a second local name, and copy the settings of your main provider block (region, profile, assume_role and so on) into a block for that name:
terraform {
required_providers {
aws = {
source = "registry.compliance.tf/compliancetf/aws"
version = "6.70.0"
}
aws-upstream = {
source = "hashicorp/aws"
version = "6.70.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
provider "aws-upstream" {
region = "us-east-1"
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
# no providers argument
}A module that requires hashicorp/aws and has no providers argument uses the default hashicorp/aws configuration of its parent, here the aws-upstream block. Terraform and OpenTofu print a "Duplicate required provider" warning for this layout; each block is used for its own provider. Resources in those modules stay unchecked.
Do not pass a providers argument to such a module. Mapping its aws to a configuration of the root module fails with "Provider type mismatch":
providers = { aws = aws }fails because the rootawsis compliancetf/aws.providers = { aws = aws-upstream }, or an alias of it, fails too.
Remove the argument. Only the default aws-upstream configuration reaches such modules.
Going back
To take a whole configuration back to hashicorp/aws, set every compliancetf/aws source back, root module and child modules alike, then follow Undo it in each state. terraform state replace-provider has no module filter, so move a configuration back as a whole, not one module at a time.