Sign in
Menu
Sign up
Docs

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.

Which modules the provider checks Resources in the root module and in child modules that require compliancetf/aws run through compliancetf/aws and are checked; terraform-aws-modules and in-house modules that require hashicorp/aws or declare no aws provider run through hashicorp/aws and are not checked. Where the resource is Provider that runs it Root moduleresources you write in the root Child module you ownrequires compliancetf/aws terraform-aws-modulesrequires hashicorp/aws In-house moduledeclares no aws provider compliancetf/awsresources are checked hashicorp/awsresources are not checked

The parts

Where the resource isWhich provider runs itChecked
The root modulecompliancetf/awsyes
A child module that requires registry.compliance.tf/compliancetf/awscompliancetf/awsyes
A child module that requires hashicorp/aws, such as every terraform-aws-modules modulehashicorp/awsno
A child module that declares no aws provider requirementhashicorp/aws: Terraform reads its aws_* resources as needing hashicorp/awsno

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 root aws is 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.

Next steps

On this page

Ask AI about this

Help improve this page