Menu

1 / 4

Terraform Import: Import Blocks, Commands and ID Formats

DEV Community: terraform·Michael Zion·about 11 hours ago
#A2FsLpYa
#devtoterraform#devto#dev#import#terraform
Reading 0:00
15s threshold

Terraform import does 1 thing: it ties a resource that already exists to an address in your Terraform state.

Bottom line

Use an import block. It has been in Terraform since 1.5 (June 2023), it shows up in terraform plan , and it goes through a pull request like any other change.

import { to = aws_s3_bucket . assets id = "my-company-assets" }

resource "aws_s3_bucket" "assets" { bucket = "my-company-assets" }

Enter fullscreen mode

Exit fullscreen mode

Run terraform plan . The line you want to see:

Plan: 1 to import, 0 to add, 0 to change, 0 to destroy.

Enter fullscreen mode

Exit fullscreen mode

Then run terraform apply . With that plan line, nothing changes in your cloud account.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.