Terraform import resource into state file in GitLab

Hello Dear All,

Any suggestions how resource can be imported into remote state file using GitLab pipeline?

We are using following approach, unfortunately with an error.


Same “importing” approach using locally works fine.

Thank you

I wouldn’t expect an import command to be in any form of automated pipeline. Import should only ever be needed once, if an existing resource is to be taken over for management by Terraform. Once that has been done the details will be in the state file and nothing further is needed.

Thank you, but our use case needs such implementation.

Finally, we have managed it.