-
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
Promise support #8156
Comments
I've been churning on this same issue (needing to do async operations in a Construct) and would also be interested in a solution for this (either explicit support, or some existing pattern/guidance). Thanks! |
You should be able to instantiate your CDK stack inside an immediately invoked async function expression.
|
@hoegertn throwing a promise without anyone looking after it may or may not work depending on the order of things. CDK has to be aware of the moment constructs are finalized. If we are showing code I would hope for something like this: class MyConstruct extends cdk.Construct {
protected async onPrepare(): Promise<void> {
const res = await something();
new OtherConstruct(this, {res});
}
} |
This is not something we will be able to support with the current programming model of the CDK. |
@eladb I understand why we can't support promises in the constructor, but why not in |
We've removed support for |
It's unclear how to use async js operations with constructs and still be able to run cdk commands.
Use Case
I want to add a rule to a security group allowing my current public IP and I need to do a network request to discover it.
Proposed Solution
Maybe constructs that need async operations could override some lifecycle method and return a promise there.
Other
I am new to CDK, sorry if this has been abundantly discussed elsewhere, I could not find it.
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: