-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-lambda-python: does command_hooks even work? #25203
Comments
I am still fumbling through this, but it appears the solution is that the interface guidance at https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-python.html must be followed, and defining my MagicHooks this way: @jsii.implements(lambda_python_alpha.ICommandHooks)
class MagicHooks:
def after_bundling(self, input_dir: str, output_dir: str) -> List[str]:
return []
def before_bundling(self, input_dir: str, output_dir: str) -> List[str]:
return [
(
"poetry export -f requirements.txt --output requirements.txt"
" --without-hashes --only=common"
)
] Will synthesize successfully. At least after I fix my other logic errors that result in the generated script failing LOL... |
Yeah thank you for pointing it out 👍 |
I successfully coerced my build into working and this indeed was the key step. |
Seems like a documentation issue then? |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
This issue should be re-opened and the docs fixed. The docs here show invalid Python code :/ |
This needs to be reopened, the documentation is beyond understandable I managed to get it working like this as I was attempting to tackle Apple Silicon esbuild for sharp module.. (Didn't find alternative solution)
And then use |
Describe the bug
See https://docs.aws.amazon.com/cdk/api/v2/docs/aws-lambda-python-alpha-readme.html#command-hooks where this example is provided:
I cannot find any example of equivalent code in python, or any statement by anybody claiming to have successfully defined such hooks.
My VSCode tool tips tell me that in this context:
I should be providing something of type
ICommandHooks
, but the constructor of that type does not provide any parameters,If I attempt to define my own class derived from ICommandHooks and replace the
after_bundling()
andbefore_bundling()
methods, synthesis fails with:Expected Behavior
I expect:
Current Behavior
Here is the full trace:
The
MagicHooks
object is an instance of my derived class (see below)Reproduction Steps
Possible Solution
I suspect this is a documentation problem, but I am TypeScript-illiterate and at a loss regarding how to restate the given TypeScript example in native python.
Additional Information/Context
No response
CDK CLI Version
2.72.1 (build ddbfac7)
Framework Version
No response
Node.js Version
I don't know how to figure this out
OS
Debian Linux 12.0
Language
Python
Language Version
3.11.2 targeting 3.10
Other information
See #23330 where I believe this support was introduced.
The text was updated successfully, but these errors were encountered: