File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -181,9 +181,30 @@ func (p *Plan) ProviderAddrs() []addrs.AbsProviderConfig {
181181 }
182182
183183 m := map [string ]addrs.AbsProviderConfig {}
184+
185+ // Get all provider requirements from resources.
184186 for _ , rc := range p .Changes .Resources {
185187 m [rc .ProviderAddr .String ()] = rc .ProviderAddr
186188 }
189+
190+ // Get the provider required for pluggable state storage, if that's in use.
191+ //
192+ // This check should be redundant as:
193+ // 1) Any provider used for state storage would be in required_providers, which is checked separately elsewhere.
194+ // 2) An apply operation that uses the planfile only checks the providers needed for the plan _after_ the operations backend
195+ // for the operation is set up, and that process will detect if the provider needed for state storage is missing.
196+ //
197+ // However, for completeness when describing the providers needed by a plan, it is included here.
198+ if ! p .StateStore .Empty () {
199+ address := addrs.AbsProviderConfig {
200+ Module : addrs .RootModule , // A state_store block is only ever in the root module
201+ Provider : * p .StateStore .Provider .Source ,
202+ // Alias: aliases are not permitted when using a provider for PSS.
203+ }
204+
205+ m [p .StateStore .Provider .Source .String ()] = address
206+ }
207+
187208 if len (m ) == 0 {
188209 return nil
189210 }
Original file line number Diff line number Diff line change @@ -15,9 +15,33 @@ import (
1515)
1616
1717func TestProviderAddrs (t * testing.T ) {
18+ // Inputs for plan
19+ provider := & Provider {}
20+ err := provider .SetSource ("registry.terraform.io/hashicorp/pluggable" )
21+ if err != nil {
22+ panic (err )
23+ }
24+ err = provider .SetVersion ("9.9.9" )
25+ if err != nil {
26+ panic (err )
27+ }
28+ config , err := NewDynamicValue (cty .ObjectVal (map [string ]cty.Value {
29+ "foo" : cty .StringVal ("bar" ),
30+ }), cty .Object (map [string ]cty.Type {
31+ "foo" : cty .String ,
32+ }))
33+ if err != nil {
34+ panic (err )
35+ }
1836
1937 // Prepare plan
2038 plan := & Plan {
39+ StateStore : StateStore {
40+ Type : "pluggable_foobar" ,
41+ Provider : provider ,
42+ Config : config ,
43+ Workspace : "default" ,
44+ },
2145 VariableValues : map [string ]DynamicValue {},
2246 Changes : & ChangesSrc {
2347 Resources : []* ResourceInstanceChangeSrc {
@@ -70,6 +94,11 @@ func TestProviderAddrs(t *testing.T) {
7094 Module : addrs .RootModule ,
7195 Provider : addrs .NewDefaultProvider ("test" ),
7296 },
97+ // Provider used for pluggable state storage
98+ {
99+ Module : addrs .RootModule ,
100+ Provider : addrs .NewDefaultProvider ("pluggable" ),
101+ },
73102 }
74103
75104 for _ , problem := range deep .Equal (got , want ) {
You can’t perform that action at this time.
0 commit comments