Import ForEach: Prerequisite - Prepare codebase for dynamic addresses for ImportTargets (#1207)

Signed-off-by: RLRabinowitz <rlrabinowitz2@gmail.com>
This commit is contained in:
Arel Rabinowitz
2024-02-08 16:05:12 +02:00
committed by GitHub
parent f92ae16419
commit 80f72cecfe
15 changed files with 552 additions and 254 deletions

View File

@@ -14,8 +14,6 @@ import (
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclsyntax"
"github.com/zclconf/go-cty/cty"
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/command/arguments"
@@ -238,11 +236,10 @@ func (c *ImportCommand) Run(args []string) int {
newState, importDiags := lr.Core.Import(lr.Config, lr.InputState, &tofu.ImportOpts{
Targets: []*tofu.ImportTarget{
{
Addr: addr,
// In the import block, the ID can be an arbitrary hcl.Expression,
// but here it's always interpreted as a literal string.
ID: hcl.StaticExpr(cty.StringVal(args[1]), configs.SynthBody("import", nil).MissingItemRange()),
CommandLineImportTarget: &tofu.CommandLineImportTarget{
Addr: addr,
ID: args[1],
},
},
},