You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-15Lines changed: 26 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,20 +13,33 @@ With this Lambda Function you will be able to add decoding features to your appl
13
13
14
14
#### Step 2, Generate code artifacts and dependencies
15
15
To read QR/Barcodes, we are going to be using the [Zbar library](https://github.com/mchehab/zbar), an open source software suite for reading bar codes. We are going to include Zbar and other necessary packages into Lambda Layers for our Lambda function to work.
16
-
But don't worry, we have already automated this process for you, in a simple script you can run in your AWS Cloudshell! Here are the steps you have to follow:
16
+
But don't worry, we have already automated this process for you, in a simple script you can run in your AWS Cloud9! Here are the steps you have to follow:
17
17
18
-
*Access AWS CloudShell, a browser-based shell inside the AWS console. You can click the terminal icon next to the search bar or looking for _Cloudshell_ in the service search bar.
18
+
*Login into you AWS Account and access AWS Cloud9 by navigating to https://console.aws.amazon.com/cloud9control/home#/
19
19
20
-

21
-
* Once CloudShell has initiallized, clone this repo
* Provide a name for your environment, select an instance from the t2 or t3 family and make sure to choose "Amazon Linux 2" as platform. This guarantees the correct installation of the zbar library
23
+
24
+

25
+
26
+
* We recommend to choose "AWS Systems Manager(SSM)" in the network settings as it won't require you to open any inbound port to the EC2 instance. Do not change setting in the "VPC Settings" sections unless you need to. Finally, create the environment by clicking "Create"
27
+
28
+

29
+
30
+
* Once your Cloud9 environment is created, open it and create a new terminal
* Run the `setup.sh` script in order to generate the needed lambda layers and code package. You must specify the bucket where you want to upload this artifacts replacing <BUCKET_NAME> with the S3 bucket name you created.
* Once the script finishes, you should see 3 new files in your S3 bucket under `BarcodeQRDecoder/qr-reader/assets/` path, the two Lambda layers containing the libraries needed (Pillow and Pyzbar) and the lambda code packaged in a .zip file
42
+
* Once the script finishes, you should see 2 new files in your S3 bucket under `BarcodeQRDecoder/qr-reader/assets/` path, the Lambda layer containing the libraries needed (Pillow and Pyzbar) and the lambda code packaged in a .zip file
30
43
31
44

32
45
@@ -35,28 +48,26 @@ But don't worry, we have already automated this process for you, in a simple scr
35
48
* Create a new Lambda Function.
36
49
* Select Author from scratch.
37
50
* Input a new name for your function
38
-
* Select Python 3.7 as runtime
51
+
* Select Python 3.9 as runtime
39
52
* Select x86_64 as architecture
40
53
* Create a new role with basic Lambda permissions
41
-
* Replace the code with Python code inside `code/lambda.py`
54
+
* Replace the code with Python code [available in this repository](src/code/lambda_function.py)
42
55
43
56
You have now created the Lambda function!
44
57
45
58
#### Step 4, Add Layers to your Lambda function
46
-
As we mentioned before, your function needs some packages to run correctly. If you completed step 2, you should have the layers artifacts ready in your bucket!
47
-
Follow these steps to create your layers:
59
+
As we mentioned before, your function needs some packages to run correctly. If you completed step 2, you should have the layer artifact ready in your bucket!
60
+
Follow these steps to create your layer:
48
61
- Open the Layers page of the Lambda console.
49
62
- Choose Create layer.
50
63
- Under Layer configuration, for Name, enter a name for your layer.
51
64
- (Optional) For Description, enter a description for your layer.
52
65
- To upload a file from Amazon S3, choose Upload a file from Amazon S3. Then, for Amazon S3 link URL, enter the S3 URI of the artifact.
53
66
- For Compatible architectures, choose x86_64.
54
-
- For Compatible runtimes, choose Python 3.7.
67
+
- For Compatible runtimes, choose Python 3.9.
55
68
- Choose Create.
56
69
57
-
Repeat these steps for both artifacts created in S3.
58
-
59
-
Next, go to the Lambda function and in your layers section, select Add Layer. Select your layers which will be available at the Custom AWS layers dropdown.
70
+
Next, go to the Lambda function and in your layers section, select Add Layer. Select your layer which will be available at the Custom AWS layers dropdown.
60
71
61
72
#### Step 5, Configure the permissions needed
62
73
Head over to IAM and add permissions to your associated role to access your S3 Bucket.
./configure --with-gtk=auto --with-python=auto && make &&cd ..
36
44
37
45
#copy library to layer folder and replace libzbar.so path inside zbar_library.py to correctly load the library. Lambda layers (.zips) will be uploaded to S3
0 commit comments