(aws_cdk): Allow Python Path objects into functions that need paths
Describe the feature
Allow using Path object in python for when a path to something is needed.
Use Case
For example to use a Code.from_asset() function I need to turn my Path object into str. It would be nice to not have to do this cast.
Code.from_asset(str(Path().cwd() / 'aws_infrastructure' / 'lambda_functions')),
Proposed Solution
No response
Other Information
No response
Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
CDK version used
2.154.1 (build febce9d)
Environment details (OS name and version, etc.)
Ubuntu 24.04
@InvincibleRMC Good afternoon. If I understand your use case properly, you want to support for overloaded version of Code.from_asset() where it accepts Python's Path() object, instead of requiring to convert into str (string). I'm not sure if it could be supported. The reasoning is that Python CDK library is generated from JSII bindings (it is a specialized process) and supporting language specific class might not be feasible since there might not be overlap across different supported CDK languages. I could review this with team.
Thanks, Ashish
That correctly summarizes my use case. If it is not possible I understand, it would just be more convenient.
This could be JSII-related. Reaching out to core team for further inputs here.
It's exactly as you said @ashishdhingra.
We have to be multi-language compatible, and not all languages have a Path type. I understand why this would be nice, but it's unlikely to happen soon.
We could do the language-specific conversion in the Python runtime over in the jsii repository: https://github.com/aws/jsii. This issue makes for a good feature request over there.
But again, unlikely to be done by us soon. I would accept someone submitting it if they can demonstrate a high degree of confidence that they understand how jsii works and why this change will not cause any unexpected problems.