logo
Serverless computing with AWS Lambda is a game-changer, but deploying and managing functions can still be a hassle. Enter Infrastructure as Code (IaC) with Terraform, a powerful tool to automate and streamline this process. 1 This blog post shows you how to effortlessly deploy TIBCO Flogo applications to AWS Lambda using Terraform

Prerequisites

  • AWS Account: An AWS account with appropriate permissions.
  • Terraform: Terraform installed and configured on your local machine.
  • AWS CLI: The AWS CLI installed and configured.
  • Flogo Application: A Flogo application ready to be deployed.

What is TIBCO Flogo Enterprise?

TIBCO Flogo is a next-generation open-source integration framework that takes a different approach to building event-driven applications and functions. It's lightweight, modern, and perfect for creating efficient serverless functions and microservices. Flogo is designed to be cloud-native and easily adaptable to the demands of modern architectures.  
Here's what makes Flogo stand out:
  • Ultra-lightweight: Flogo boasts a small footprint, minimizing resource consumption and making it ideal for resource-constrained environments like serverless functions, edge devices, and IoT gateways.
  • Visual Development:Flogo offers an intuitive web-based UI and a drag-and-drop interface for designing and building applications. This visual approach simplifies development and makes it accessible to a wider range of users.
  • Extensive Connectivity: Flogo provides a rich set of connectors and activities to integrate with various systems, services, and protocols, including databases, messaging systems, APIs, and more.
  • Flexible Deployment:Deploy Flogo applications as serverless functions (AWS Lambda, Azure Functions, Google Cloud Functions), microservices, or even directly to edge devices.
  • Enhanced Scalability: Flogo applications can be easily scaled to handle increasing workloads and demands.
With Flogo Enterprise, you get all the benefits of the open-source framework plus:
  • Advanced Management and Monitoring: Centralized management and monitoring capabilities for Flogo applications deployed across your environment.
  • Enterprise-Grade Security: Robust security features to protect your applications and data.
  • Support for Mission-Critical Deployments: Enhanced support and maintenance for production deployments.

Why Terraform?

Terraform is an open-source IaC tool that lets you define and manage your infrastructure as code. It supports various cloud providers and offers several advantages:
  • Automation: Say goodbye to manual deployments! Terraform automates the provisioning and management of your infrastructure.
  • Consistency: Ensure consistent deployments across different environments.
  • Version Control: Track infrastructure changes like you track code using version control systems.
  • Modularity: Create reusable modules for common infrastructure components.
Note: This article focuses solely on the deployment aspect of Flogo applications using Terraform. It does not cover the design and development of Flogo apps, which involve creating flows, defining triggers, and configuring actions. For information on designing and developing Flogo applications, please refer to the TIBCO Flogo documentation

How This Solution Works

This repository provides a Terraform configuration that:
  • Creates an IAM role for the Lambda function with the necessary permissions.
  • Builds a ZIP archive of your Flogo application code.
  • Creates an AWS Lambda function and configures it to use the Flogo binary.

Deployment Steps

  • Clone the repository:
  • Build your Flogo app:
Build your Flogo application (using TIBCO Cloud UI, Platform APIs, or Flogo Visual Code Extension), ensuring it's built for the correct target architecture (linux and amd64 for AWS Lambda).
The Flogo application in use:
flogo app for lambda deployment
  • Configure Terraform:
Follow the steps outlined in the main.tf file (provided for demonstration purposes).
Don't forget to update the file with your AWS credentials and the desired configuration for your Lambda function.
This includes things like the function's name, the IAM role it will use, and any environment variables your Flogo application needs.
https://github.com/mpandav-tibco/flogo-lambda-terraform/blob/main/main.tf
  • Run Terraform
This is where Terraform takes the stage! We'll use a few simple commands to deploy our Flogo application.
Initialize Terraform: 
This command sets up Terraform in your project directory, downloading the necessary provider plugins and initializing the backend you've configured
terraform init
Plan the changes:         
This command creates an execution plan, showing you what Terraform will do to reach the desired state defined in your configuration files. It's a great way to preview the changes before applying them.
terraform plan
Apply the changes:
This command executes the plan, provisioning and configuring the actual infrastructure resources on AWS. 
terraform apply

Customization

  • Environment variables: You can add environment variables to your Lambda function configuration in the main.tf file.
  • IAM permissions: Adjust the IAM role permissions as needed for your deployment.

Flogo Takes Flight: Your Serverless Function is Live!

And there you have it! With a few simple Terraform commands, we've successfully deployed our Flogo application as a serverless function on AWS Lambda. You can now harness the power of Flogo's event-driven capabilities without the burden of managing servers.
  • Flogo in AWS Lambda:
This screenshot from the AWS Lambda console shows your deployed Flogo function. You can see its configuration details, including the runtime, handler, memory allocation, and timeout settings. You can also monitor your function's invocations, performance, and logs from here.
Flogo app as a lambda function
  • Testing using a dummy event:
To see your Flogo function in action, you can test it by invoking it with a dummy event through the AWS Lambda console. This will allow you to verify that your function is configured correctly and executing as expected.
Test you lambda function with dummy event

Benefits of this Approach

By adopting this Terraform-driven deployment strategy for your Flogo applications, you gain several advantages:
  • Increased Automation: Eliminate manual steps and errors by automating the entire deployment process.
  • Improved Consistency: Ensure consistent and repeatable deployments across different environments.
  • Enhanced Collaboration: Use version control to track changes and collaborate effectively with your team.
  • Simplified Management: Manage your infrastructure as code, making it easier to update, scale, and maintain.
  • Reduced Costs: Leverage the cost-effectiveness of serverless computing with AWS Lambda.

Conclusion

By combining the flexibility and power of Flogo with the automation and efficiency of Terraform, you can unlock new possibilities for serverless development. This approach not only simplifies deployments but also promotes consistency, scalability, and maintainability in your cloud infrastructure. Embrace the power of IaC and elevate your Flogo applications to new heights!

References

Discussion
You
0