Terraform 1.5 Import Block: Eliminate Manual Imports and Streamline IaC

26 / May / 2025 by Karandeep Singh 0 comments

Introduction

We know that sometimes the cloud infrastructure is already set up before we start using Terraform. Traditionally, if we wanted to import these resources into Terraform and control them, we had to run some manual import commands. It was a pain and made it tricky to keep things smooth when working in a collaborative environment.

Well, Terraform 1.5 fixed that with this new feature called the terraform import block. Now you can just add the imports right inside your Terraform files, no extra manual steps, no extra import commands. It makes managing existing resources way easier and helps teams work together better. Honestly, it’s a pretty cool update for anyone doing infrastructure as code.

terraform import

terraform import

 

In this brief blog, I’m going to walk you through how to use the new import block feature that came out in the Terraform 1.5 release. We’ll also take a look at how it compares to the older terraform import command. To keep things simple, I’ll use an AWS S3 bucket as the example and show you how both methods work.

Why Terraform Import Can Be Frustrating

If you’ve ever used the terraform import command, you probably know it comes with a few headaches:

  • No Plan Preview: When we run the import command, it just updates the Terraform state directly, without giving you a chance to see what’s about to change. That’s risky, especially when working with a team.
  • One at a Time: Only one resource is imported at a time, which is a pain if you’ve got a bunch of stuff to bring under Terraform’s control. This can take days to weeks in-order to bring fully- fledged running environment under terraform control.

Prerequisites:

  • Terraform 1.5 or later
  • AWS CLI configured with appropriate access
  • S3 bucket created already.

Scenario:

We already have an S3 bucket created manually in the AWS account (e.g., my-existing-s3-demo-bucket). Our aim here is to manage this bucket using Terraform without recreating it. We will see how we can do this. First, let’s explore the old method, i.e., the terraform import command.

Step 1: Older Method – terraform import

  • Define a Terraform configuration file like this:
provider "aws" {
  region = "us-west-2"
}

resource "aws_s3_bucket" "existing_demo_bucket" {
  bucket = "my-existing-s3-demo-bucket"
}
  • Run terraform init to initialize the directory.

    terraform init

    terraform init

  • With the old method, we will use the CLI to import the existing S3 bucket into the Terraform state:
terraform import aws_s3_bucket.existing_demo_bucket my-existing-s3-demo-bucket
terraform import

terraform import

After importing, if we run terraform plan to see that the resource is now tracked by Terraform and is present inside the terraform state file.

terraform plan

terraform plan

Now, let’s explore the new method of bringing resources into the Terraform state with the newly launched Terraform import block. But before that, let’s clean up the state file and the Terraform configuration file.

cleanup

cleanup

Step 2: New Method – import block (Terraform 1.5+)

  • Add the import block directly in the Terraform configuration. In the Terraform import block, the “to” ( Terraform address of the resource in your configuration) and “id” (it tells Terraform which real resource to import) arguments are important for specifying what you’re importing and from where. For S3 buckets, the ID is simply the bucket name.
provider "aws" {
  region = "us-west-2"
}

resource "aws_s3_bucket" "existing_demo_bucket" {
  bucket = "my-existing-s3-demo-bucket"
}

import {
  to = aws_s3_bucket.existing_demo_bucket
  id = "my-existing-s3-demo-bucket"
}

 

  • Run terraform plan directly — no separate terraform import command is needed.
terraform plan

terraform plan

  • Terraform will automatically detect the import block and will try to bring the existing S3 bucket into state. To do so we have to run terraform apply and enter “yes”.

    terraform apply

    terraform appl

  • As we can see, Terraform successfully imported the S3 bucket into its state.

    terraform state list

    terraform state list

  • Once the resources are imported, we can safely remove the import block from the Terraform configuration files as the import is successful.

Benefits of using an import block:

  • It is declarative and part of the configuration.
  • Easier for teams and CI/CD pipelines — no more manual CLI commands.
  • Improves readability and version control of imports.
  • We can add multiple import blocks, which will result in saving time and effort.

Summary

Feature Terraform import CLI Terraform import block (1.5+)
Declarative  No  Yes
Part of the configuration  No  Yes
Supports CI/CD  No  Yes
Manual step required  Yes  No

Conclusion

With the introduction of the import block in Terraform v1.5, the process of safely importing unmanaged cloud resources without impacting live infrastructure has become more transparent, auditable, versioned, and collaboration-friendly. Use the import block if you’re using Terraform 1.5 or later — it’s cleaner, trackable, and simplifies automation. This feature simplifies your workflow and makes your configuration easier to manage, share, and review — perfect for modern IaC and CI/CD environments.

At TO THE NEW, we specialize in solving real-world DevOps challenges, from state management to large-scale infrastructure transformations on AWS, Azure, GCP, and other cloud providers. Whether you’re modernizing Terraform practices or planning a zero-downtime migration, our certified AWS architects and DevOps engineers are here to ensure your cloud journey is efficient, reliable, and future-proof.

Tip: If your team is automating infrastructure onboarding or migration, the import block will save you time and reduce manual steps.

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *