Skip to content

AWS CodePipeline

AWS CodePipeline is a continuous integration and continuous delivery (CI/CD) service for fast and reliable application and infrastructure updates. This guide provides instructions on how to configure AWS CodePipeline to deploy Martini packages from your repository.

Overview

AWS CodePipeline automates the build and deployment process for your Martini packages. The pipeline can be configured to either bundle Martini Server Runtime with the packages or focus solely on deploying the packages. The process involves setting up a pipeline that fetches code from your repository, builds the necessary packages, and deploys them to your AWS environment.

Build Options:

  1. martini-build-image.yaml:
    This buildspec builds a Docker image that bundles the Martini Server Runtime with your Martini Packages, giving you control over both the runtime version and the packages within a single deployment. This method is suitable when you need to control both runtime and package versions.

  2. martini-upload-package.yaml:
    This buildspec focuses solely on deploying your Martini packages to an existing Martini Server Runtime instance. This is useful when the runtime remains the same, but frequent package updates are required.

Steps to Configure AWS CodePipeline

  1. Access the CodePipeline Code:
    The AWS CodePipeline configuration code is available on Lonti's GitHub account. You can find it here. This repository contains a setup for building and deploying Martini packages.

  2. Review the README:
    The repository includes a README file with detailed instructions on using the provided code. Review this file to understand the setup and configuration requirements, including choosing between the two buildspec files.

  3. Set Up Your Pipeline and CodeBuild Project:
    Clone the repository from GitHub to your local machine:

    1
    git clone https://github.com/torocloud/martini-build-pipeline-aws-codepipeline.git
    

    You will need to create an AWS CodeBuild project to run the pipeline. Ensure you set up GitHub as your source repository for the pipeline and attach the necessary permissions for both CodePipeline and CodeBuild.

    If you prefer not to manually create the CodeBuild project, CodePipeline, and other necessary infrastructure, you can use our provided Terraform template, which automates the creation of these resources based on your input requirements. Find the template here.

  4. Configure AWS Parameter Store:

For martini-build-image.yaml, define the following parameters:

Parameter Required Description
MARTINI_VERSION No The version of the Martini runtime to be used when building the Docker image. Defaults to LATEST if not provided. Explicit values are also supported.
AWS_REGION Yes AWS region for ECR.
AWS_ACCOUNT_ID Yes AWS account ID for ECR.
ECR_REPO_NAME Yes ECR repository name.

For martini-upload-package.yaml, define:

Parameter Required Description
BASE_URL Yes Martini instance base URL.
MARTINI_ACCESS_TOKEN Yes Authentication token for Martini.
ALLOWED_PACKAGES Yes A specific package name or a comma-separated list of package names to be uploaded. If not specified, all packages in the packages/ directory will be zipped and uploaded.

Behavior of martini-upload-package pipeline with ALLOWED_PACKAGES

Scenario Behavior
ALLOWED_PACKAGES is used Only the specified packages are zipped and uploaded.
ALLOWED_PACKAGES is not used All directories in the packages folder are zipped and uploaded.

Set up parameters using the following AWS CLI command:

1
PARAMETER=$(aws ssm get-parameter --name "${PARAMETER_NAME}" --with-decryption --query "Parameter.Value" --output text)

  1. Start the Pipeline Execution:
    By default, the pipeline starts a build automatically when any change is made in its source repository. However, if you need to rerun the most recent revision through the pipeline, you can do so manually using the CodePipeline console or the AWS CLI's start-pipeline-execution command.

    To manually trigger a pipeline execution, use this command:

    1
    aws codepipeline start-pipeline-execution --name pipeline-name
    

You can also extend your pipeline by adding this command into your pipeline's buildspec file, allowing for automated execution of the pipeline from the most recent revision in its source repository

Additional Resources