1

I need to create a Button with Django Framework and connect to trigger lambda function (aws), click to button to should trigger the function. Also, another page to upload files to S3 Bucket with django from local. Should I work on REST API or there is a way around this.

how to get started on this or execute the idea? also helpful if you could share resources on this.

1
  • Are you looking to deploy the Django application to Lambda? Or do you have a Django application deployed somewhere else, but you need to trigger a Lambda function with it? Commented Jan 9, 2021 at 17:43

2 Answers 2

1

You can use the lambda client's invoke() function from the boto3 package:

import boto3

lambda_client = boto3.client('lambda')

lambda_payload = {"name":"name","age":"age"}
lambda_client.invoke(
    FunctionName='myfunctionname', 
    InvocationType='RequestResponse',
    Payload=lambda_payload
)

Refer to the official boto3 documentation for more info.

You may call the invoke() function from your Django admin button. Check out this answer or search similar ones to figure out the Django admin part.

Cheers!

Sign up to request clarification or add additional context in comments.

Comments

-1

You can connect your lambda to an API gateway. The browser hits the API gateway which will trigger your lambda. (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html)

For S3, you can use boto3 to upload to s3 from inside any Python application. https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.