Backend must be defined

I have a terragrunt project setup with a folder structure near identical of 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

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

As the error says, you must have a backend "s3" {} block in your Terraform code—that is, the .tf files. See

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

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

I’m running into the same issue and could use a pointer. I’m starting off with terragrunt-infrastructure-live-example and added s3 module The S3 module doesn’t have a default partial backend which is why i’m seeing the error. What’s the best way to declare it?

Create your own module that creates an S3 bucket (possibly using another module under the hood) and has a backend "..." {} block.

I would like use existing terraform modules on the community registry, rather then creating my own modules. From what I can see most of the AWS modules doesn’t have a default partial backend block. Jim is there a way i could use terragrunt to keep the backend DRY with community modules?

You can generate a on the fly with a hook.