diff --git a/providers/terraform/resources/tfplan.go b/providers/terraform/resources/tfplan.go index 93ce8ebe86..a044e50381 100644 --- a/providers/terraform/resources/tfplan.go +++ b/providers/terraform/resources/tfplan.go @@ -18,6 +18,9 @@ func (t *mqlTerraformPlan) id() (string, error) { } func initTerraformPlan(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) { + if len(args) != 0 { + return args, nil, nil + } conn := runtime.Connection.(*connection.Connection) plan, err := conn.Plan() @@ -25,6 +28,16 @@ func initTerraformPlan(runtime *plugin.Runtime, args map[string]*llx.RawData) (m return nil, nil, err } + // TODO: This only creates compatibility with v8. Please revisit this section + // after https://github.com/mondoohq/cnquery/issues/1943 is clarified. + if plan == nil { + return map[string]*llx.RawData{ + "formatVersion": llx.StringData(""), + "terraformVersion": llx.StringData(""), + "resourceChanges": llx.ArrayData([]interface{}{}, types.Resource("terraform.plan.resourceChange")), + }, nil, nil + } + args["formatVersion"] = llx.StringData(plan.FormatVersion) args["terraformVersion"] = llx.StringData(plan.TerraformVersion) @@ -154,6 +167,12 @@ func (t *mqlTerraformPlanConfiguration) providerConfig() ([]interface{}, error) return nil, err } + // TODO: This only creates compatibility with v8. Please revisit this section + // after https://github.com/mondoohq/cnquery/issues/1943 is clarified. + if plan == nil { + return []interface{}{}, nil + } + if plan.Configuration == nil { return nil, nil } @@ -180,6 +199,12 @@ func (t *mqlTerraformPlanConfiguration) resources() ([]interface{}, error) { return nil, err } + // TODO: This only creates compatibility with v8. Please revisit this section + // after https://github.com/mondoohq/cnquery/issues/1943 is clarified. + if plan == nil { + return []interface{}{}, nil + } + if plan.Configuration == nil { return nil, nil }