Skip to content
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

Merged
merged 12 commits into from
Aug 21, 2018
Merged

Conversation

CyrusNajmabadi
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Aug 21, 2018

This is just exposing the support we added here: pulumi/pulumi#1804

Also includes an example showing how you could use this with express.

Cyrus Najmabadi added 2 commits August 21, 2018 15:12
Copy link
Contributor

@swgillespie swgillespie left a 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 });
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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 } }

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@CyrusNajmabadi CyrusNajmabadi merged commit b53a9d5 into master Aug 21, 2018
@pulumi-bot pulumi-bot deleted the factoryFunction branch August 21, 2018 23:45
Copy link
Contributor

@lukehoban lukehoban left a 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
Copy link
Contributor

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;
Copy link
Contributor

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,
Copy link
Contributor

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:

  1. A different class that inherits from aws.serverless.Function that accepts a different argument?
  2. Moving the function parameter inside the args bag and allowing either func: or factory: ?
  3. Something else?

@CyrusNajmabadi
Copy link
Contributor Author

I agree with your concerns luke. I think to approaches can be taken here:

  1. roll back and redo.
  2. adjust things with a new PR to handle the problems you identified.

Because the issues seem small enough, i'm going to go with '2'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants