Variables from external file - output file generated by terraform


Hi All,

I am trying to use variables from external file, which is generated by terraform. I am loading the file into variable in custom section as below.

  tfconfig: ${file(./tfconfig.json)}

I require the file to be dynamically created during deployment. So, I wrote a plugin which is running terraform output and generating the file. But, I get the following error

A valid file to satisfy the declaration 'file(tfconfig.json):variable' could not be found.

I am not sure, which hook should I use, so the file is generated, before serverless is trying to load the file. Or is there any other way to do it? Any suggestion would be helpful…