Backend must be defined

terragrunt
#1

I have a terragrunt project setup with a folder structure near identical of https://github.com/gruntwork-io/terragrunt-infrastructure-live-example/blob/master/prod/terraform.tfvars for testing. When I run terragrunt init, I’m getting an error of You must define a backend block (it can be empty!). But the backend is defined in the terraform.tfvars. Do I also need to define it in something like backend.tf?

terragrunt = {
  # Configure Terragrunt to automatically store tfstate files in an S3 bucket
  remote_state {
    backend = "s3"
   ...
#2

As the error says, you must have a backend "s3" {} block in your Terraform code—that is, the .tf files. See https://github.com/gruntwork-io/terragrunt#motivation-1.

#3

Ah, but if all I’m looking to do is run all modules in a region, I don’t have to run terragrunt init from the root directory, and instead just use terragrunt plan-all

#4

The plan-all command will run init automatically in each module. That doesn’t change the fact that in each module you must have an empty backend "s3" {} block defined. Otherwise, Terraform won’t configure a backend at all.

1 Like