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
These instructions describe how to use Maven to generate a cloud service function (CSF) zip file from within your python-components project.
NOTE: While the zip file generated may technically work with other cloud service providers, these configuration instructions will focus on AWS Lambda.
Review the README
Please see README.md for further information on, and use of, this content.
License for embedded documentation and source codes: PIOT-DOC-LIC
Estimated effort may vary greatly
The estimated level of effort for this exercise shown in the 'Estimate' section below is a very rough approximation. The actual level of effort may vary greatly depending on your development and test environment, experience with the requisite technologies, and many other factors.
Actions
NOTE: There are many ways to create a zip file of the Python components that will comprise an AWS Lambda. You can simply copy all of the requisite source files to a new directory, with relative paths retained, and then use your favorite zip-creation tool to create the zip file, or follow the instructions below to create a Maven assembly.
Using Maven
NOTE: These instructions provide general guidelines depicting how you can create the directives to handle packaging of the AWS Lambda code. You can embed the configuration directives within your pom.xml, or create a separate XML file that's referenced by your pom.xml. The examples in this instruction set focus on the latter. Keep in mind these are just examples - your configuration data and the properties embedded within your Maven XML files should be specific to YOUR implementation. Be sure to update them accordingly.
At the top level of your python-components directory, create a new pom.xml file. This will contain the project information as well as an assembly plugin directive to invoke another Maven configuration XML to create the zip file.
At the top level of your python-components directory, create a new directory named 'assembly'. This will contain the Maven configuration XML file(s) used to package your Lambda's. Create an XML file within the assembly directory - you can name this whatever you want - in the example below, I've named the file '
NOTE: This assumes you've already created your CSF modules (e.g., your AWS Lambda function in Python). The example below is specific to the CSF module ./programmingtheiot/csf/SensorDataHandlerFunction.py described in PIOT-CSF-11-001 and Programming the IoT - Chapter 11.
Sample Maven pom.xml (NOTE: Use your own properties)
From a terminal / command line, change your directory to the top-level of python-components.
Execute mvn install
Check the directory target for a file with a name similar to piot-cda-aws-sensordatahandler-0.0.1.zip (yours may be different depending on your pom.xml properties)
Open the zip file and ensure the contents include the following from python-components:
All files from programmingtheiot\data, in the appropriate path
All files from programmingtheiot\config, in the appropriate path
The appropriate programmingtheiot\csf file (e.g., SensorDataHandlerFunction.py), at the top level
All __init__.py files (from programmingtheiot, data, common, and csf), in the appropriate paths
Description
NOTE: While the zip file generated may technically work with other cloud service providers, these configuration instructions will focus on AWS Lambda.
Review the README
Estimated effort may vary greatly
Actions
NOTE: There are many ways to create a zip file of the Python components that will comprise an AWS Lambda. You can simply copy all of the requisite source files to a new directory, with relative paths retained, and then use your favorite zip-creation tool to create the zip file, or follow the instructions below to create a Maven assembly.
Using Maven
NOTE: These instructions provide general guidelines depicting how you can create the directives to handle packaging of the AWS Lambda code. You can embed the configuration directives within your pom.xml, or create a separate XML file that's referenced by your pom.xml. The examples in this instruction set focus on the latter. Keep in mind these are just examples - your configuration data and the properties embedded within your Maven XML files should be specific to YOUR implementation. Be sure to update them accordingly.
pom.xml
file. This will contain the project information as well as an assembly plugin directive to invoke another Maven configuration XML to create the zip file.NOTE: This assumes you've already created your CSF modules (e.g., your AWS Lambda function in Python). The example below is specific to the CSF module
./programmingtheiot/csf/SensorDataHandlerFunction.py
described in PIOT-CSF-11-001 and Programming the IoT - Chapter 11.Sample Maven pom.xml (NOTE: Use your own properties)
Sample Maven Lambda/zip packaging XML (e.g., assembly/piot-aws-sensordatahandler-zip.xml)
Estimate
Tests
mvn install
target
for a file with a name similar topiot-cda-aws-sensordatahandler-0.0.1.zip
(yours may be different depending on your pom.xml properties)python-components
:programmingtheiot\data
, in the appropriate pathprogrammingtheiot\config
, in the appropriate pathprogrammingtheiot\csf
file (e.g.,SensorDataHandlerFunction.py
), at the top level__init__.py
files (fromprogrammingtheiot
,data
,common
, andcsf
), in the appropriate pathsSensorData
.The text was updated successfully, but these errors were encountered: