File tree Expand file tree Collapse file tree 5 files changed +39
-0
lines changed Expand file tree Collapse file tree 5 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ credentials.json
2
+ package
3
+ package.zip
Original file line number Diff line number Diff line change
1
+ This is an example of a Python lambda function that uses Google Cloud Vision API.
2
+
3
+ * Compile the code: ` $ ./bundle.sh `
4
+ * Upload ` package.zip ` to AWS Lambda
5
+ * If you need to install a dependency: ` pip install --target ./package <package name> `
6
+
7
+ Reference: https://docs.aws.amazon.com/lambda/latest/dg/python-package.html#python-package-create-package-with-dependency
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ rm -f package.zip
3
+ rm -rf package
4
+ pip install --target ./package requests
5
+ pip install --target ./package google-cloud-vision
6
+ cd package
7
+ zip -r ../package.zip .
8
+ cd ..
9
+ zip -g package.zip lambda_function.py
10
+ zip -g package.zip credentials.json
11
+ echo ' Now upload package.zip to AWS Lambda (please make sure that the Lambda function timeout configuration is enough)'
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " service_account" ,
3
+ "project_id" : " " ,
4
+ "private_key_id" : " " ,
5
+ "private_key" : " "
6
+ "client_email" : " " ,
7
+ "client_id" : " " ,
8
+ "auth_uri" : " https://accounts.google.com/o/oauth2/auth" ,
9
+ "token_uri" : " https://oauth2.googleapis.com/token" ,
10
+ "auth_provider_x509_cert_url" : " https://www.googleapis.com/oauth2/v1/certs" ,
11
+ "client_x509_cert_url" : " "
12
+ }
Original file line number Diff line number Diff line change
1
+ from google .cloud import vision
2
+ import os
3
+ os .environ ['GOOGLE_APPLICATION_CREDENTIALS' ] = "credentials.json"
4
+ def lambda_handler (event , context ):
5
+ client = vision .ImageAnnotatorClient ()
6
+ print (client )
You can’t perform that action at this time.
0 commit comments