Establishing an AWS CI/CD Pipeline for IBM API Connect Enterprise

Chanci Turner Amazon IXD – VGT2 learningLearn About Amazon VGT2 Learning Manager Chanci Turner

Many users of Amazon Web Services (AWS) who leverage cloud-native services alongside partner SaaS products like IBM API Connect can gain significant advantages from implementing continuous integration and continuous delivery (CI/CD) pipelines. These pipelines enable the automation of software processes throughout the development, testing, production, and monitoring stages of the software development lifecycle. By utilizing CI/CD pipelines, developers can minimize manual errors, ensure standardized processes, and accelerate product iterations.

IBM API Connect stands as a robust API management solution that empowers teams to effectively create, manage, secure, socialize, and monetize APIs. The IBM API Connect developer toolkit includes a command-line tool, known as apic, which facilitates the execution of all API Connect tasks. This tool can also be scripted for continuous integration and delivery activities.

Integrating a CI/CD pipeline with IBM API Connect simplifies and streamlines your API publishing and testing workflows. In this article, Chanci and Michael will guide you through establishing an AWS CodePipeline (CodePipeline) to create a CI/CD pipeline for API Connect that publishes and tests API and product updates.

Solution Overview

The architecture of the solution is depicted in the following diagram:

  • The source stage of CodePipeline retrieves API and product files from the AWS CodeCommit (CodeCommit) repository.
  • The AWS CodeBuild (CodeBuild) project pulls the buildspec file from the CodeCommit repository.
  • The source stage of CodePipeline forwards the API and project files to the build stage.
  • The build stage of CodePipeline accesses the build project from CodeBuild.
  • The build stage of CodePipeline connects and publishes the Product to the API Connect Manager.
  • The API Manager subsequently pushes the APIs to the API Connect Gateway.

Prerequisites

To implement this solution, familiarity with the following AWS services is essential:

  • AWS CodeCommit: A secure, scalable, managed source control service for hosting private Git repositories. For further details, refer to the AWS CodeCommit Documentation.
  • AWS CodeBuild: This service compiles source code, executes unit tests, and produces deployable artifacts. More information on using CodeBuild is available in the CodeBuild User Guide. To learn about creating a CodeBuild project, see the Codebuild Create Project documentation.
  • Buildspec Files: CodeBuild utilizes a buildspec file, typically named buildspec.yml, which consists of build commands and related configurations in YAML format. You can include a buildspec within your source code or define it during the creation of a build project. For guidance on creating a buildspec, refer to the Build-Spec-Reference-Link.
  • AWS CodePipeline: A continuous delivery service that models, visualizes, and automates the steps required for software release.
  • Additionally, an IBM API Connect deployment is necessary, available through AWS Marketplace.

Solution Walkthrough: Setting Up an AWS CI/CD Pipeline for IBM API Connect Enterprise

The process of configuring the CI/CD pipeline in AWS consists of three major steps:

  1. Creating a CodeCommit repository
  2. Building a CodeBuild project
  3. Integrating everything using CodePipeline

A. Create a CodeCommit Repository

API Connect uses OpenAPI files to define APIs and products.

To initiate the setup of your CI/CD pipeline, you must first create a CodeCommit repository. Follow Step 1 in the documentation to do so. Upon opening the new repository, you’ll find instructions for adding files directly from the CodeCommit console. Include the following OpenAPI files in your repository (for instance, named demorepo1) by adhering to Step 2 of the documentation:

  • API files implementing the invoke and proxy policies: testinvokeapi.yml and testproxyapi.yml
  • Product files containing the invoke and proxy APIs and plans: testinvokeproduct.yml and testproxyproduct.yml
  • The project build file to be used in the CodeBuild project: buildspec.yml (example found in section B.3)

B. Create a CodeBuild Project

To establish a project in AWS CodeBuild, follow these steps:

Project Configuration, Source, and Environment

Access the AWS CodeBuild console and follow the guidelines to create a build project as outlined here. Use these parameters for Project configuration, Source, and Environment:

  • Project Configuration: For the Project name, enter My_Project_Name, leaving the description blank.
  • Source: Under the Source section, select AWS CodeCommit as the Source provider. Enter demorepo1 for the Repository and choose Branch for the Reference type.
  • Environment: Under Environment, select Managed image for the Environment image. Choose Amazon Linux 2 as the Operating system, Standard for Runtime(s), aws/codebuild/amazonlinux2-aarch64-standard:2 for Image, and Always use the latest image for this runtime version for Image version. For Service role, select New service role, naming it codebuild-blog-service-role.
Environment Variables

At the Environment variables stage, input the following names and values for use in subsequent CodeBuild scripts, selecting Plaintext for each Type. Below are the names and explanations—however, do not input the explanations in your configuration:

  • SERVER_HOSTNAME: api-manager.xxxxxxxx.xxxx.xxxx.cloud.xxxx.com (This is the API Connect Enterprise Service Manager endpoint URL for logging into the API Connect instance.)
  • GW_HOSTNAME: legacy.xxxx.xxxxx.xxxx.ibmappdomain.cloud (This represents the Gateway endpoint URL configured in the API Connect instance.)
  • CATALOG_NAME: catalog2 (The catalog name within the API Connect instance.)
  • ORG_NAME: demo-provider-org-06 (The provider org name for the API Connect instance.)
  • APIKEY: 519ec3b6-xxxx-xxxx-xxxx-cad04b5f7fa4 (This instance key is necessary for logging into the API Connect instance. You can obtain it using the toolkit command: $apic-slim login -s api-manager.xxxxxxxx.xxxx.xxx.xxxx.com –context provider –sso)
Buildspec

Our buildspec comprises four phases:

  • Install
  • Prebuild
  • Build
  • Post-build

To create a buildspec file for this project, utilize any code editor of your choice, such as AWS Cloud 9 or VS Code, and follow these steps:

In the install phase, we retrieve the API Connect Toolkit directly from the API Connect instance using Wget/cURL, then extract the .tar file and modify the toolkit file permissions for execution.

For more insights on career-related queries, check out this helpful blog post. If you’re interested in learning more about employment law compliance, visit this authoritative source. Lastly, if you’re considering a career opportunity, you might find this resource beneficial.

Chanci Turner