Skip to main content

AWS CDK package that helps deploying a lambda function.

Project description

AWS Lambda Pipeline

A library that creates a full out-of-the-box solution for AWS Lambda with CI/CD pipeline.

Remarks

The project is written by Deividas Tamkus, supervised by Laimonas Sutkus and is owned by iDenfy. This is an open source library intended to be used by anyone. iDenfy aims to share its knowledge and educate market for better and more secure IT infrastructure.

Related technology

This project utilizes the following technology:

  • AWS (Amazon Web Services).
  • AWS CDK (Amazon Web Services Cloud Development Kit).
  • AWS CloudFormation.
  • AWS Lambda.
  • AWS CodePipeline.

Assumptions

This library project assumes the following:

  • You have knowledge in AWS (Amazon Web Services).
  • You have knowledge in AWS CloudFormation.
  • You are managing your infrastructure with AWS CDK.
  • You are writing AWS CDK templates with a python language.

Install

The project is built and uploaded to PyPi. Install it by using pip.

pip install aws-lambda-pipeline

Or directly install it through source.

./build.sh -ic

Description

This package creates a Lambda function and a pipeline for a complete out-of-the-box hosting infrastructure.

The pipeline takes your source code from CodeCommit and deploys it to Lambda.

Tutorial

  • Create a full infrastructure around AWS Lambda by using the following code below in your stack.
from aws_ci_cd_lambda.parameters.ssh_parameters import SshParameters
from aws_ci_cd_lambda.parameters.lambda_parameters import LambdaParameters
from aws_ci_cd_lambda.parameters.vpc_parameters import VpcParameters
from aws_ci_cd_lambda.ci_cd_lambda import CiCdLambda
from aws_cdk import core, aws_ec2, aws_iam
from aws_cdk.aws_lambda import Runtime

class MainStack(core.Stack):
    def __init__(self, scope: core.App) -> None:
        super().__init__(
            scope=scope,
            id='MyCoolStack'
        )

        # Create your own vpc or use an existing one.
        vpc = aws_ec2.Vpc(...)

        # Create an execution role for your function.
        role = aws_iam.Role(...)

        # Create a security group for your function.
        sg = aws_ec2.SecurityGroup(...)

        vpc_params = VpcParameters(
            vpc=vpc,
            subnets=vpc.isolated_subnets,
            security_groups=[sg],
        )

        lambda_params = LambdaParameters(
            execution_role=role,
            lambda_memory=1024,
            lambda_timeout=60,
            lambda_runtime=Runtime.PYTHON_3_6,
            lambda_handler='manage.runner',
        )

        pipeline_params = SshParameters(
            secret_id='MyCoolSecret',
            secret_arn='arn:aws:secretsmanager:region:account_id:secret:MyCoolSecret-rAnDomStrinG'
        )   

        self.ci_cd_lambda = CiCdLambda(
            scope=self,
            prefix='MyCool',
            vpc_params=vpc_params,
            lambda_params=lambda_params,
            ssh_params=pipeline_params
        )
  • Provision you infrastructure with CloudFormation by calling cdk deploy.

  • After you provision your infrastructure, go to AWS CodeCommit in your AWS Console.

  • Find a newly created git repository.

  • Commit any code you want to the newly created repository to trigger a pipeline.

(A tutorial on pushing code to remote repositories: AWS Tutorial).

(A tutorial on setting up git ssh with aws git repositories: AWS Tutorial)

Release history

2.0.1

Bug fix.

2.0.0

Refactor. Increase clarity.

1.1.0

Major refactoring and minor updates and fixes.

1.0.1

Made use CDK version 1.27.0

1.0.0

Initial commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_ci_cd_lambda-2.0.1.tar.gz (7.8 kB view hashes)

Uploaded Source

Built Distribution

aws_ci_cd_lambda-2.0.1-py3-none-any.whl (23.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page