@@ -243,7 +243,18 @@ func Provider() *schema.Provider {
243
243
Description : "Avoid initializing NSX connection on startup" ,
244
244
DefaultFunc : schema .EnvDefaultFunc ("NSXT_ON_DEMAND_CONNECTION" , false ),
245
245
},
246
- "context" : getContextSchema (false , false , true ),
246
+ "project_id" : {
247
+ Type : schema .TypeString ,
248
+ Description : "Id of the project which the plan executes in its context." ,
249
+ Optional : true ,
250
+ DefaultFunc : schema .EnvDefaultFunc ("NSXT_PROVIDER_PROJECT_ID" , "" ),
251
+ },
252
+ "vpc_id" : {
253
+ Type : schema .TypeString ,
254
+ Description : "Id of the VPC which the plan executes in its context." ,
255
+ Optional : true ,
256
+ DefaultFunc : schema .EnvDefaultFunc ("NSXT_PROVIDER_VPC_ID" , "" ),
257
+ },
247
258
},
248
259
249
260
DataSourcesMap : map [string ]* schema.Resource {
@@ -785,10 +796,8 @@ func configurePolicyConnectorData(d *schema.ResourceData, clients *nsxtClients)
785
796
clientAuthDefined := (len (clientAuthCertFile ) > 0 ) || (len (clientAuthCert ) > 0 )
786
797
policyEnforcementPoint := d .Get ("enforcement_point" ).(string )
787
798
policyGlobalManager := d .Get ("global_manager" ).(bool )
788
- projectID , vpcID , err := getContextDataFromSchema (d , * clients )
789
- if err != nil {
790
- return err
791
- }
799
+ projectID := d .Get ("project_id" ).(string )
800
+ vpcID := d .Get ("vpc_id" ).(string )
792
801
vmcInfo := getVmcAuthInfo (d )
793
802
794
803
isVMC := false
@@ -1221,10 +1230,10 @@ func getGlobalPolicyEnforcementPointPath(m interface{}, sitePath *string) string
1221
1230
func getContextDataFromSchema (d * schema.ResourceData , m interface {}) (string , string , error ) {
1222
1231
ctxPtr := d .Get ("context" )
1223
1232
if ctxPtr != nil {
1224
- if m .(nsxtClients ).ProjectID != "" || m .(nsxtClients ).VPCID != "" {
1233
+ contexts := ctxPtr .([]interface {})
1234
+ if (m .(nsxtClients ).ProjectID != "" || m .(nsxtClients ).VPCID != "" ) && len (contexts ) > 0 {
1225
1235
return "" , "" , fmt .Errorf ("cannot specify context in both provider level and object level" )
1226
1236
}
1227
- contexts := ctxPtr .([]interface {})
1228
1237
for _ , context := range contexts {
1229
1238
data := context .(map [string ]interface {})
1230
1239
vpcID := ""
0 commit comments