Production Ready Kumologica: Github Action simplified

Generate Github Action workflow

Kumologica
5 min readDec 5, 2023
Photo by Markus Winkler on Unsplash

This is a continuation of article:

In version 3.2.2 of the Kumologica SDK, a significant enhancement has been introduced — the seamless integration of GitHub Actions in both the Command Line Interface (CLI) and the Kumologica Designer. This new feature is designed to simplify the creation of GitHub Action workflow files, requiring only a minimal set of commands to efficiently build and deploy Kumologica flows into various cloud providers.

This article will specifically delve into leveraging GitHub Actions to deploy Kumologica flows into an AWS account using CloudFormation. While the Kumologica CLI also supports Terraform, exploring this capability will be the focus of a future article.

Kumologica CLI

The creation of a GitHub Actions workflow becomes a seamless task with the simple invocation of the kl export github aws command. The following is an example command to deploy kumologica flow containing tags, environment variable, api gateway trigger with new api gateway creation:

kl export github aws  \
--z lambda.zip \
--b kumologica-designer-deploy-11111111-2222222 \
--description 'kumologica flow' \
--environment '{"Variables":{"env1":"env1value1"}}' \
--tags '{"tag1":"t1value1","tag2":"t2value2"}' \
--timeout 21 \
--memory 512 \
--triggers '[{"api":{"apiId":"create new","stage":"test"}}]' \
--project-directory . \
--region ap-southeast-2

Developers can choose between CloudFormation and Terraform scripting languages using — lang option. If omitted, the default choice is AWS CloudFormation.

The set of options supersedes the options provided by kl export cloudformation command. This ensures all options required by cloudformation export will be provided within workflow file.

The generated workflow file is, by default, placed in the current working directory. However, developers have the option to customise the destination by using the -output-file-name option. This allows specifying both the path and the yaml file name for the generated workflow, offering adaptability to different project deployment strategies.

Kumologica Designer

Within Kumologica Designer, GitHub Action workflow export becomes available upon logging into the AWS account. This integration is designed to enhance the developer experience by automating various aspects of the workflow.

To maximise the benefits of GitHub Action workflow export, it’s highly recommended to input as many AWS deployment details as possible within Kumologica Designer. This includes environment variables, triggers, Lambda settings, and tags. By providing comprehensive details, developers ensure that the generated workflow file is enriched with all necessary information.

The export command is available on Deploy AWS panel after successful connection to the AWS account:

After exporting the GitHub workflow, the resulting file is automatically created in the project’s directory at .github/workflows/workflow.yaml. This organisation ensures that the workflow file is triggered by github actions according to event definition.

AWS Bucket

Kumologica designer automatically creates bucket for cloud formation based deployment when necessary. The bucket name starts with kumologica-designer-deploy followed by random string. The exact bucket name is searched in logged in AWS account and included into github workflow file. If aws bucket has not been found then workflow must be updated with valid aws bucket name meant for lambda deployments.

Generated workflow

The following workflow is generated by the cli or Kumologica Designer:

name: |
Example github action workflow demonstrating deployment
of Kumologica flow to the aws account
Generated by kumologica sdk 3.2.2 on 2023-12-05T23:58:47.331Z
on:
push:
branches:
- main
env:
LAMBDA_NAME: testrepo-flow
BUCKET_NAME: kumologica-designer-deploy-11111111-2222222
AWS_REGION: ap-southeast-2
KL_DESCRIPTION: 'kumologica flow'
KL_ENVIRONMENT: '{"Variables":{"env1":"env1value1"}}'
KL_TAGS: '{"tag1":"t1value1","tag2":"t2value2"}'
KL_TIMEOUT: 21
KL_MEMORY: 512
KL_TRIGGERS: '[{"api":{"apiId":"create new","stage":"test"}}]'

jobs:
deploy:
name: Deploy kumologica flow
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]

steps:
# checkout repository
- name: checkout sources
uses: actions/checkout@v2

# setup aws credentials
- uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

# setup right node version
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

# install kumologica cli
- name: Install kumologica cli
run: |
npm install -g @kumologica/sdk --ignore-scripts

# build kumologica flow
- name: build kumologica flow lambda
run: kl build aws

# generate cloudformation script
# note we pass environment variables so iam role will
# contain valid resources
- name: generate cloudformation script
run: |
kl export cloudformation \
--description '${{ env.KL_DESCRIPTION }}' \
--environment '${{ env.KL_ENVIRONMENT }}' \
--tags '${{ env.KL_TAGS }}' \
--timeout ${{ env.KL_TIMEOUT }} \
--memory ${{ env.KL_MEMORY }} \
--triggers '${{ env.KL_TRIGGERS }}' \
--project-directory . \
--bucket-name ${{ env.BUCKET_NAME }} \
--zip-file-name lambda.zip

# cloud formation package
- name: cf package
run: |
aws cloudformation package \
--template-file ./build/template.json \
--s3-bucket ${{ env.BUCKET_NAME }} \
--s3-prefix ${{ env.LAMBDA_NAME }} \
--output-template-file template.yml

# cloudformation deploy
- name: Deploy CloudFormation Stack
uses: aws-actions/aws-cloudformation-github-deploy@v1.0.3
with:
name: ${{ env.LAMBDA_NAME }}
template: template.yml
capabilities: CAPABILITY_NAMED_IAM, CAPABILITY_AUTO_EXPAND
no-fail-on-empty-changeset: "1"

Assumptions

AWS Access

It is assumed that the GitHub repository has defined action secrets named AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

The IAM user associated with the provided AWS access key should possess sufficient permissions. These permissions should extend to managing CloudFormation stacks, Lambda functions, IAM roles, and any other resources referenced by the Kumologica flow.

Github Workflow

The workflow is configured to trigger when sources are pushed to the main branch. However, this may need adjustment based on the branching and deployment strategy specific to the project. Developers should customise this trigger event according to their preferred release workflow.

Upon generating the workflow file, it is essential to conduct a thorough review. Developers should check for any missing details that might be required for successful deployment. This includes verifying environment variables, deployment triggers, Lambda settings, and any other project-specific configurations.

Conclusion

Kumologica Designer plays a pivotal role in simplifying tasks for developers. The implementation of Kumologica CLI and Kumologica Designer creates a cohesive ecosystem, where tasks spanning from design to deployment are seamlessly integrated. This synergy further amplifies the ease with which developers can navigate and execute tasks within the Kumologica environment.

As Kumologica CLI continues to advance, developers can anticipate a more sophisticated and user-friendly experience, ultimately allowing them to unleash their creativity and innovation in building robust and efficient applications.

Remember Kumologica is free to download and use. Go ahead and give it a try, we would love to hear your feedback.

More information

--

--

Kumologica
Kumologica

Written by Kumologica

Kumologica is the first low-code development solution that makes your integration services run on serverless compute regardless the cloud provider.

No responses yet