This guide covers how to create your own Cycloid private stack from scratch. The source code for each steps in the documentation is available here.

We will create a stack called stack-lambda to create & deploy an AWS Lambda function using a pipeline.

Here is an overview of the final result: Final pipeline

This pipeline will get the source code of the Lambda from Git, build it and push it into an AWS S3 bucket. Then create and deploy an AWS Lambda function using this code with Terraform. The code is built before the Lamdba function because Terraform needs an archive file to create the Lambda resource properly.

Requirements

To simplify the step by step guide we assume that you provide the following elements:

  • An empty Git repository (you can use Github, Bitbucket, Gitlab, AWS CodeCommit, etc.):
    • Later on, we will create 3 branches (stacks, config and code).
    • ReadOnly SSH key to access to the repository.
  • Two empty AWS S3 buckets with versioning enabled:
    • ($ organization_canonical $)-deploy: Store CI artifacts (built code for the AWS Lambda function).
    • ($ organization_canonical $)-terraform-remote-state: Store Terraform remote state file.
  • Amazon access key:
    • Require permissions to create and execute a AWS Lambda function.
    • Also require read and write permissions on the previous S3 bucket.

Prepare Cycloid credentials

Let's create Cycloid credentials that we will use into our pipeline.

  • 1) SSH key Create a new credential named step by step of type git. Put your private SSH key in the ssh_key field.

This creates a Git credential under the path git_step-by-step, which will be used to interact with the Git repository.

  • 2) AWS access key Create a second credential of type aws named step by step too.

This creates an AWS credential under the path aws_step-by-step, which will be used to interact with AWS.

Cycloid credentials