The file lark_parser.py is generated "on-demand". However, the file is created in the same directory as where hcl2 is installed. If the directory is on a read-only filesystem, creation fails, and parsing is not possible. This happens if the code is e.g. run in an AWS Lambda function.
Generated files should instead be placed in /tmp. The filename can be generated using the tempfile module. An alternative would be to keep the current logic, but in case of file creation failure, fall back to writing the file to /tmp.
The file lark_parser.py is generated "on-demand". However, the file is created in the same directory as where hcl2 is installed. If the directory is on a read-only filesystem, creation fails, and parsing is not possible. This happens if the code is e.g. run in an AWS Lambda function.
Generated files should instead be placed in /tmp. The filename can be generated using the
tempfile
module. An alternative would be to keep the current logic, but in case of file creation failure, fall back to writing the file to /tmp.