From ad28ed0e3b7a0ca4a49bd04f9f2ae0fa0be9b0b3 Mon Sep 17 00:00:00 2001 From: Katy Moe Date: Wed, 8 Jul 2020 18:37:52 +0100 Subject: [PATCH] implement Import --- tfexec/terraform.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tfexec/terraform.go b/tfexec/terraform.go index 97d745ad..5ce02bc7 100644 --- a/tfexec/terraform.go +++ b/tfexec/terraform.go @@ -498,6 +498,20 @@ func (opt *VarFileOption) configureImport(conf *importConfig) { conf.varFile = opt.path } +func (t *Terraform) Import(ctx context.Context, opts ...ImportOption) error { + importCmd := t.ImportCmd(ctx, opts...) + + var errBuf strings.Builder + importCmd.Stderr = &errBuf + + err := importCmd.Run() + if err != nil { + return parseError(errBuf.String()) + } + + return nil +} + type outputConfig struct { state string json bool