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

Using python for lambda functions #1823

Closed
cookiejest opened this issue Aug 5, 2024 · 7 comments
Closed

Using python for lambda functions #1823

cookiejest opened this issue Aug 5, 2024 · 7 comments
Labels
pending-triage Incoming issues that need categorization question Question or confusion about some aspect of the product

Comments

@cookiejest
Copy link

cookiejest commented Aug 5, 2024

Environment information

using amplify v2

Description

hi would like to use python for some of the lambda functions. It looks like this is not supported yet but can see this.

#1543

Assuming this issue will not be supported soon - What would be the next best approach to do this? Is it to create an API gateway and cognito auth and run the queries that way or is there a better approach?

@cookiejest cookiejest added the pending-triage Incoming issues that need categorization label Aug 5, 2024
@ykethan
Copy link
Member

ykethan commented Aug 8, 2024

Hey @cookiejest, thank you for reaching. As the RFC: #1543 provides this is currently not supported. But wanted to provide some information on this.

To create a python function you can utilize the CDK Lambda construct: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html
and build the function using local commands as the construct will default to docker to build the function and the CICD deploy may fail.
Also, CDK does provide a pythonFunction construct but do note this is experimental.

Additionally, you can create the function on the console or a tool and reference the function for your use cases using the fromFunctionArn method.
But do note that functions created or referenced by CDK cannot be used with the Data schema or use other attributes such as the access property to provide access to the function directly.

@ykethan ykethan added question Question or confusion about some aspect of the product pending-response Issue is pending response from author labels Aug 8, 2024
@cookiejest
Copy link
Author

Ok, as I am not able to use experimental approach, I decided to deploy python lambda functions separately in another repo and keep amplify updated via graphQL. However I havn't figured out a clean way to add custom graphql yet within the amplify v2.

I listed this seperately under aws-amplify/amplify-category-api#2754

@github-actions github-actions bot removed the pending-response Issue is pending response from author label Aug 8, 2024
@misha-slyusarev
Copy link

You can try this simple approach to create a custom python lambda resource https://medium.com/@misha.slyusarev/amplify-gen-2-custom-python-function-with-cdk-5e5b79b91b10

@cookiejest
Copy link
Author

cool! What user will the custom function run under? If want to add the equivilent of only authenticated, is it possible?

@MarlonJD
Copy link

cool! What user will the custom function run under? If want to add the equivilent of only authenticated, is it possible?

#1602 You can check my pr, it's allowing to use custom runtimes in data resources.ts, you can use go, python functions in graphql query and mutations

@cookiejest
Copy link
Author

cool! What user will the custom function run under? If want to add the equivilent of only authenticated, is it possible?

#1602 You can check my pr, it's allowing to use custom runtimes in data resources.ts, you can use go, python functions in graphql query and mutations

i saw it. I can see it's blocked at the moment as the AWS team would need to do additional house keeping to support it properly, I cannot risk using the separate branch for my project unfortunately!

You can try this simple approach to create a custom python lambda resource https://medium.com/@misha.slyusarev/amplify-gen-2-custom-python-function-with-cdk-5e5b79b91b10

Thanks, this looks more stable but has to introduce docker complexity. Maybe it would be better if had an example deploying amplify app and associated resources via SAM so amplify can be adopted by people already with a deployment pipeline and just using amplify for the front end auth with cognito?

Thanks!

@MarlonJD
Copy link

cool! What user will the custom function run under? If want to add the equivilent of only authenticated, is it possible?

#1602 You can check my pr, it's allowing to use custom runtimes in data resources.ts, you can use go, python functions in graphql query and mutations

i saw it. I can see it's blocked at the moment as the AWS team would need to do additional house keeping to support it properly, I cannot risk using the separate branch for my project unfortunately!

You can try this simple approach to create a custom python lambda resource https://medium.com/@misha.slyusarev/amplify-gen-2-custom-python-function-with-cdk-5e5b79b91b10

Thanks, this looks more stable but has to introduce docker complexity. Maybe it would be better if had an example deploying amplify app and associated resources via SAM so amplify can be adopted by people already with a deployment pipeline and just using amplify for the front end auth with cognito?

Thanks!

You don't need to use docker, you can bypass this

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 question Question or confusion about some aspect of the product
Projects
None yet
Development

No branches or pull requests

4 participants