1. Create the Cloudera DataFlow function🔗
You can use the AWS CLI to create and configure the Cloudera DataFlow function in AWS Lambda.
-
Create the AWS IAM Role required to create the lambda function.
- When Lambda executes a function, it requires an execution role that grants the function permission to access AWS services and resources. Lambda assumes the role when the Cloudera DataFlow function is invoked. Assign the most limited permissions/policies for the function to execute.
- Download the trust-policy.json file.
-
Using the below AWS CLI command, create a role called
NiFi_Function_Quickstart_Lambda_Role that the Lambda service will assume.
The role will be attached to an AWS managed role that provides the limited permissions for the function to execute.
aws iam create-role --role-name NiFi_Function_Quickstart_Lambda_Role --assume-role-policy-document file://trust-policy.json aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole --role-name NiFi_Function_Quickstart_Lambda_Role
-
These two commands will create the following IAM role. Copy and save the Role ARN
which you will need to create the function.
-
Create the Cloudera DataFlow function in Lambda.
-
Download the Cloudera DataFlow Function
Definition JSON file.
- This file has the full definition required to create the Cloudera DataFlow function including function, code, environment variable and security configuration.
- The environment variables in this file contain the info for Lambda to fetch the function definition from the Cloudera DataFlow Catalog as well as the function’s application parameters.
-
Update the following properties in the definition file:
-
DF_ACCESS_KEY – The access key created for the Cloudera on cloud service account
-
DF_PRIVATE_KEY – The private key created for the Cloudera on cloud service account
-
FLOW_CRN – The CRN value you copied from the Cloudera DataFlow Catalog page after uploading the function
-
aws_access_key_id – The AWS access key that has permissions to access (read/write) the S3 bucket you created in the prerequisite section
-
aws_access_key_password – The AWS access key password that has permissions to access (read/write) the S3 bucket you created in the prerequisite section
-
s3_bucket – The name of the bucket you created
-
s3_region – The bucket's region
-
S3Bucket – The name of the bucket that you uploaded the binaries ZIP file that you downloaded from the Cloudera DataFlow Functions page
-
S3Key – The key to the binaries ZIP file in S3.
For example, if you uploaded the ZIP to S3 with this URI s3://dataflowfunctionsquickstart/libs/naaf-aws-lambda-1.0.0-SNAPSHOT-bin.zip, the key would be libs/naaf-aws-lambda-1.0.0-SNAPSHOT-bin.zip
-
Role – The ARN of the role created in the previous step
-
-
Run the following command to create a function called NiFi_Function_Quickstart
(if the FunctionName property was not modified):
aws lambda create-function --cli-input-json file://NiFi_Function_Quickstart-definition.json
-
Download the Cloudera DataFlow Function
Definition JSON file.
-
View the Lambda function in AWS Console.
-
On the AWS console, navigate to the Lambda service and click the function called
NiFi_Function_Quickstart (if the FunctionName property was not modified).
You can see the following under the Code tab of the function:
-
If you click the Configuration tab, you can see all the
configured parameters required to run the function under Environment
variables.
-
On the AWS console, navigate to the Lambda service and click the function called
NiFi_Function_Quickstart (if the FunctionName property was not modified).