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

defineFunction only has entry property to provide code #2487

Open
juan-psl opened this issue Feb 6, 2025 · 0 comments
Open

defineFunction only has entry property to provide code #2487

juan-psl opened this issue Feb 6, 2025 · 0 comments
Labels
pending-triage Incoming issues that need categorization

Comments

@juan-psl
Copy link

juan-psl commented Feb 6, 2025

Environment information

System:
  OS: macOS 15.2
  CPU: (8) arm64 Apple M2
  Memory: 149.80 MB / 16.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
  Yarn: 1.22.22 - ~/.nvm/versions/node/v18.18.0/bin/yarn
  npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.5.1
  @aws-amplify/backend: 1.9.0
  @aws-amplify/backend-auth: 1.4.2
  @aws-amplify/backend-cli: 1.4.3
  @aws-amplify/backend-data: 1.2.2
  @aws-amplify/backend-deployer: 1.1.11
  @aws-amplify/backend-function: 1.9.0
  @aws-amplify/backend-output-schemas: 1.4.0
  @aws-amplify/backend-output-storage: 1.1.4
  @aws-amplify/backend-secret: 1.1.5
  @aws-amplify/backend-storage: 1.2.4
  @aws-amplify/cli-core: 1.2.1
  @aws-amplify/client-config: 1.5.3
  @aws-amplify/deployed-backend-client: 1.4.2
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.9
  @aws-amplify/platform-core: 1.3.0
  @aws-amplify/plugin-types: 1.6.0
  @aws-amplify/sandbox: 1.2.7
  @aws-amplify/schema-generator: 1.2.6
  aws-amplify: 6.10.3
  aws-cdk: 2.172.0
  aws-cdk-lib: 2.172.0
  typescript: 5.7.2
No AWS environment variables
No CDK environment variables

Describe the feature

Add a way to specify the folder that contains the handler.ts, instead of the path to the handler.ts, so when bundling the lambda it packages all the contents of the container folder

Or add a new property where we can pass a list of extra files to include when packaging the lambda.

Use case

I want to use handlebars in a lambda, so I need to bundle a template.hbs file along with the code.

The defineFunction has an entry property which is The path to the file that contains the function entry point.

My project structure looks like this :

amplify/
    my-lambda/
        handler.ts
        resource.ts
        template.hbs

when I build the lambda, if I download the code, the code only contains:

index.mjs
index.mjs.map

the template.hbs file is not there

If I use the cdk like this:

import * as lambda from "aws-cdk-lib/aws-lambda";
import { Runtime } from "aws-cdk-lib/aws-lambda";
const emailHandler = new lambda.Function(customResourceStack, "EmailHandler", {
  runtime: Runtime.NODEJS_20_X,
  code: lambda.Code.fromAsset("./amplify/my-lambda"),
  handler: "handler.handler",
});

it adds all of my code inlcuding the template.hbs

would there be a way do the same with the defineFunction?, I don't wanna rely on the new lambda.Function because then I wouldn't be able to provide the secret() in the env configuration

@juan-psl juan-psl added the pending-triage Incoming issues that need categorization label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-triage Incoming issues that need categorization
Projects
None yet
Development

No branches or pull requests

1 participant