-
Notifications
You must be signed in to change notification settings - Fork 154
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
Schematize lambda.CallbackFunction overlay and add docs for it #4352
Conversation
The CallbackFunction resource overlay was not present in the registry before. This change adds the schema for it and adds the docs for the registry.
) | ||
|
||
// extraTypes augment the types defined by the upstream AWS provider | ||
var extraTypes = map[string]schema.ComplexTypeSpec{ |
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 moved this to its own file to make it easier to work with and add additional extraTypes sources (like the overlays)
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.
Thank you so much, I dread working in the super long resources.go.
TypeSpec: schema.TypeSpec{ | ||
Ref: "#/types/aws:lambda/Runtime:Runtime", | ||
}, | ||
Description: "The Lambda runtime to use. If not provided, will default to `NodeJS20dX`.", |
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 not true yet, but we're currently updating it here: #4348
This PR will only go in after that one
Does the PR have any schema changes?Looking good! No breaking changes found. New resources:
Maintainer note: consult the runbook for dealing with any breaking changes. |
// typeOverlays augment the types defined by the upstream AWS provider | ||
var typeOverlays = map[string]schema.ComplexTypeSpec{} | ||
|
||
//go:embed pkg/overlays/examples/callbackFunction.md |
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 a moot point for just one file but if we're doing it a lot we can avoid shipping this into pulumi-resource-aws binary to avoid bulking it up. Trouble with resources.go code is that it's evaluated twice, once for tfgen and once for runtime startup in the provider, so it's a little tricky, but can be done with os.ReadFile that only runs for make tfgen
case.
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.
IMO we should opt for the simpler option here to avoid bugs and trouble down the road. Even if we had multiple files it wouldn't be a lot of storage size we're adding. The markdown file for the callbackFunction has ~9KB, so we'd need a lot of them before this has meaningful impact on the overall size of the provider (~794MB right 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.
You are right, I concede the point.. The provider binary is too large but we need to look holistically as to what to do with that, this is not really the root problem here.
You can provide the JavaScript function used for the Lambda Function's Handler either directly by setting the `callback` input property or instead specify the `callbackFactory`, which is a Javascript function that will be called to produce the callback function that is the entrypoint for the AWS Lambda. | ||
Using `callbackFactory` is useful when there is expensive initialization work that should only be executed once. The factory-function will be invoked once when the final AWS Lambda module is loaded. It can run whatever code it needs, and will end by returning the actual function that Lambda will call into each time the Lambda is invoked. | ||
|
||
The callback function should follow the following signature: `(event: E, context: Context, callback: (error?: Error | string | null, result?: R) => void) => Promise<R> | void`. It is recommended to use an async function, otherwise the Lambda execution will run until the `callback` parameter is called and the event loop is empty. See [Define Lambda function handler in Node.js](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html) for additional details. |
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.
Consider avoiding inline code gory details in favor of a code example (or just entirely drop).
|
||
See [Function Serialization](https://www.pulumi.com/docs/concepts/inputs-outputs/function-serialization/) for additional details on this process. | ||
|
||
If no IAM Role is specified, CallbackFunction will automatically use the following managed policies: |
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.
Is this important information to have upfront, or perhaps reference section at the bottom?
|
||
Notice the path to the file is now `/opt/config/config.json` --- `/opt` being the path at which AWS Lambda extracts the contents of a layer. The configuration layer is now manageable and deployable independently of the Lambda itself, allowing changes to be applied immediately across all functions that use it. | ||
|
||
#### Using layers for Node.js dependencies |
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.
TIL, very nice.
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.
Very nice.
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@pulumi/aws](https://pulumi.io) ([source](https://togithub.com/pulumi/pulumi-aws)) | dependencies | minor | [`6.48.0` -> `6.49.0`](https://renovatebot.com/diffs/npm/@pulumi%2faws/6.48.0/6.49.0) | --- ### Release Notes <details> <summary>pulumi/pulumi-aws (@​pulumi/aws)</summary> ### [`v6.49.0`](https://togithub.com/pulumi/pulumi-aws/releases/tag/v6.49.0) [Compare Source](https://togithub.com/pulumi/pulumi-aws/compare/v6.48.0...v6.49.0) ##### Does the PR have any schema changes? Looking good! No breaking changes found. ##### New resources: - `ebs/snapshotBlockPublicAccess.SnapshotBlockPublicAccess` - `lambda/callbackFunction.CallbackFunction` - `rds/integration.Integration` ##### New functions: - `rds/getClusterParameterGroup.getClusterParameterGroup` - `secretsmanager/getSecretVersions.getSecretVersions` ##### What's Changed - Update GitHub Actions workflows. by [@​pulumi-bot](https://togithub.com/pulumi-bot) in [pulumi/pulumi-aws#4353 - Upgrade CallbackFunction default runtime to Node 20.x by [@​t0yv0](https://togithub.com/t0yv0) in [pulumi/pulumi-aws#4348 - Schematize lambda.CallbackFunction overlay and add docs for it by [@​flostadler](https://togithub.com/flostadler) in [pulumi/pulumi-aws#4352 - Upgrade terraform-provider-aws to v5.62.0 by [@​flostadler](https://togithub.com/flostadler) in [pulumi/pulumi-aws#4359 **Full Changelog**: pulumi/pulumi-aws@v6.48.0...v6.49.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNS4yIiwidXBkYXRlZEluVmVyIjoiMzguMjUuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsidHlwZS9taW5vciJdfQ==--> Co-authored-by: lumiere-bot[bot] <98047013+lumiere-bot[bot]@users.noreply.github.com>
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@pulumi/aws](https://pulumi.io) ([source](https://togithub.com/pulumi/pulumi-aws)) | dependencies | minor | [`6.48.0` -> `6.49.0`](https://renovatebot.com/diffs/npm/@pulumi%2faws/6.48.0/6.49.0) | --- ### Release Notes <details> <summary>pulumi/pulumi-aws (@​pulumi/aws)</summary> ### [`v6.49.0`](https://togithub.com/pulumi/pulumi-aws/releases/tag/v6.49.0) [Compare Source](https://togithub.com/pulumi/pulumi-aws/compare/v6.48.0...v6.49.0) ##### Does the PR have any schema changes? Looking good! No breaking changes found. ##### New resources: - `ebs/snapshotBlockPublicAccess.SnapshotBlockPublicAccess` - `lambda/callbackFunction.CallbackFunction` - `rds/integration.Integration` ##### New functions: - `rds/getClusterParameterGroup.getClusterParameterGroup` - `secretsmanager/getSecretVersions.getSecretVersions` ##### What's Changed - Update GitHub Actions workflows. by [@​pulumi-bot](https://togithub.com/pulumi-bot) in [pulumi/pulumi-aws#4353 - Upgrade CallbackFunction default runtime to Node 20.x by [@​t0yv0](https://togithub.com/t0yv0) in [pulumi/pulumi-aws#4348 - Schematize lambda.CallbackFunction overlay and add docs for it by [@​flostadler](https://togithub.com/flostadler) in [pulumi/pulumi-aws#4352 - Upgrade terraform-provider-aws to v5.62.0 by [@​flostadler](https://togithub.com/flostadler) in [pulumi/pulumi-aws#4359 **Full Changelog**: pulumi/pulumi-aws@v6.48.0...v6.49.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNS4yIiwidXBkYXRlZEluVmVyIjoiMzguMjUuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsidHlwZS9taW5vciJdfQ==--> Co-authored-by: lumiere-bot[bot] <98047013+lumiere-bot[bot]@users.noreply.github.com>
This PR has been shipped in release v6.49.0. |
The CallbackFunction resource overlay was not present in the registry before. This change adds the schema for it and adds the docs for the registry.
The schema is mostly based on the
lambda.Function
resource with modifications to adhere to the typescript class here:pulumi-aws/sdk/nodejs/lambda/lambdaMixins.ts
Line 245 in 7461d68
How to review?
go install github.com/pulumi/registry/tools/resourcedocsgen@master
resourcedocsgen docs --schemaFile ../pulumi-aws/provider/cmd/pulumi-resource-aws/schema.json --docsOutDir content/registry/packages/aws/api-docs --packageTreeJSONOutDir static/registry/packages/navs/aws.json --version 6.0.0-alpha.0+dev
(you might have to tweak the path to the schema.json to match your dir layout)make serve
Fixes #4351