|
|
|
|
@ -8828,6 +8828,52 @@ module.child:
|
|
|
|
|
`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestContext2Apply_targetedResourceOrphanModule(t *testing.T) {
|
|
|
|
|
m := testModule(t, "apply-targeted-resource-orphan-module")
|
|
|
|
|
p := testProvider("aws")
|
|
|
|
|
p.ApplyFn = testApplyFn
|
|
|
|
|
p.DiffFn = testDiffFn
|
|
|
|
|
|
|
|
|
|
// Create a state with an orphan module
|
|
|
|
|
state := MustShimLegacyState(&State{
|
|
|
|
|
Modules: []*ModuleState{
|
|
|
|
|
&ModuleState{
|
|
|
|
|
Path: []string{"root", "child"},
|
|
|
|
|
Resources: map[string]*ResourceState{
|
|
|
|
|
"aws_instance.bar": &ResourceState{
|
|
|
|
|
Type: "aws_instance",
|
|
|
|
|
Primary: &InstanceState{},
|
|
|
|
|
Provider: "provider.aws",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
ctx := testContext2(t, &ContextOpts{
|
|
|
|
|
Config: m,
|
|
|
|
|
ProviderResolver: providers.ResolverFixed(
|
|
|
|
|
map[string]providers.Factory{
|
|
|
|
|
"aws": testProviderFuncFixed(p),
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
State: state,
|
|
|
|
|
Targets: []addrs.Targetable{
|
|
|
|
|
addrs.RootModuleInstance.Resource(
|
|
|
|
|
addrs.ManagedResourceMode, "aws_instance", "foo",
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if _, diags := ctx.Plan(); diags.HasErrors() {
|
|
|
|
|
t.Fatalf("plan errors: %s", diags.Err())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if _, diags := ctx.Apply(); diags.HasErrors() {
|
|
|
|
|
t.Fatalf("apply errors: %s", diags.Err())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestContext2Apply_unknownAttribute(t *testing.T) {
|
|
|
|
|
m := testModule(t, "apply-unknown")
|
|
|
|
|
p := testProvider("aws")
|
|
|
|
|
|