App Connect

 View Only
Expand all | Collapse all

Building an AWS CI/CD Pipeline for IBM App Connect Enterprise v 12 on AWS Ipaas

  • 1.  Building an AWS CI/CD Pipeline for IBM App Connect Enterprise v 12 on AWS Ipaas

    Posted Thu August 17, 2023 05:55 AM

    Hi with the release of IBM App Connect Enterprise (iPaaS) on AWS and new API to interact with this service /instance on AWS: 

    https://www.ibm.com/docs/en/app-connect/saas?topic=overview-openapi-document

    Ibm remove preview
    View this on Ibm >

    can I be able to replicate same CI/CD using AWS stack  codebuild,codepipeline and codedeploy to have a stating concept to be able to deploy .BAR files to the independent integration server running on AWS IBM App Connect Enterprise (iPaaS)

    similar to this solution Building an AWS CI/CD Pipeline for IBM API Connect Enterprise for IBM API Connect

    Building an AWS CI/CD Pipeline for IBM API Connect Enterprise | Amazon Web Services

    Amazon Web Services remove preview
    Building an AWS CI/CD Pipeline for IBM API Connect Enterprise | Amazon Web Services
    Using a CI/CD pipeline with IBM API Connect can help simplify and streamline your API publishing and testing workflows. In this blog post, Senthil and I will show you how to set up AWS CodePipeline (CodePipeline) to build an API Connect CI/CD pipeline to publish and test APIs and product changes.
    View this on Amazon Web Services >

    I will appreciate a detail analysis and technical response to this 

    Regards

    Rolivhuwa



    ------------------------------
    Rolivhuwa Collins Makhavhu
    ------------------------------



  • 2.  RE: Building an AWS CI/CD Pipeline for IBM App Connect Enterprise v 12 on AWS Ipaas

    Posted Wed August 23, 2023 11:28 AM

    Hi Rolivhuwa,

    Thanks for getting in touch. Any tool or programming languages that can issue http requests, should be able to interact with the IBM App Connect API (SaaS). As you have pointed out, AWS has a few services that can be used to together to build out a CI/CD pipeline, e.g. AWS CodeBuild, AWS CodePipeline and AWS CodeDeploy. Of these services, it looks like AWS CodeDeploy is well suited for the "deploy a BAR file to a new (or existing) Integration Runtime" scenario. AWS CodeDeploy supports running of shell scripts, so I'll be using curl to make issue http requests.

    There are various ways to do the AWS CodeDeploy setup in your AWS account, here's one example:

    1. Package up your BAR file into a zip file and then upload it to an AWS S3 bucket. This zip file will contain other content too which I'll explain in more detail further below. 
    2. Create an EC2 instance in your AWS account that has the CodeDeploy Agent software running on it.
    3. Create your AWS CodeDeploy "Application" and "deployment group" resources. The deployment group is where you associate your EC2 instance to AWS CodeDeploy.
    4. Create an AWS CodeDeploy "Deployment". This is where you specify the path of the zip file you want to deploy. Once created, the content of the zip file is then processed. 

    There are extra tasks that I've omitted from the above steps, e.g. setting up IAM Roles, as these are more standard AWS task that are already covered in the CodeDeploy documentations.

    The zip file that I referred to in step 1 above, need to contain a appspec.yml file. In this file you can define a hooks section where you can specify shell scripts to run. These shell scripts will also needs to be added the zip file. These shell scripts will executed on the CodeDeploy Agent (EC2 instance). It is in these shell scripts where you can make your http requests to deploy a bar file to an Integration runtime. Here's an example of this shell script:

    #!/usr/bin/env bash
    
    set -ex
    
    export hostname=https://api.p-lon-c1.appconnect.automation.ibm.com
    export clientId='xxxx'
    export clientSecret='xxx'
    export instanceId='xxx'
    export apiKey='xxx'
    
    ##
    ## Create token
    ##
    curl -s --request POST \
      --url "${hostname}/api/v1/tokens" \
      --header 'Content-Type: application/json' \
      --header "X-IBM-Client-Id: ${clientId}" \
      --header "X-IBM-Client-Secret: ${clientSecret}" \
      --header "x-ibm-instance-id: ${instanceId}" \
      --data "{
      \"apiKey\": \"${apiKey}\"
    }" | jq -r '.access_token' > /tmp/appconnect_token.txt
    
    export appConnToken=$(cat /tmp/appconnect_token.txt)
    echo $appConnToken
    
    
    ##
    ## Upload Bar file
    ##
    export bar_url=$(curl -s --request PUT \
      --url "${hostname}/api/v1/bar-files/myBarFileV1" \
      --header "Authorization: Bearer ${appConnToken}" \
      --header 'Content-Type: application/octet-stream' \
      --header "X-IBM-Client-Id: ${clientId}" \
      --data-binary @/path/to/bar/file/myBarFile.bar | jq -r '.url')
    
    
    ##
    ## Deploy Bar file to an Integration Runtime
    ##
    irCrFilePath="/path/to/irCr.json"
    
    export irCr=$(jq --arg barUrl $bar_url '.spec.barURL[0] = $barUrl' $irCrFilePath)
    export irName=$(jq -r '.metadata.name' $irCrFilePath)
    
    curl --request PUT \
      --url "${hostname}/api/v1/integration-runtimes/${irName}" \
      --header "Authorization: Bearer ${appConnToken}" \
      --header 'Content-Type: application/json' \
      --header "X-IBM-Client-Id: ${clientId}" \
      --data "$irCr"
    
    exit 0

    This shell script is just a proof of concept to illustrate the three main http requests that are required to deploy a bar file, create token, upload BAR file,  and Deploy BAR file. This script is also reliant on an irCr.json file. This json file is just a sample integration runtime spec, which I'm using as a template to create/update my integration runtime:

    {
        "metadata": {
          "name": "pleaseReplaceMe",
          "annotations": {},
          "labels": {
            "appconnect.ibm.com/designerapiflow": "false",
            "appconnect.ibm.com/designereventflow": "false",
            "appconnect.ibm.com/toolkitflow": "true",
            "component-name": "appconnect"
          }
        },
        "spec": {
          "barURL": [
            "pleaseReplaceMe"
          ],
          "configurations": [],
          "forceFlowBasicAuth": {
            "enabled": true
          },
          "replicas": 1,
          "template": {
            "spec": {
              "containers": [
                {
                  "name": "runtime",
                  "resources": {
                    "limits": {
                      "cpu": "500m",
                      "memory": "500Mi"
                    }
                  }
                },
                {
                  "name": "designerflows",
                  "resources": {
                    "limits": {
                      "cpu": "500m",
                      "memory": "500Mi"
                    }
                  }
                },
                {
                  "name": "designereventflows",
                  "resources": {
                    "limits": {
                      "cpu": "500m",
                      "memory": "500Mi"
                    }
                  }
                },
                {
                  "name": "proxy",
                  "resources": {
                    "limits": {
                      "cpu": "500m",
                      "memory": "500Mi"
                    }
                  }
                }
              ]
            }
          },
          "version": "12.0"
        }
      }

    I hope that helps, and let me know if have any more questions. 

    Kind regards, 

    Sher Chowdhury



    ------------------------------
    Sher Chowdhury
    ------------------------------



  • 3.  RE: Building an AWS CI/CD Pipeline for IBM App Connect Enterprise v 12 on AWS Ipaas

    Posted Wed October 18, 2023 06:18 AM

    Hi Rolivhuwa,

    I've just published a blog post on this topic, it's called Using the App Connect Public API with AWS CodeDeploy

    Hopefully that blog answers your question, but if not then please do get in touch. 



    ------------------------------
    Sher Chowdhury
    ------------------------------