Terraform error: Unclosed configuration block

HCL blocks such as resource, module and variable, and map values such as tags = { }, must close every { with a }. Terraform reached the end of the file with a block still open. It reports the block where the opening brace is, but the missing brace is often inside it: here the } meant for resource actually closed tags. PasteKit names the open block and the line it starts on.

Seen as:

  • Error: Unclosed configuration block
  • There is no closing brace for this block before the end of the file. This may be caused by incorrect brace nesting elsewhere in this file.
  • Error: Argument or block definition required
  • Error: Missing newline after argument

Input

Settings

History

Load from URL

Common causes

1. A map or object value missing its brace

A tags = { without its own } steals the brace of the enclosing block. Indentation makes this easy to spot once the file is formatted.

Before
resource "aws_s3_bucket" "logs" {
  tags = {
    Team = "platform"
}
After
resource "aws_s3_bucket" "logs" {
  tags = {
    Team = "platform"
  }
}

2. A block cut short when copying

Copying a resource from documentation or another module often leaves out the last line. Each nested block (lifecycle, ingress, dynamic) needs its own closing brace too.

Before
resource "aws_security_group" "web" {
  ingress {
    from_port = 443
    to_port   = 443
  }
After
resource "aws_security_group" "web" {
  ingress {
    from_port = 443
    to_port   = 443
  }
}

3. An unterminated string

A missing closing quote makes the string run past the brace, so Terraform never sees the }. Close the quote and the brace reappears.

Before
variable "region" {
  default = "eu-west-1
}
After
variable "region" {
  default = "eu-west-1"
}

4. An unclosed ${ interpolation

Inside a string, ${ opens a template expression that needs its own }. Without it, the rest of the file is read as part of the expression.

Before
locals {
  name = "${var.env-app"
}
After
locals {
  name = "${var.env}-app"
}

Frequently asked questions

How do I find which brace is missing?

Format the file: once braces are unbalanced, the indentation of the closing lines stops matching the openings. terraform fmt refuses invalid files, but PasteKit points at the block that is still open.

What does "Argument or block definition required" mean?

Terraform found something at the top level of a body that is neither name = value nor a block, often a stray closing brace or text left after an edit. It is the mirror image of an unclosed block.

Does this apply to .tfvars and Packer files?

Yes. They use the same HCL syntax, so braces, quotes and interpolations must be balanced in exactly the same way.

Related