-
Notifications
You must be signed in to change notification settings - Fork 157
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
Expose 'factory functions' from pulumi-aws #304
Conversation
…serverless function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty cool!
@@ -16,13 +16,13 @@ function createServer(region: aws.Region): aws.ec2.Instance { | |||
ingress: [ | |||
{ protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] }, | |||
], | |||
}, { provider: provider }); | |||
|
|||
}, <pulumi.CustomResourceOptions>{ provider: provider }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need these casts now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tagging @pgavlin . It looks like we split ResourceOptions into ResourceOptions and CustomResourceOptions. This resource still takes ResourceOptions, but 'provider' is in CustomResourceOptions. So, without this cast, typescript thinks something fishy is going on.
I'm running into this because i'm pulling in a new @pulumi/pulumi version. I'm not sure what our expectation is supposed to be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How close are we to landing pulumi/pulumi#1802? I think that would have let the code just work as written.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absent that, I think you need to write
{ providers: { aws: provider } }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is custom resource, not a component resource. so the { providers: { aws: provider } }
version seems... wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #305 to track this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a couple concerns here.
@@ -0,0 +1,4 @@ | |||
name: exoress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
express
*/ | ||
export type Handler = (event: any, context: Context, callback: (error: any, result: any) => void) => any; | ||
export type HandlerSignature = (event: any, context: Context, callback: (error: any, result: any) => void) => any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are exported types - changing their names is a breaking change, right?
@@ -106,9 +129,10 @@ export class Function extends pulumi.ComponentResource { | |||
|
|||
constructor(name: string, | |||
options: FunctionOptions, | |||
func: Handler, | |||
func: FuncSignature, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will, I'm nearly certain - lead to much worse intellisense - since TypeScript can't infer the signature for callers. I'm not a huge fan of losing this.
Should we consider:
- A different class that inherits from
aws.serverless.Function
that accepts a different argument? - Moving the function parameter inside the args bag and allowing either
func:
orfactory:
? - Something else?
I agree with your concerns luke. I think to approaches can be taken here:
Because the issues seem small enough, i'm going to go with '2'. |
This is just exposing the support we added here: pulumi/pulumi#1804
Also includes an example showing how you could use this with express.