Automations
All questions related to Workflow Automation, AutomationEngine, and EdgeConnect, as well as integrations with various tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Terraform provider backend state

tarjei
Organizer

Hi!

I would like to import state of a set of configurations directly to my backend (s3 bucket / azurerm) but I cannot see any way of tweaking this.

Any suggestions?

2 REPLIES 2

sujit_k_singh
Champion

Hi @tarjei 

Terraform doesn’t support directly importing state into a backend (S3/AzureRM) outside of its normal workflow.

You have two options:

Configure the backend first → run terraform init → then terraform import (this writes directly to remote state)
Or import locally and migrate using terraform init -migrate-state

Backend is just storage — all state operations must go through Terraform CLI.

Refer this link for more details

How to Import Resources into a Remote State Managed by Terraform Cloud – HashiCorp Help Center

Thanks,

Sujit

Dynatrace Professional Certified

t_pawlak
Leader

Hi,

I agree with @sujit_k_singh here.

The remote backend, such as S3 or AzureRM, is only the storage layer for the Terraform state. Terraform does not support safely “pushing” or importing resources directly into the backend state file outside of the normal Terraform workflow.

The usual approach would be:

  1. Configure the backend first.
  2. Run terraform init
  3. Run terraform import or use import blocks.
  4. Let Terraform write the imported resources into the configured remote state.

Alternatively, if the import was already done locally, you can configure the remote backend afterwards and migrate the state with:

terraform init -migrate-state

So in short: don’t edit/upload the state manually to S3/AzureRM. Let Terraform CLI manage the state operations.

Featured Posts