amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

Feature: custom runtimes to define function

Open MarlonJD opened this issue 8 months ago • 18 comments

Problem

#1543, #1486

Changes

~~I changed runtime parameter to string from int. It was only nodejs version. Now it can be:~~

~~'GO_1_X_PROVIDED_AL2023' | 'NODEJS_16_X' | 'NODEJS_18_X' | 'NODEJS_20_X' | 'PYTHON_3_8' | 'PYTHON_3_9' | 'PYTHON_3_10' | 'PYTHON_3_11' | 'PYTHON_3_12'~~

~~It's default NODEJS_18_X same as old functions, people only need to specify runtime: "NODEJS_16_X" if they want another version, it's giving lint error, so it's easy to inform people if it's changed. If it's empty, it's still creating nodejs version, I also add required to entry parameter when it's go or python runtimes.~~

Edit: I modified defineFunction to props and callback function can be parameters at the same time:

defineFunction({
  name: "my-regular-function",
})

// a go function
defineFunction((scope) => {
  return new GoFunction(scope, "GoFunction", {
    entry: "app/cmd/api",
  })
})

can be usable like proposal in RFC, go function will be usable out of box, python function will be require docker, so python function cannot be used on CI/CD, it can be deploy with custom pipeline on local.

ie: disabling auto deploy, npm ci && export CI=1 && npx ampx pipeline-deploy --branch BRANCH_NAME --app-id AMPLIFY_APP_ID will do the trick for python.

Checklist

  • [X] If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.
  • [X] If this PR requires a change to the Project Architecture README, I have included that update in this PR.
  • [X] If this PR requires a docs update, I have linked to that docs PR above.
  • [X] If this PR modifies E2E tests, makes changes to resource provisioning, or makes SDK calls, I have run the PR checks with the run-e2e label set.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

MarlonJD avatar Jun 03 '24 16:06 MarlonJD