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

Detailed docs for: Go, Python Runtimes functions, how can we create and assign these functions

Open MarlonJD opened this issue 9 months ago • 6 comments

Environment information

System:
  OS: macOS 14.4.1
  CPU: (8) arm64 Apple M2
  Memory: 361.41 MB / 16.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
  Yarn: 1.22.22 - /opt/homebrew/bin/yarn
  npm: 10.5.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/backend: 1.0.0
  @aws-amplify/backend-cli: 1.0.1
  aws-amplify: 6.3.0
  aws-cdk: 2.140.0
  aws-cdk-lib: 2.140.0
  typescript: 5.4.5
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Description

On AWS Amplify Gen 2 document, it says there is only nodejs runtimes for defineFunction Source

Currently, only Node runtimes are supported by defineFunction. However, you can change the Node version that is used by the function. The default is the oldest Node LTS version that is supported by AWS Lambda (currently Node 18).

On the Gen 1 vs. Gen 2 feature matrix. It says, Function runtime: .NET 6, Go, Java, Javascript and Python is available with Yes with CDK.

How can we create for example Go Lambda function and use as a custom GraphQL query in gen 2. There was detailed document on gen 1 for custom query with lambda function.

We were creating go function with amplify add function, then just assigning this function name with this:

type Query {
  echo(msg: String): String @function(name: "echofunction", region: "us-east-1")
}

Set up custom queries and mutations (Gen 1)

Now, how can we do this? Also we need to get current user's information with body, can we do this in gen 2 ? For example I'm using user's cognitoId to get user's detail and get permissions about custom job.

Which options we have? How can we connect our Golang function to custom query, can I get user's cognate id with this query?

MarlonJD avatar May 09 '24 17:05 MarlonJD