Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configs: Emit a warning for backends in nested modules #26954

Merged
merged 1 commit into from Nov 18, 2020

Conversation

apparentlymart
Copy link
Member

Terraform considers backend configurations only in the root module, so any declarations in child modules are entirely ignored.

To avoid users mistakenly thinking that a root module backend configuration has taken effect, we'll now emit a warning about it. This is a warning rather than an error because it's reasonable to call a module that would normally be a root module instead as a child module when writing a wrapper module to handle integration testing.

Warning: Backend configuration ignored

  on child/nested-backend-config-child.tf line 2, in terraform:
   2:   backend "ignored" {}

The selected backend applies to the entire configuration, so Terraform expects
provider configurations only in the root module.

This is a warning rather than an error because it's sometimes convenient to
temporarily call a root module as a child module for testing purposes, but
this backend configuration block will have no effect.

This closes #25933, by giving better feedback that ignoring the child module backends is by design.

@codecov
Copy link

codecov bot commented Nov 18, 2020

Codecov Report

Merging #26954 (fb858ec) into master (b06db96) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted Files Coverage Δ
configs/config_build.go 81.81% <100.00%> (+2.65%) ⬆️
terraform/evaluate.go 53.30% <0.00%> (+0.41%) ⬆️
dag/marshal.go 54.79% <0.00%> (+1.36%) ⬆️

configs/config_build.go Outdated Show resolved Hide resolved
Terraform considers backend configurations only in the root module, so any
declarations in child modules are entirely ignored.

To avoid users mistakenly thinking that a root module backend
configuration has taken effect, we'll now emit a warning about it. This is
a warning rather than an error because it's reasonable to call a module
that would normally be a root module instead as a child module when
writing a wrapper module to handle integration testing.
@apparentlymart apparentlymart merged commit eed6b3c into master Nov 18, 2020
@apparentlymart apparentlymart deleted the f-backend-ignored-warning branch November 18, 2020 16:20
@ghost
Copy link

ghost commented Dec 19, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked as resolved and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend config has no effect in modules
2 participants