2. Infrastructure as Code using Jenkins

2.1. Overview

This document describes the process of setting up an openIDL node using Infrastructure as a Code. This document details the process that involves automation pipelines prepared using Jenkins and its dependant platform. The following are the technology tools required.

  1. GitHub

  2. Jenkins

  3. Terraform Cloud/Terraform Enterprise

  4. AWS Cloud

  5. Ansible Tower/AWX (Opensource)

NOTE: When setting up nodes, all nodes must use the same environment. It is not possible to connect with different environments. For example, a test carrier node cannot connect to a dev aais and analytics network.

Throughout this document you will find sections, sub sections, paragraphs or steps that apply to one or the other path. This will be designated with a if statement or a flag in the right part of the page.

2.1.1. Instructions

If you see a checkbox then you will find a step in the iac-workbook.

2.2. Introduction

2.2.1. Architecture

_images/iac-architecture.png

2.2.2. High Level Workflow

The below are the stages required to complete to get the node up and running.

  1. Prepare Amazon Web Services account

  2. Prepare GitHub Repository

  3. Prepare Terraform Cloud/Enterprise

  4. Prepare Jenkins

  5. Prepare Ansible Tower/AWX (open source version)

  6. Deploy Base Infrastructure (AWS cloud)

  7. Deploy Blockchain Network (New network/join existing network)

  8. Deploy OpenIDL application

2.2.3. Configuration Worksheet

This section is pending…

2.3. Prepare Amazon Web Services Account

The AWS account needs to be prepared before the actual resources are deployed as a prerequisite.

note As a first step note down the aws account number as it will be used later

In this phase, the following steps are performed at high level.

  1. Enable an IAM role with permission policy

  2. Enable an IAM user

  3. Enable trust policy

  4. Prepare Cognito prerequisite

2.3.1. Setup IAM Role

checkbox Setup IAM Role for terraform

  1. Login to AWS console using either a root account or IAM user with administrative rights

  2. Go to IAM and go to roles under access management and click on create role

  3. Select type of trusted entity as “AWS account”

  4. Keep the default for the account.

  5. Choose “Require external ID” and enter “terraform”. Then click “next”

    _images/select-trusted-entity.png
  6. Then click on create policy, select json and update the policy content with below policy to limit only necessary permissions for the IAM role to be used by terraform to manage AWS resources.

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "AllowServices",
                "Effect": "Allow",
                "Action": [
                    "iam:*",
                    "ec2:*",
                    "s3:*",
                    "cloudtrail:*",
                    "cloudwatch:*",
                    "logs:*",
                    "ses:*",
                    "cognito-idp:*",
                    "eks:*",
                    "kms:*",
                    "dynamodb:*",
                    "acm:*",
                    "autoscaling:*",
                    "elasticloadbalancing:*",
                    "ebs:*",
                    "route53:*",
                    "route53domains:*",
                    "sts:*",
                    "secretsmanager:*",
                    "cloudformation:ListStacks",
                    "sns:*",
                    "application-autoscaling:*",
                    "lambda:*"
                ],
                "Resource": "*"
            }
        ]
    }
    
  7. Add necessary meaningful tags which are arbitrary for the policy

    Example:

    Owner = “”

    Used_by = “terraform”

    Application = “openidl”

  8. Enter a name for the IAM policy, ex: tf_admin_policy and click on create policy to finish

    _images/iac_aws_setup_3.png
  9. Once the policy is created, go back to roles screen, and create the role again click refresh and select the named policy created in previous step and hit the refresh button.

    _images/iac_aws_setup_4.png
  10. Add the necessary arbitrary tags to the IAM role this time and click Review

  11. Enter role name, a description and ensure the policy is assigned as per below screen shot and click on create role to finish setting up IAM role with necessary policy required to manage AWS

    _images/iac_aws_setup_5.png

note Note down the IAM role ARN as it is required later

2.3.2. Setup IAM User with inline policy

checkbox Setup IAM user for terraform

  1. Within IAM in AWS console go to users in access management and click on Add users

  2. Enter a username and select AWS access type as “Programmatic access” and click next

_images/image14.png
  1. Add user to specific group if applicable, otherwise key in tags and finish creating user

    Note: Do not attach any IAM policy at this moment.

  2. Create the user

  3. Note the access key id and secret key

  1. Then get back to users and open the created user, go to permissions and click on Add inline policy, click on json

    _images/image151.png
  2. Modify the below policy template by adding ARN of the IAM role created in previous step and the external id value set in previous step and click review policy “terraform” is the external id

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": [
                        "sts:AssumeRole",
                        "sts:TagSession"
                ],
                "Resource": "<AWS_IAM_ROLE_ARN>",
                "Effect": "Allow",
                "Condition": {
                "StringEquals": {
                        "sts:ExternalId": "<AWS_EXTERNAL_ID>"
                    }
                }
            }
        ]
    }
    
  3. Finally name the inline policy and finish creating it. Use “tf_user_policy”.

    _images/image161.png

note Note down the IAM user access key and secret key

note Note the IAM user ARN

2.3.3. Update IAM Role with Trust Policy

checkbox Update terraform IAM role trust policy

  1. Finally, time to update the trust policy for the IAM role created in the previous step. So, within AWS console under IAM go to roles in access management, select the role created in previous step.

  2. Go to trust relationships and click on Edit trust relationship

  3. Now update the policy document using the below template with update on IAM user ARN and finish update trust policy

    {
        "Version": "2012-10-17",
        "Statement": [
            {
            "Effect": "Allow",
            "Principal": {
                "AWS": "<IAM_USER_ARN>"
            },
            "Action": [
                "sts:AssumeRole",
                "sts:TagSession"
            ],
            "Condition": {
                "StringEquals": {
                "sts:ExternalId": "<AWS_EXTERNAL_ID>"
                }
            }
            }
        ]
    }
    

External ID is from the first step of IAM. “terraform”

note The external ID is additional security string used between IAM user and IAM role as a trust to allow permission. Node down the external ID “terraform” as it is required later

Now we have completed the following steps

  1. Created IAM role (ARN to be noted)

  2. Assigned permission policy to manage AWS resources for the IAM role

  3. Created IAM user

  4. Created inline policy and assigned to IAM user to assume the IAM role previously created

  5. Updated trust policy in IAM role to allow IAM user a permission to assume the role

2.3.4. Setup email identity and move SES out of sandbox for COGNITO

Cognito is a prerequisite for the node to setup and function. Cognito user pool is used and it allows users to self-sign in (self-register) using their email id. Hence during user self-sign in process, Cognito sends email to the user email address for verification.

These emails to users can be sent using Cognito default service or using AWS SES service.

Limitations:

  1. Cognito default allows only 50 emails per day only

Based on requirement, the option of either default email service (COGNITO_DEFAULT) or SES service (DEVELOPER) shall be chosen

2.3.5. Option1: COGNITO_DEFAULT

1. In case, Cognito default is preferred, there are no actions in adding an email address and verifying it or moving SES service out of sandbox for production is required.

2. When Cognito default is chosen, set email_sending_account = “COGNITO_DEFAULT” while preparing variables set in Terraform Cloud/Enterprise. This section is covered later.

  1. Set the below input variables as empty in variables set in Terraform Cloud/Enterprise as they are not applicable.

ses_email_identity = “” userpool_email_source_arn = “”

2.3.6. Option2: AWS SES Service (DEVELOPER)

The next option is enabling SES service for Cognito for sending emails. However Cognito supports using SES service only in the following regions for this purpose.

Hence for Cognito to work along with SES choose either one of the regions to configure SES.

Cognito supported SES regions:

  1. us-west-1

  2. us-west-2

  3. us-east-1

2. In AWS console, choose one of the regions mentioned above, go to SES service select email addresses

Login to AWS console, go to simple email service in one of the regions and add the email address and click on verify a new email address

_images/image35.png

3. Enter an email address that would be used as an identity by Cognito in sending emails to users during self-sign up.

_images/image36.png

4. A verification email would be triggered to the email address that was added. Please login to the email account and complete email id verification.

  1. note Then note down the ARN of the email address and the email address itself that was verified in SES as it is used later

_images/image37.png

6. Further go to email addresses and click on the email id that is added, then select Identity Policies and click on Create policy and select Custom Policy.

_images/image38.png

7. Edit the below policy and replace account number and email-id with the relevant values and add this policy statement to finish creating identity policy. This allows Cognito to use SES service to trigger emails upon user self-sign in to verify user identity.

{

“Version”: “2008-10-17”,

“Statement”: [

{

“Sid”: “stmnt1234567891234”,

“Effect”: “Allow”,

“Principal”: {

“Service”: “cognito-idp.amazonaws.com”

},

“Action”: [

“ses:SendEmail”,

“ses:SendRawEmail”

],

“Resource”: “arn:aws:ses:us-east-1:<aws_account_number>:identity/<emailid>”

}

]

}

_images/image39.png
  1. Finally refer the below link to move SES service out of sandbox for production use.

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html

2.4. Prepare GitHub repositories

checkbox Setup forked repository

  • If you don’t have an alternate organization into which you can fork the repositories, then create that now

  • Fork the respective repository and its mentioned branches as per the below table

  • Fetch the upstream for the respective branch and its relevant repository

2.4.1. Source code repositories (GitHub)

There are three public repositories that are used in the overall node setup.

No

Repository

Description

URL and branch

1

openidl-aais-gitops

This is the key repository that is used in setting up the node.

https://github.com/openidl-org/openidl-aais-gitops.git branch: develop-nginx-v1

2

openidl-main

application codes are managed in this repository. Indirectly used in the pipelines

https://github.com/openidl-org/openidl-main.git branch: develop

3

openidl-etl

There are lambda functions used and those code is located in this repository. Indirectly used.

https://github.com/openidl-org/openidl-etl.git branch: develop

note Node down the repository URLs and the branches

checkbox Setup github user and personal access tokens

A user account with necessary permissions to manage these repositories is required. Further provision a Personal Access Token with Selected scopes as “repo”.

The following are the areas the token is used. A single PAT or multiple PAT can be provisioned and used according to each organization decisions. Either provision one or below listed number of tokens and use accordingly.

No

PAT

Description

1

PAT 1

A personal access token which will be used by Jenkins to connect to GitHub. This token will be added as a username/password secret in Jenkins to allow it to connect to repositories successfully.

2

PAT 2

A personal access token which will be used by AWX/Tower to connect to source control to sync project (playbooks). This will be added as a source control credential in AWX/Tower and further used to sync playbooks.

3

PAT 3

A personal access token used by ansible playbooks to download content from the repository during playbook run on remote host.

  1. To provision PAT in GitHub (Source control) login to GitHub, go to settings => Developer settings => Personal access tokens => Generate new token.

  2. Name the token, set expiration as either no expiration or required number of days if decided to refresh on a specific interval.

  3. Set the selected scopes as “repo”

_images/image1.png

note Note down the personal access tokens created and the github user account in which it is created for further use

2.4.2. Best practices to consider in setting up GitHub repository

checkbox Follow best practices in github

The below are best practices recommended in setting up a GitHub repository and for more details refer to GitHub documentation. However, these are only optional for enabling the pipeline.

  1. Enable appropriate branch protection rules to manage who can push/pull to a branch

  2. Enable required status checks, either strict or loose to have controlled updates to the branch

  3. Configure how to merge based on requirements (Option A: Allow merge commits, Option B: Allow squash merging, Option C: Allow rebase merging)

  4. Disable auto merge

  5. Disable auto delete of head branch

  6. Enable who can have access to repository

  7. Enable branch protection by setting up

    1. require pull requests review before merging,

    2. require conversion resolution before merging

  8. Protect who can push to branch directly

  9. Setup notifications related to branch updates/changes

  10. Setup artifact and log retention as per needs

  11. Configure necessary secrets according to requirements at Organization, Environment or Repository level.

  12. Setup Runner configuration - Allow select actions especially those created by GitHub and verified marketplace actions as below.

note ** The last step in enabling github actions is optional as and when Github actions pipeline are used, otherwise not applicable**

_images/iac_github_permissions.png

2.5. Prepare Terraform Cloud/Enterprise

Terraform Cloud or Terraform Enterprise are assumed to be setup. Please see your administrator for how to accomplish this.

The following are the configuration required to setup in Terraform cloud/enterprise instance.

  1. User Token/Team Token

  2. Workspaces

  3. Variable Set

2.5.1. Terraform User/Team Token

checkbox Setup terraform token (either user or team)

A user token/team token is required to allow Jenkins to authenticate and successfully communicate with Terraform. It depends on an organization to choose between the type of token used according to their need.

2.5.1.1. TFC/TFE User Token

A user API token has the same permission level as your user account. It is the only type of token which can be granted access to multiple organizations.

  1. Login to Terraform Cloud/Enterprise go to User settings

  2. Create an API token

|image1| |image2|

2.5.1.2. TFC/TFE Team Token

A team is suppose to be created before creating a team token. Refer to terraform cloud/enterprise documentation on setting up a team. Team API tokens are used by services, for example a CI/CD pipeline to perform plans and applies on a workspace. This is the preferred choice.

  1. Login to Terraform Cloud/Enterprise, go to Organization settings

  2. Go to Teams to setup up a new team and provision a team token or go to existing team and provision a team API token.

_images/image4.png

note Note down the token

2.5.2. Workspaces

checkbox Setup terraform workspaces

The terraform code to provision necessary Infrastructure resources for OpenIDL node is provisioned into two independent sets. The first set is used to provision AWS resources and the other one to provision K8s resources. There is a dependency in provisioning K8s which are addressed in the first set of code and before provisioning K8s.

For example, K8s resources like config-map, storage class and ha proxy have dependencies with the EKS cluster which gets provisioned before these resources. Hence two sets of code are managed which requires two different terraform workspaces in the environment to manage and configure. The details are below.

2.5.2.1. Workspace to manage K8S Resources

checkbox Create K8S Workspace

  1. A workspace to manage K8s resources is required. Create a new workspace and choose workflow as “API-Driven workflow” and give a meaningful name. Like <org name>-k8s-workspace

  2. Open the workspace go to settings => General and set the execution mode to Remote, Apply method as Manual and Terraform version above 1.1.2

Note: This workspace refers to the state file of AWS resources workspace.

_images/image5.png _images/image6.png _images/image7.png _images/image8.png

note Note down the workspace name created to manage K8s resources

2.5.2.2. Workspace to manage AWS Resources

checkbox Create AWS Workspace

  1. A workspace to manage AWS resources is required. Create a new workspace and choose workflow as “API-Driven workflow” and give a meaningful name. Like <org name>-aws-workspace

  2. Open the workspace go to settings => General and set the execution mode to Remote, Apply method as Manual and Terraform version above 1.1.2

  3. And finally, allow the state file of this workspace is accessible to the workspace used to manage K8s resources.

Note:This workspace shares its state file with K8s resources workspace

_images/image9.png _images/image6.png _images/image10.png

note Note down the workspace name created to manage AWS resources

2.5.3. Variable Set

checkbox Setup terraform variables set

All the terraform variables and their values (including sensitive and non-sensitive) are added in a variable set. The details of actual variables and samples can be referred in the repository openidl-aais-gitops under directory “aws/templates”.

All the variables in the templates are required to add in the variable set. The detailed description of the variable’s significance is documented the templates directory in the repository.

The variable set is preferred as it can be shared across workspaces which is the typical use case in our solution. Configure variable set and share them across the workspace’s setup in previous section.

NOTE: When you are entering variables, in case of complex data types like maps, lists etc, follow HCL format and ensure the checkbox HCL is checked. Please refer to the below link and section “variable values and format”

https://www.terraform.io/cloud-docs/workspaces/variables/managing-variables

_images/image11.png _images/image12.png

Refer to this spreadsheet that details the list of variables and its details to help populate variable set.

Use this TerraformVariables to prepare variable set in terraform cloud/enterprise.

2.5.4. Team Access

checkbox Enable team access to the workspaces (applicable when teams and its token used)

Finally in each workspace configured enable team access in case team token is chosen as preferred method for API access.

_images/image152.png

2.5.5. Terraform code changes to adapt to Terraform Cloud/Enterprise

checkbox Update terraform code to support Terraform Cloud/Enterprise as backend

Finally update the terraform code to support Terraform Cloud/Enterprise as backend for state management. Ensure that the code is updated as below before using to provision resources in the pipeline.

  1. Activate the right AWS provider configuration in the code for aws_resources code set. |image5|

  2. Comment the terraform backend section of the code in both aws_resources and k8s_resources code set in the file main.tf. Below is an example.

_images/image251.png
  1. Activate the AWS provider configuration as below for k8s_resources code set and for remaining providers like Kubernetes and helm requires no changes.

_images/image261.png
  1. Finally update/activate the code relevant code snippet as below for data.tf in k8s_resources code set.

_images/image272.png
  1. Finally ensure that the updated code is pushed to the repository.

2.6. Prepare Jenkins

It is assumed that Jenkins exist in the environment, if not refer to jenkins documentation to setup an instance in the network.

When the jenkins instance is up and running below are the configuration required to complete.

  1. Plugins

  2. Node labels

  3. Global tools configuration

  4. Configure System – Ansible Tower/AWX

  5. Credentials

2.6.1. Plugins required

checkbox Enable required jenkins plugin

The following are the additional plugins required to enable other than standard plugins which are installed during initial Jenkins’s setup.

  1. HTTP Request Plugin

  2. Source Code Plugin (Git Plugin)

  3. Ansible Tower Plugin

  1. AnsiColor

_images/image162.png

2.6.2. Node labels

checkbox Label jenkins node

The Jenkins pipeline job uses a node label “openidl”. Do either of the one to setup a node with relevant label.

Option 1: Setup “openidl” as node lable to existing node

Option 2: Setup a new node and label it as “openidl”

Option 3: Identify existing nodes in the environment and identify the label set. Then update the Jenkins pipeline code with that label to align code with the environment.

The steps to labeling a node is skipped as it can be handled by Jenkins’s administrator.

In case chosen to update the pipeline code with relevant node label. Refer to the pipeline code to the following section and replace “openidl” with custom label.

Go to the repository openidl-aais-gitops and to the folder Jenkins-jobs/. For each job code, update as required.

node {

label “openidl”

}

node(‘openidl’)

2.6.3. Global tools configuration

checkbox setup global tools configuration

  1. Go to Jenkins => Mange Jenkins => Global Tool Configuration

  2. Ensure Git and Terraform are configured according to your environment

  3. Note the command shown here works for Ubuntu node and for Linux it will be different. Hence configure Git according to your nodes operating system.

_images/image191.png

tool home should be ‘/usr/bin/git’

2.6.4. Configure System (AWX/Ansible Tower)

checkbox configure Ansible Tower plugin in Jenkins for integration between them

  1. Go to Jenkins => Manage Jenkins => Configure System

  2. Go to Ansible Tower

  3. Click on Add, Give a name to the instance “AWX”. Please note “AWX” instance name is used in Jenkins’s pipeline code. In case a different name is used, the pipeline code needs to be updated.

  4. Update the actual URL of Ansible Tower/AWX instance to make API calls

  5. Include the username/password to authenticate Jenkins in AWX/Tower. Hence get the user first created in AWX/Tower and get that credential added in Jenkins as username/password credential type before setting this up. Refer to the AWX preparation section on how to setup user account.

  6. During development instance SSL is not used, however in production environment SSL should be enabled which is not documented here, refer to relevant Jenkins’s documentation on enabling SSL.

  7. Test the connection between Jenkins and Ansible is successful to proceed further.

_images/image211.png

2.6.5. Credentials

checkbox Finally create credentials and enter the secrets used in the pipelines/integrations

The following are the listed credentials are required to create in Jenkins. Refer to example of username and password kind and secret text type to provision the three credentials in Jenkins.

No

Purpose

Cred Type

Description

1

Jenkins access to AWX

Username and Password

An AWX user account having permissions to run jobs, access required credentials, project, and resources. A username and password are used. Setup an acc in Ansible Tower and key in. Refer to Ansible Tower section.

2

Jenkins access to GitHub (source control)

Username and Password (PAT)

GitHub username and Personal Access Token. This is used by Jenkins to work with source control. Refer to tokens created previously.

3

Jenkins access to Terraform Cloud/ Enterprise

Secret Text

A User/team token created in Terraform Cloud/Enterprise. Get that added as secret text in Jenkins. Refer to token created previously.

2.6.5.1. Username and Password Type

  1. Login to Jenkins go to Manage Jenkins => Manage Credentials => Stores scoped to Jenkins (Jenkins) => Global Credentials (unrestricted) => Add credentials

  2. Then choose Kind as “Username Password” and key in username, Password, Description and a unique ID which would be referred in the pipeline code. (An example below)

_images/image221.png

2.6.5.2. Secret Text Type

  1. Login to Jenkins go to Manage Jenkins => Manage Credentials => Stores scoped to Jenkins (Jenkins) => Global Credentials (unrestricted) => Add credentials

  2. Choose Kind as secret text, enter secret text like Token in “secret” field and name the secret ID as unique since it will be used in pipeline code. (An example below)

_images/image231.png

2.7. Jenkins Jobs Configuration

2.7.1. Credentials

  1. Before configuring Jenkins’s job ensure that the required credentials relevant to the jobs are already configured in Jenkins.

Terraform credentials

AWX (Ansible Tower/AWX User credentials)

GitHub User credentials

No

Cred Type

ID

Username

Password

Descr

1

Username with password

openidl-a ais-gitops

GitHub account username

Personal access token created

GitHub credentials

2

Username with password

AWX

Ansible tower username

Ansible tower user password

Ansible Tower/AWX credentials

3

Secret text

TF_BE ARER_TOKEN

NA

Terraform user/team API token

Terraform Cloud /Enterprise access token

References: GitHub credential

_images/image561.png

References: AWX credential

_images/image571.png

References: Terraform credential

_images/image581.png

2.7.2. Job Configurations

checkbox Configure Jenkins pipeline jobs

The list of jobs to be configured are

  1. Job to provision AWS resources and K8s resources using Terraform Cloud/Enterprise

  2. Job to provision Vault using Ansible Tower/AWX

  3. Job to provision Blockchain Network using Ansible Tower/AWX

  4. Job to provision MongoDB using Ansible Tower/AWX

  5. Job to provision OpenIDL application secrets and application using Ansible Tower/AWX

2.7.2.1. Terraform Job

  1. Go to Jenkins => New Item => Give a meaningful name

  2. Select Job type as PIPELINE and proceed next

  3. Give a description to the job and move to pipeline section

  4. Select Definition as Pipeline Script from SCM

  5. Select SCM as Git

  6. Key in the Infrastructure code repository (openidl-aais-gitops) url.

  7. Select the GitHub credentials

  8. Specify the relevant branch “refs/heads/<branch-name>”.

  9. Set script path to “Jenkins-jobs/jenkinsfile-tf”.

_images/image591.png

2.7.2.2. Vault Job

  1. Go to Jenkins => New Item => Give a meaningful name

  2. Select Job type as PIPELINE and proceed next

  3. Give a description to the job and move to pipeline section

  4. Select Definition as Pipeline Script from SCM

  5. Select SCM as Git

  6. Key in the Infrastructure code repository (openidl-aais-gitops) url.

  7. Select the GitHub credentials

  8. Specify the relevant branch “refs/heads/<branch-name>”.

  9. Set script path to “Jenkins-jobs/jenkinsfile-vault”.

_images/image601.png

2.7.2.3. Blockchain Network Job

  1. Go to Jenkins => New Item => Give a meaningful name

  2. Select Job type as PIPELINE and proceed next

  3. Give a description to the job and move to pipeline section

  4. Select Definition as Pipeline Script from SCM

  5. Select SCM as Git

  6. Key in the Infrastructure code repository (openidl-aais-gitops) url.

  7. Select the GitHub credentials

  8. Specify the relevant branch “refs/heads/<branch-name>”.

  9. Set script path to “Jenkins-jobs/jenkinsfile-baf”.

_images/image611.png

2.7.2.4. MongoDB Job

  1. Go to Jenkins => New Item => Give a meaningful name

  2. Select Job type as PIPELINE and proceed next

  3. Give a description to the job and move to pipeline section

  4. Select Definition as Pipeline Script from SCM

  5. Select SCM as Git

  6. Key in the Infrastructure code repository (openidl-aais-gitops) url.

  7. Select the GitHub credentials

  8. Specify the relevant branch “refs/heads/<branch-name>”.

  9. Set script path to “Jenkins-jobs/jenkinsfile-mongodb”.

_images/image621.png

2.7.2.5. OpenIDL Application Job

  1. Go to Jenkins => New Item => Give a meaningful name

  2. Select Job type as PIPELINE and proceed next

  3. Give a description to the job and move to pipeline section

  4. Select Definition as Pipeline Script from SCM

  5. Select SCM as Git

  6. Key in the Infrastructure code repository (openidl-main) url.

  7. Select the GitHub credentials

  8. Specify the relevant branch “refs/heads/<branch-name>”.

  9. Set script path to “Jenkins-jobs/jenkinsfile-apps-secrets”.

_images/image631.png

2.8. Prepare Ansible Tower/AWX

The following configuration items are required to setup in Ansible for the pipelines to work.

  1. An User Account

  2. Credential Types

  3. Inventory, Group and Host

  4. Credentials

  5. Projects

  6. Templates

2.8.1. User Account

checkbox An user account for jenkins to make API calls to Ansible

A user account to allow Jenkins to successfully work with Ansible Tower/AWX API. The user should have necessary permissions to run jobs and its relevant objects. In development used system administrator type, however in production use role-based access control using teams/roles.

_images/image281.png

note Note down the username and password created

2.8.2. Credential Types

checkbox Custom credential types for openidl project specific in ansible

For the OpenIDL deployment there are infrastructure and application related pipelines. They require specific credentials and additional variables. Hence custom credential types are used to simply the setup. The following are the credential types and steps to configure them.

  1. OpenIDL-IAC => Used in infrastructure provisioning jobs

  2. OpenIDL-APP => Used in application deployment jobs

  3. OpenIDL-IAC-AWSUser-BAF => AWS IAM user credentials used with Blockchain automation jobs

2.8.2.1. OpenIDL-IAC

  1. Login into Ansible Tower/AWX instance, Go to Administration

  2. Go to Credential Types

  3. Click on Add

4. Name it as OpenIDL-IAC and paste the below configuration in each relevant section.

Input Configuration

fields:

  • id: aws_access_key

    type: string

    label: AWS access key

    secret: true

    help_text: AWS IAM user access key

  • id: aws_secret_key

    type: string

    label: AWS secret key

    secret: true

    help_text: AWS IAM user secret key

  • id: aws_iam_role

    type: string

    label: AWS IAM role

    help_text: AWS IAM role to be assumed

  • id: aws_external_id

    type: string

    label: AWS external id

    help_text: Externl ID set during IAM user/role configuration

  • id: aws_region

    type: string

    label: AWS region

    help_text: AWS Region

  • id: aws_account_number

    type: string

    label: AWS account number

    secret: true

    help_text: AWS account number

  • id: baf_image_repo

    type: string

    label: BAF image repository

    help_text: Blockchain automation framework Docker image repository

  • id: blk_cluster_name

    type: string

    label: Blockchain cluster name

    help_text: Blockchain EKS cluster name

  • id: app_cluster_name

    type: string

    label: Application cluster name

    help_text: OpenIDL Application EKS cluster name

  • id: gitops_repo_url

    type: string

    label: ‘Gitops repository URL (without https://)’

    help_text: Github repository URL

  • id: gitops_repo_branch

    type: string

    label: Gitops repository branch

    help_text: Branch name in Github repository

  • id: gitops_repo_user

    type: string

    label: Gitops repository user

    help_text: GITHUB repository user

  • id: gitops_repo_user_token

    type: string

    label: Gitops repository user PAT

    secret: true

    help_text: GITHUB repository user token

  • id: gitops_repo_user_email

    type: string

    label: Gitops repository user email

    help_text: GITHUB repository user email id

required:

  • aws_access_key

  • aws_secret_key

  • aws_iam_role

  • aws_external_id

  • aws_region

  • aws_account_number

  • blk_cluster_name

  • baf_image_repo

  • app_cluster_name

  • gitops_repo_user

  • gitops_repo_user_email

  • gitops_repo_user_token

Injector Configuration

extra_vars:

aws_region: ‘{{ aws_region }}’

aws_iam_role: ‘{{ aws_iam_role }}’

aws_access_key: ‘{{ aws_access_key }}’

aws_secret_key: ‘{{ aws_secret_key }}’

baf_image_repo: ‘{{ baf_image_repo }}’

aws_external_id: ‘{{ aws_external_id }}’

gitops_repo_url: ‘{{ gitops_repo_url }}’

app_cluster_name: ‘{{ app_cluster_name }}’

blk_cluster_name: ‘{{ blk_cluster_name }}’

gitops_repo_user: ‘{{ gitops_repo_user }}’

aws_account_number: ‘{{ aws_account_number }}’

gitops_repo_branch: ‘{{ gitops_repo_branch }}’

gitops_repo_user_email: ‘{{ gitops_repo_user_email }}’

gitops_repo_user_token: ‘{{ gitops_repo_user_token }}’

  1. Save and close, screenshot below.

_images/image291.png

2.8.2.2. OpenIDL-IAC-AWSUser-BAF

Similarly repeat the above steps to setup this credential type as well.

Input Configuration

fields:

  • id: baf_user_access_key

    type: string

    label: baf_user_access_key

    help_text: AWS IAM user access key for baf

  • id: baf_user_secret_key

    type: string

    label: baf_user_secret_key

    secret: true

    help_text: AWS IAM user secret key for baf

  • id: baf_user_external_id

    type: string

    label: baf_user_external_id

  • id: baf_user_assume_role_arn

    type: string

    label: baf_user_assume_role_arn

required:

  • baf_user_access_key

  • baf_user_secret_key

  • baf_user_external_id

  • baf_user_assume_role_arn

Injector Configuration

extra_vars:

baf_user_access_key: ‘{{ baf_user_access_key }}’

baf_user_secret_key: ‘{{ baf_user_secret_key }}’

baf_user_external_id: ‘{{ baf_user_external_id }}’

baf_user_assume_role_arn: ‘{{ baf_user_assume_role_arn }}’

_images/image301.png

2.8.2.3. OpenIDL-APP

Similarly repeat the above steps to setup this credential type as well.

Input Configuration

fields:

  • id: aws_access_key

    type: string

    label: AWS access key

    secret: true

    help_text: AWS IAM user access key

  • id: aws_secret_key

    type: string

    label: AWS secret key

    secret: true

    help_text: AWS IAM user secret key

  • id: aws_iam_role

    type: string

    label: AWS IAM role

    help_text: AWS IAM role to be assumed

  • id: aws_external_id

    type: string

    label: AWS external id

    help_text: Externl ID set during IAM user/role configuration

  • id: aws_region

    type: string

    label: AWS region

    help_text: AWS Region

  • id: gitrepo_name

    type: string

    label: ‘Git Repository (without https://)’

    help_text: Git repository URL

  • id: gitrepo_branch

    type: string

    label: Git branch name

    help_text: Git repository branch name

  • id: gitrepo_username

    type: string

    label: Gitrepo username

    help_text: Git repository login username

  • id: gitrepo_pat

    type: string

    label: Gitrepo PAT

    secret: true

    help_text: Git repository personl access token

  • id: app_cluster_name

    type: string

    label: Application cluster name

    help_text: OpenIDL Application EKS cluster name

  • id: vault_secret_name

    type: string

    label: vault secret name

    help_text: Vault secret name provisioned in AWS secrets manager

required:

  • aws_access_key

  • aws_secret_key

  • aws_iam_role

  • aws_external_id

  • aws_region

  • gitrepo_username

  • gitrepo_password

  • gitrepo_name

  • gitrepo_branch

  • app_cluster_name

  • vault_secret_name

Injector Configuration

extra_vars:

aws_region: ‘{{ aws_region }}’

aws_iam_role: ‘{{ aws_iam_role }}’

gitrepo_name: ‘{{ gitrepo_name }}’

aws_access_key: ‘{{ aws_access_key }}’

aws_secret_key: ‘{{ aws_secret_key }}’

gitrepo_branch: ‘{{ gitrepo_branch }}’

aws_external_id: ‘{{ aws_external_id }}’

app_cluster_name: ‘{{ app_cluster_name }}’

gitrepo_password: ‘{{ gitrepo_pat }}’

gitrepo_username: ‘{{ gitrepo_username }}’

vault_secret_name: ‘{{ vault_secret_name }}’

_images/image311.png

note Note down the credential types created

2.8.3. Inventory, Group and Host

checkbox Setting up hosts/groups in ansible inventory

The OpenIDL ansible playbooks use the inventory group “ansible_provisioners” and a localhost. Hence setup the relevant inventory, its group and host details in Ansible Tower/AWX.

  1. Login to the instance, go to Resources => Inventories => Add

  2. Name it as “ansible_provisioners and save.

_images/image321.png
  1. Now open the created inventory and go to Groups and click on Add

_images/image331.png
  1. Name the group as “ansible_provisioners”.

_images/image341.png
  1. Now go to inventory ansible_provisioners and then go to Hosts and click on Add to include localhost part of the group.

_images/image351.png
  1. Note localhost is by default added to the inventory file part of playbook configuration in the repository. In case chosen to use alternate node then ensure that the relevant node is added to the ansible_provisioners group/inventory and further the same host information is added to the inventory file located in the path “awx-automation/inventory/ansible_provisioners” file in the github repositories as well. For example, below.

  2. This entry should be added to both the repositories. (app and infra).

_images/image361.png

2.8.4. Credentials

checkbox Setup credentials that will be used for authentication in jobs

The following are the credentials to be configured in Ansible Tower/AWX.

  1. Machine credential

  2. Source Control credential

  3. OpenIDL-IAC

  4. OpenIDL-APP

  5. OpenIDL-IAC-AWSUser-BAF

2.8.4.1. Machine Credential

This credential is used by the playbook to authenticate a host to run the playbooks. It may be either a localhost or remote node. This is a system SSH credential configured to allow Ansible instance to access a host to run the playbook.

First ensure the host (localhost/remotehost) is configured such access and further the credential is added here.

  1. Go to Ansible instance => Resource => Credentials and add.

  2. Ensure the credential type chosen is Machine

  3. Enter a name, Input username of the account and add private key of the SSH key pair which is configured in the system and also enable privilege escalation method as sudo.

  4. Note that in development an account “ansible” is used with sudo permissions. The account can be adjusted with permissions carefully reviewing the playbook actions and relevant permissions only to allow sudo commands.

_images/image371.png

note Note down the credential

2.8.4.2. Source Control Credential

Similarly create a credential of type source control to enter GitHub user credential (username and PAT) to allow Ansible to successfully work with repositories. The screenshot for reference.

  1. Name the credential

  2. Select Type as Source Control

  3. Enter the GitHub username and Personal Access Token (alternate is to use SSH method)

_images/image381.png

note Note down the credential

2.8.4.3. OpenIDL-IAC

The next step is to use credential of type OpenIDL-IAC. This will be used by infrastructure jobs. A reference screenshot and significance of each field is detailed in below table.

note However the values for all the fields would not be readily available as the AWS infrastructure is not provisioned yet. Hence fill up dummy values which are unknown at the moment and later it can be populated before executing the relevant pipeline jobs.

_images/image391.png

S N o

Key

Description

1

Credential Type

Select type OpenIDL-IAC

2

AWS access key

AWS access key of GitHub actions IAM user provisioned

3

AWS secret key

AWS secret key of GitHub actions IAM user provisioned

4

AWS IAM role

AWS IAM role provisioned to be assumed by GitHub actions IAM user

5

AWS external id

“git-actions” by default

6

AWS region

AWS region in which resources are provisioned

7

AWS account number

AWS account number

8

BAF image repository

The repository in which Docker image for Blockchain Automation Framework is located. Presently this is public repository.

9

Blockchain cluster name

Name of the cluster provisioned for blockchain resources

10

Application cluster name

Name of the cluster provisioned for application resources

11

Gitops repository URL

GitHub repository URL in which infrastructure code is located

12

Gitops repository branch

GitHub repository branch to be used

13

GitOps repository user

Username has access to the repository

14

Gitops repository user PAT

Personal access token of the user to authenticate with GitHub to use with ansible playbooks

15

Gitops repository user email

User email ID of the GitHub repository user used

note Note down the credential

2.8.4.4. OpenIDL-APP

Create the credential of type OpenIDL-APP as described below which will be used by jobs related to OpenIDL application.

note However the values for all the fields would not be readily available as the AWS infrastructure is not provisioned yet. Hence fill up dummy values which are unknown at the moment and later it can be populated before executing the relevant pipeline jobs.

_images/image401.png

S N o

Key

Description

1

Credential Type

OpenIDL-APP

2

AWS access key

AWS access key of GitHub actions IAM user provisioned

3

AWS secret key

AWS secret key of GitHub actions IAM user provisioned

4

AWS IAM role

AWS IAM role provisioned to be assumed by GitHub actions IAM user

5

AWS external id

“git-actions” by default

6

AWS region

AWS region in which resources are provisioned

7

Git Repository

GitHub repository related to applications

8

Git branch name

Name of the GitHub branch

9

Gitrepo username

Email id of the GitHub user used

10

Gitrepo PAT

Personal access token created previously to use with ansible playbooks

11

Application cluster name

Application cluster name

12

Vault Secret name

Secret created in AWS secret manage which holds credentials of vault. The standard format is <orgname>-<env>-config-vault

note Note down the credential

2.8.4.5. OpenIDL-IAC-AWSUser-BAF

Finally, provision credential of type OpenIDL-IAC-AWSUser-BAF. Choose the relevant credential type, key in AWS access key, secret key, external_id and baf user assume role arn of AWS IAM user provisioned related to BAF.

note However the values for all the fields would not be readily available as the AWS infrastructure is not provisioned yet. Hence fill up dummy values which are unknown at the moment and later it can be populated before executing the relevant pipeline jobs.

_images/image411.png

note Note down the credential

2.8.5. Projects

checkbox Setup projects

The next step is to configure projects which is used to pull the ansible playbook contents from GitHub to ansible tower/AWX.

  1. openidl-aais-gitops

2.8.5.1. openidl-aais-gitops

Repeat the same above steps to configure project for infrastructure code.

_images/image431.png

note **Note down the project name”

2.8.6. Templates

checkbox Setup ansible job templates

It is time to configure ansible job templates in Ansible Tower/AWX. The following are the list of job templates required to configure.

  1. Vault install

  2. MongoDB install

  3. Blockchain install

  4. Register Users (BAF preregister users)

  5. OpenIDL application secrets install

  6. OpenIDL application install

2.8.6.1. Vault Install

  1. Login to Ansible Tower/AWX, Go to Resources => Templates => Add

  2. Key in Job name. The format is <org_name>-<env>-openidl-vault.

Org_name: First 4 characters of org_name. Note Jenkins pipeline code refers to the job template name and hence it is vital.

Env: dev | test | prod

  1. Select Job type as Run and check on Prompt on Launch

  2. Choose inventory as ansible_provisioners which was configured in previous step.

  3. Choose the project that holds the IaC code. (openidl-aais-gitops) configured in previous step

  4. Choose the relevant execution environment

  5. Choose the playbook “awx-automation/vault.yml”.

  6. Choose the following credentials.

    1. Machine credential configured in previous step

    2. OpenIDL-IAC credential configured in previous step

  7. Choose prompt on Launch for variables (mandatory)

  8. Set relevant verbosity level, Timeout at minimum 1800 seconds.

  9. Set the Option “Privilege Escalation”.

2.8.6.2. MongoDB Install

  1. Login to Ansible Tower/AWX, Go to Resources => Templates => Add

  2. Key in Job name. The format is <org_name>-<env>-openidl-mongodb.

Org_name: First 4 characters of org_name. Note Jenkins pipeline code refers to the job template name and hence it is vital.

Env: dev | test | prod

  1. Select Job type as Run and check on Prompt on Launch

  2. Choose inventory as ansible_provisioners which was configured in previous step.

  3. Choose the project that holds the IaC code. (openidl-aais-gitops) configured in previous step

  4. Choose the relevant execution environment

  5. Choose the playbook “awx-automation/mongodb.yml”.

  6. Choose the following credentials.

    1. Machine credential configured in previous step

    2. OpenIDL-IAC credential configured in previous step

  7. Choose prompt on Launch for variables (mandatory)

  8. Set relevant verbosity level, Timeout at minimum 1800 seconds.

  9. Set the Option “Privilege Escalation”.

_images/image46.png _images/image47.png

2.8.6.3. Blockchain install

  1. Login to Ansible Tower/AWX, Go to Resources => Templates => Add

  2. Key in Job name. The format is <org_name>-<env>-openidl-baf.

Org_name: First 4 characters of org_name. Note Jenkins pipeline code refers to the job template name and hence it is vital.

Env: dev | test | prod

  1. Select Job type as Run and check on Prompt on Launch

  2. Choose inventory as ansible_provisioners which was configured in previous step.

  3. Choose the project that holds the IaC code. (openidl-aais-gitops) configured in previous step

  4. Choose the relevant execution environment

  5. Choose the playbook “awx-automation/fabric-network.yml”.

  6. Choose the following credentials.

    1. Machine credential configured in previous step

    2. OpenIDL-IAC credential configured in previous step

    3. OpenIDL-IAC-AWSUser-BAF configured in previous step

  7. Choose prompt on Launch for variables (mandatory)

  8. Set relevant verbosity level, Timeout at minimum 0 seconds.

  9. Set the Option “Privilege Escalation”.

_images/image48.png _images/image49.png

2.8.6.4. Register Users

  1. Login to Ansible Tower/AWX, Go to Resources => Templates => Add

  2. Key in Job name. The format is <org_name>-<env>-openidl-register-users

Org_name: First 4 characters of org_name. Note Jenkins pipeline code refers to the job template name and hence it is vital.

Env: dev | test | prod

  1. Select Job type as Run and check on Prompt on Launch

  2. Choose inventory as ansible_provisioners which was configured in previous step.

  3. Choose the project that holds the IaC code. (openidl-aais-gitops) configured in previous step

  4. Choose the relevant execution environment

  5. Choose the playbook “awx-automation/pre-register-users.yml”.

  6. Choose the following credentials.

    1. Machine credential configured in previous step

    2. OpenIDL-IAC credential configured in previous step

  7. Choose prompt on Launch for variables (mandatory)

  8. Set relevant verbosity level, Timeout at minimum 900 seconds.

  9. Set the Option “Privilege Escalation”.

_images/image50.png _images/image511.png

2.8.6.5. OpenIDL Application Install

  1. Login to Ansible Tower/AWX, Go to Resources => Templates => Add

  2. Key in Job name. The format is <org_name>-<env>-openidl-apps

Org_name: First 4 characters of org_name. Note Jenkins pipeline code refers to the job template name and hence it is vital.

Env: dev | test | prod

  1. Select Job type as Run and check on Prompt on Launch

  2. Choose inventory as ansible_provisioners which was configured in previous step.

  3. Choose the project that holds the application code. (openidl-main) configured in previous step

  4. Choose the relevant execution environment

  5. Choose the playbook “awx-automation/deploy-openidl-apps.yaml”.

  6. Choose the following credentials.

    1. Machine credential configured in previous step

    2. OpenIDL-APP credential configured in previous step

  7. Choose prompt on Launch for variables (mandatory)

  8. Set relevant verbosity level, Timeout at minimum 900 seconds.

  9. Set the Option “Privilege Escalation”.

_images/image521.png _images/image531.png

2.8.6.6. OpenIDL Application Secrets Install

  1. Login to Ansible Tower/AWX, Go to Resources => Templates => Add

  2. Key in Job name. The format is <org_name>-<env>-openidl-secrets

Org_name: First 4 characters of org_name. Note Jenkins pipeline code refers to the job template name and hence it is vital.

Env: dev | test | prod

  1. Select Job type as Run and check on Prompt on Launch

  2. Choose inventory as ansible_provisioners which was configured in previous step.

  3. Choose the project that holds the application code. (openidl-main) configured in previous step

  4. Choose the relevant execution environment

  5. Choose the playbook “awx-automation/deploy-openidl-secrets.yaml”.

  6. Choose the following credentials.

    1. Machine credential configured in previous step

    2. OpenIDL-APP credential configured in previous step

  7. Choose prompt on Launch for variables (mandatory)

  8. Set relevant verbosity level, Timeout at minimum 900 seconds.

  9. Set the Option “Privilege Escalation”.

_images/image541.png _images/image551.png

2.8.7. Summary

At this stage the preparation phase is completed in getting the below technology tools and environment readiness.

checkbox Sourcecode repositories

checkbox AWS account

checkbox Terraform Cloud/Enterprise

checkbox Jenkins

checkbox Ansible Tower/AWX

The next stage is the deployment phase in preparing base infrastructure, setting up blockchain network and deploying openidl application.

2.9. Deploy Base Infrastructure in AWS Cloud

Since the preparation phase is completed, the next phase is deployment in which getting the jenkins pipelines executed to provision the following.

  1. Base infrastructure deployment in AWS cloud (uses Terraform/Jenkins)

  2. Vault deployment (uses Jenkins/Ansible)

  3. Blockchain deployment (uses Jenkins/Ansible)

  4. MongoDB deployment (uses Jenkins/Ansible)

  5. OpenIDL application secrets deployment (uses Jenkins/Ansible)

  6. OpenIDL application deployment (uses Jenkins/Ansible)

The following section describes how to prepare and execute each Jenkins job to provision on the node. Let us first focus on deploying base infrastructure in AWS cloud.

checkbox Base infrastructure preparation

2.9.1. Executing Jenkins pipeline to provision AWS resources using Terraform Cloud

checkbox Provision AWS resources using Jenkins/Terraform pipeline

This is the job previously setup. It is used to provision AWS resources and K8s resources. Before triggering the pipeline ensure that the following are already setup as documentation in previous section.

  1. Terraform Cloud/Enterprise (Workspaces, VariableSet, API Token)

  2. Jenkins (Credentials, Job configuration)

  3. Terraform code changes and pushed to repository

note First run after configuring the job is dummy run as the option shows as “Build Now”. This will fail and will update your job with relevant parameters required for the job to run. Further runs will show an option Build with Parameters which will be right run.

  1. To trigger the job, go to Jenkins => relevant job (terraform) => Build with Parameters.

  2. Enter the values to the inputs as listed below.

Field

Description

TF_ADDRESS

Terraform Cloud/Enterprise endpoint

TF_ORG_NAME

Organization name setup in Terraform

T F_AWS_WORKSPACE

Terraform workspace name setup specifically for AWS resources

T F_K8S_WORKSPACE

Terraform workspace name setup specifically for K8s resources

GITHUB_URL

GitHub repository to check out the code

GITHUB_BRANCH

GitHub branch specifically to check out the code

  1. The job runs terraform plan and asks manual confirmation before running terraform apply. This job will run first to provision AWS resources and further run for K8s resources. Hence twice it asks input to confirm before performing terraform apply.

_images/image64.png

NOTE:

It is noticed that sometimes the request to upload configuration data (git repository content) to Terraform fails with below HTTP error 422. In case when you see the pipeline failed with this error, rerun the pipeline which will help.

Status

Response

Reason

422

JSON API error object

Malformed request.

Once the AWS resources are provisioned successfully, carefully review the resources provisioned and perform the below actions.

2.9.2. Disable access keys and setup new access keys

checkbox Disable existing keys, create new keys and note down credentials for next stage

The terraform pipeline provisions three vital AWS IAM user resources. As this is provisioned part of terraform these user access and secret keys are in terraform state file.

The initial provisioned access keys and secret keys should not be used, and it should be set as INACTIVE(Do not delete them). Further create new access keys and secret keys for these users and use them.

NOTE: The name of the user has the first part truncated from the org_name. That is “carrier” becomes “carr-dev-baf-automation” which could cause a problem during testing if creating more than one carrier.

note Note down the access keys and secret keys of the IAM users. Also note down the IAM roles that these users will assume. Refer to inline policy of the users to identify the same if required

2.9.3. Remove security rule created by Kubernetes NGINX proxy deployment

checkbox Remove mentioned security group rules

Once AWS resources are provisioned. The following security rules from the security groups are required to remove as they are deployed by default by Ingress Controller deployment in Kubernetes cluster.

Refer to the following security groups to identify the rule and remove it.

  1. Go to EC2/VPC services section in the AWS console

  2. Go to Security Group section

  3. Look for the security group as mentioned in the above table

_images/image42.png
  1. Open the security group and look for the rule related to ICMP set with source 0.0.0.0/0 and remove it. The below screenshot is a reference. Please remove only this rule only.

_images/image43.png
  1. Remove this rule from both (two) security groups as mentioned the table above.

2.9.4. Confirm email id subscription confirmation

  1. During the resource provisioning list of email ids included for SNS notification subscription

  2. The infra provisioning would have subscribed these list of email ids to the SNS topics

  3. The subscription process involves SES emailing subscription confirm/verify emails to individual email Ids

  4. Each email account owners required to verify them before SNS could start sending notifications

2.9.5. Review and collect AWS resources details required:

checkbox Collect AWS resource information based on the infra provisioned as it is required in next pipeline jobs

  1. account number it not noted previously

  2. aws region

  3. application EKS cluster name

  4. blockchain EKS cluster name

  5. vault secret name (refer to secret manager)

  6. <orgname>-<env>-gitactions-admin credentials

  7. <orgname>-<env>-openidl-apps-user credentials

  8. <orgname>-<env>-baf-user credentials

  9. <orgname>-<env>-baf-automation role ARN which will be assumed by *-baf-user

10. <orgname>-<env>-gitactions-admin role ARN which will be assumed by *-gitactions-admin user 11.<orgname>-<env>-openidl-apps role ARN which will be assumed by *-openidl-apps-user 12. cognito pool id 13. cognito app client id 14. s3 buckets created for HDS and IDM-ETL functions

In case anything missed to list here, while setting up the environment let us identify and include.

2.10. Deploy Blockchain Network

The next phase is blockchain deployment phase in which the following steps are required to perform.

  1. Prepare config file for blockchain network setup

  2. Update OpenIDL related credentials in Ansible

  3. Deploy vault

  4. Deploy Blockchain Network (new network or add a node to existing network)

2.10.1. Preparing Config file for Blockchain network setup

checkbox Prepare config file for blockchain network setup

Since the first step of provisioning base AWS infrastructure is completed, the next step would be preparing the dependent components and setting up either blockchain network/a node to join the existing network depends on your organization role.

The template and example configuration files are in the repository “openidl-aais-gitops” under “awx-automation/config-references”. Using these templates, the actual config file can be created and placed in the path “awx-automation/config”. The file name should follow the naming standard as below.

FileName format: <org-name>-config-<env>.yml

Org-name: Up to first 4 characters of the org name Env: dev | test | prod

The configuration file should be placed in the path “awx-automation/config/<org-name>-config-<env>.yml

NOTE: Make sure to atleast have a defaultchannel listed under channels in organization configuration file. New channel information may be added when required in the configuration file and maintained in the repository.

Please ensure that this configuration file is prepared and exist in the mentioned directory path in the github repository before triggering deployment jobs in Jenkins.

NOTE: The details in preparing the config file are to refer from the repository templates.

_images/image651.png

After preparing the configuration file as mentioned above and ensure that it is pushed to the github repository “**openidl-aais-gitops” used to prepare the node.

The following table details the meaningful description for the configuration file variables and their expected values.

AAIS Node Configuration

AAIS

Variable

Description

Example Value

GITOPS_REPO_URL

github repo url of openidl-aais-gitops repo

https://github.com/aais-openidl/openidl-aais-gitops

This is the forked repo.

GITOPS_REPO_BRANCH

github branch in openidl-aais-gitops repo

develop

The branch where saving the file <node_type>_<env>

ORDERERORG_DOMAIN_NAME

Domain name of the ordering service running in AAIS account

aais.aaisdirect.com

<domain_name>

This is common across all and should be the same for every carrier

DOMAIN_NAME

Domain name to be used for fabric endpoints

aais.aaisdirect.com

<subdomain>.<domain_name>

INTERNAL_DOMAIN_NAME

Internal domain name from the Route53 private hosted zone

aais.internal.aaisdirect.org

<subdomain>.internal.<domain_name>

ENV

Environment

dev

AAIS_ORGNAME

AAIS organization name

aais

ANALYTICS_ORGNAME

Analytics organization name

analytics

ANALYTICS_DOMAIN_NAME

Analytics domain name to be used for its endpoints

analytics.openidldirect.org

CARRIER_ORGNAME

Carrier organization name

ins (should be four or less characters)

CARRIER_DOMAIN_NAME

Carrier domain name to be used for its endpoints

ins.openidldirect.org

ANAYTICS_AAIS_CHANNEL_NAME

Channel name between Analytics and AAIS nodes

anal-aais

ANAYTICS_CARRIER_CHANNEL_NAME

Channel name between Analytics and Carrier nodes

anal-ins

CHAINCODE_REPO_BRANCH

Branch to be used for installing chaincode from github.com/openidl-org/openidl-main repository

develop

Analytics Node Configuration

Analytics

Variable

Description

Example Value

GITOPS_REPO_URL

github repo url of openidl-aais-gitops repo

https://github.com/analytics-openidl/openidl-aais-gitops

GITOPS_REPO_BRANCH

github branch in openidl-aais-gitops repo

develop

ORDERERORG_DOMAIN_NAME

Domain name of the ordering service running in AAIS account

aais.openidldirect.org

DOMAIN_NAME

Domain name to be used for fabric endpoints

analytics.openidldirect.org

INTERNAL_DOMAIN_NAME

Internal domain name from the Route53 private hosted zone

analytics.internal.openidldirect.org

ENV

Environment

dev

AAIS_ORGNAME

AAIS organization name

aais

ANALYTICS_ORGNAME

Analytics organization name

analytics

ANALYTICS_DOMAIN_NAME

Analytics domain name to be used for its endpoints

analytics.openidldirect.org

CARRIER_ORGNAME

Carrier organization name

trv

CARRIER_DOMAIN_NAME

Carrier domain name to be used for its endpoints

trv.openidldirect.org

ANAYTICS_AAIS_CHANNEL_NAME

Channel name between Analytics and AAIS nodes

analytics-aais

ANAYTICS_CARRIER_CHANNEL_NAME

Channel name between Analytics and Carrier nodes

analytics-trv

CHAINCODE_REPO_BRANCH

Branch to be used for installing chaincode from github.com/openidl-org/openidl-main repository

develop

Carrier Node Configuration

Carrier

Variable

Description

Example Value

BAF_IMAGE_REPO

the org and repo name of the baf_image

use this value unless otherwise stated openidl-org/openidl-aais-gitops

GITOPS_REPO_URL

github repo url of openidl-aais-gitops repo

https://github.com/trv-openidl/openidl-aais-gitops

GITOPS_REPO_BRANCH

github branch in openidl-aais-gitops repo

baf-automation

ORDERERORG_DOMAIN_NAME

Domain name of the ordering service running in AAIS account.

aais.openidldirect.org

This was defined on the aais node and should be repeated here.

DOMAIN_NAME

Domain name to be used for fabric endpoints

trv.openidldirect.org

INTERNAL_DOMAIN_NAME

Internal domain name from the Route53 private hosted zone

trv.internal.openidldirect.org

ENV

Environment

dev

AAIS_ORGNAME

AAIS organization name

aais

ANALYTICS_ORGNAME

Analytics organization name

analytics

ANALYTICS_DOMAIN_NAME

Analytics domain name to be used for its endpoints

analytics.openidldirect.org

CARRIER_ORGNAME

Carrier organization name

trv

CARRIER_DOMAIN_NAME

Carrier domain name to be used for its endpoints

trv.openidldirect.org

ANAYTICS_AAIS_CHANNEL_NAME

Channel name between Analytics and AAIS nodes

analytics-aais

ANAYTICS_CARRIER_CHANNEL_NAME

Channel name between Analytics and Carrier nodes

analytics-trv

CHAINCODE_REPO_BRANCH

Branch to be used for installing chaincode from github.com/openidl-org/openidl-main repository

develop

2.10.3. Vault Deployment

It is all set to deploy vault. Go to Jenkins and to the vault deployment pipeline job created in previous step. Click on build with parameters and key in organization name (name that was used to setup infra) and environment type (dev | test | prod) and chose deploy_action whether to deploy. There is also a vault_cleanup job which would be handy in case to remove vault for unforeseen reasons.

note First run after configuring the job is dummy run as the option shows as “Build Now”. This will fail and will update your job with relevant parameters required for the job to run. Further runs will show an option Build with Parameters which will be right run.

_images/image661.png

2.10.3.1. Verify Vault

  1. Setup AWS CLI

  2. Set AWS_PROFILE to the credentials that has access to EKS blockchain cluster

  3. Set cluster context as blockchain cluster

  4. Review vault objects and its working, refer to below screen shot.

_images/verify-vault-1.png _images/verify-vault-2.png

note This should allow access to the vault UI

2.10.4. Deploy Blockchain Network

It is time to deploy either blockchain network (new network) or joining a node to existing network.

To run blockchain related tasks, the relevant jenkins pipeline job for blockchain should be triggered with different actions based on workflow.

note First run after configuring the job is dummy run as the option shows as “Build Now”. This will fail and will update your job with relevant parameters required for the job to run. Further runs will show an option Build with Parameters which will be right run.

_images/image67.png

Before triggering the blockchain pipeline, let us understand the workflow involved and multiple actions that needs to be followed in sequence. Then it would be easy to follow the workflow table and trigger the blockchain pipeline job in jenkins accordingly.

2.10.4.1. AAIS node setup

The below are the steps required to complete using relevant jenkins jobs to setup base AAIS (multi tenant node). These steps are to be performed on AAIS (multi tenant node).

AAIS NODE

AAIS Node Steps

#

Node

Action

ORG

ENV

Channel Name

Extra

New Org Name

Chaincode Version

Comments

1

AAIS

baf_image

aais

dev

Not applicable as images are already provisioned

2

AAIS

vault

aais

dev

defaultchannel

3

AAIS

deploy_network

aais

dev

defaultchannel

4

AAIS

chaincode

aais

dev

defaultchannel

Format:MMDDTTTT

5

AAIS

register_users

aais

dev

defaultchannel

2.10.4.2. Analytics node setup

2.10.4.3. Pictorial representation

_images/image13.png

2.10.4.4. Analytics node workflow

The below are the steps to follow in deploying analytics node and joining with AAIS(multi tenant node). The procedure involves performing joint action working with AAIS(multi tenant) node.

These steps are required to perform in sequential order. These steps are to be performed through blockchain pipeline job in jenkins.

_images/analytics-aais-node.png

2.10.4.5. Carrier node setup

2.10.4.6. Pictorial representation

_images/image141.png

2.10.4.7. Carrier node workflow

The below are the steps to follow in deploying carrier node and joining with AAIS(multi tenant node)/Analytics node. The procedure involves performing joint action working with AAIS(multi tenant) node and Analytics node.

These steps are required to perform in sequential order. These steps are to be performed through blockchain pipeline job in jenkins.

_images/carrier-anal-aais-node.png

2.10.5. How to verify blockchain actions are successful

  1. Using kubectl client get into blockchain cluster to run kubectl commands to verify and below screenshot self explains the details.

2.10.5.1. deploy network action on AAIS node

_images/verify-deploy-network.png

2.10.5.2. deploy new org action on other nodes

_images/verify-new-org.png

2.10.5.3. deploy chaincode action

  1. Verify chaincode install

_images/verify-chaincode-install.png
  1. Verify chaincode approve

_images/verify-chaincode-approve.png
  1. Verify chaincode commit

_images/verify-chaincode-commit.png
  1. Verify chaincode invoke

_images/verify-chaincode-invoke.png

2.10.5.4. deploy add new channel action

_images/verify-new-channel.png

2.10.5.5. deploy join peer action

_images/verify-join-channel.png

2.10.5.6. deploy register users action

_images/verify-register-users.png

2.11. Manage OpenIDL Infrastructure Resources

This section describes the operational procedures to manage OpenIDL project infrastructure resources.

2.12. Managing AWS resources

This section describes the details on how to manage AWS resources provisioned. All the resources provisioned in AWS by terraform automation has access only to the IAM role used to provision resources.

Hence to manage the resources the IAM role needs to be assumed.

1. Just to recollect during the initial preparation phase an IAM user called “terraform” and IAM role called “tf_automation” with necessary permissions was configured

  1. Further this IAM user assumed IAM role to provision AWS resources through CI-CD pipeline

  2. By default all the resources are accessible by the IAM role “tf_automation. Hence assuming this role helps to gain access to these resources

4. However only for the IAM role “terraform” is allowed to assume this “tf_automation”. Hence login as terraform user and assume this IAM role to manage it.

  1. Since this terraform user is configured only with programmatic access, it is required to use AWS CLI to manage resources

2.12.1. Using AWS CLI and assuming role

  1. Install AWS CLI (refer to AWS documentation to install AWS CLI)

  2. Go to the user profile directory under “./aws” directory

  3. Edit the file called “credentials” located under user profile directory “./aws/”

  4. Update terraform user access/secret keys and assume role profile configuration as below

[openidl-terraform-user] aws_access_key_id = <accesskey> aws_secret_access_key = <secretkey>

[openidl-terraform-role] role_arn = <IAM-ROLE-ARN> source_profile = openidl-terraform-user external_id = terraform region = <aws-region>

  1. Once this profile is updated in the “credentials” file save and close

  2. Go to command line interface and set the AWS_PROFILE=openidl-terraform-role

    Linux: export AWS_PROFILE=openidl-terraform-role Windows: set AWS_PROFILE=openidl-terraform-role

  3. Validate the profile is configured well and IAM user is able to assume the role by running this command.

    #aws sts get-caller-identity

{

“UserId”: “AROAYM7S43VMIRGVMSVN6:botocore-session-1629220738”, “Account”: “577645632856”, “Arn”: “arn:aws:sts::577645632856:assumed-role/terraform_automation/terraform”

}

  1. Now it is all set to manage AWS resources through CLI

2.13. Managing EKS Kubernetes Cluster and resources

This section briefs the details about access to EKS kubernetes cluster and how to manage it.

Let us first understand how this access to EKS cluster is all set in AWS. Whenever a kubernetes cluster is created in AWS the IAM user or IAM role assumed by the user gains access to EKS cluster by default. Other than this IAM user/role none of them will have access to the cluster.

However in our project during AWS resource provisioning, there is an option to enter list of IAM users/IAM roles to provision access to EKS cluster part of deployment and its configuration. In case if you have added some IAM user/IAM role they would have gained access.

Finally the last option is that part of our project there is a default IAM role which is set to have access to the EKS cluster. However to assume this IAM role manage EKS cluster, an IAM user must the added to the specific IAM group setup part of resource provisioning. Once the user is added in the group then the user has permissions to assume this IAM role to manage EKS cluster.

In summary who has access to EKS cluster

  1. tf_automation role and it can be assumed by terraform user

  2. List of IAM users/IAM roles allowed permissions to the EKS cluster part of AWS resource provisioning pipeline process

3. Letting list of IAM users by subscribing to IAM group specifically setup for this purpose and the user assumes the IAM role allowed to assume by this group membership

In all of these cases setting up AWS CLI and configuring IAM role assumption in AWS profiles helps to gain access to EKS cluster.

In case how to setup AWS CLI profile, refer to section “Managing AWS resources”

2.13.1. Adding IAM user to IAM group for managing EKS

  1. Login to AWS and got IAM and under groups

  2. Edit the group <orgname>-<env>-eks-admin. Example aais-dev-eks-admin

  3. Add any IAM user expected to give permissions to EKS cluster

Now the user has permission to assume the IAM role named “<orgname>-<env>-eks-admin” to gain eks cluster access.

Example IAM ROLE ARN: arn:aws:iam::<acc_number>:role/carr-dev-eks-admin

2.13.2. Managing EKS Kubernetes Cluster

  1. Setup AWS CLI (refer to AWS documentation)

  2. Setup AWS Profile (refer to section managing aws resources)

  3. set/export AWS_PROFILE

  4. set cluster context to whichever cluster the user is going to manage

    #aws eks update-kubeconfig –region <region> –name <orgname>-<env>-<clustername>

    Example: aws eks update-kubeconfig –region us-east-2 –name aais-dev-blk-cluster

2.14. Connecting to Vault Cluster

This section describes how to connect to vault cluster and further retrieve following certificates.

#Orderer TLS certificate from AAIS node (multi tenant) hashicorp vault

#Analytics/Carrier ORG MSP from hashicorp vault

2.14.1. Connecting to vault cluster

  1. Setup AWS CLI profile with necessary credentials and IAM role

  2. Switch to the K8s blockchain cluster context

Example: #>aws eks update-kubeconfig –region <region> –name <blockchain-cluster-name>

  1. Get the vault root token from AWS secret manager to login vault

Example: #>aws secretsmanager get-secret-value –region <region> –secret-id <orgname>-<env>-vault-unseal-key

note ** Ensure that the AWS credentials has permissions to retrieve secret from secrets manager

  1. Setup port-forward using below command to access vault

#kubectl port-forward -n vault svc/vault 8200:8200

  1. Login to vault using root token retrieved from AWS secret manager

_images/image671.png

2.14.2. Retrieve Orderer TLS certificate (AAIS Node)

  1. Orderer TLS certificate is available at the below mentioned path. Replace <orgname> with organization name (aais)

Path: http://localhost:8200/ui/vault/secrets/<orgname=aais?>/show/crypto/peerOrganizations/<orgname>-net/orderer/tls

_images/image681.png
  1. Copy the orderer TLS certificate and paste into a file, Example: “orderer.pem”

  2. Convert the orderer TLS certificate to base64

#cat “orderer.pem” | base64

  1. Share the base64 encoded orderer TLS certificate with analytics/carrier node. This would be used during blockchain network steps

2.14.3. Retrieve Org MSP certificate (Analytics or Carrier Node)

  1. Org MSP certificate is available at the below mentioned path. Replace <orgname> with organization name (anal | trv |etc for example)

Path: http://localhost:8200/ui/vault/secrets/<orgname>/show/crypto/peerOrganizations/<orgname>-net/mspDefinition

_images/image691.png
  1. Copy the Org MSP certificate and paste into a file, Example: “orgMSP.txt”

3. Share the Org MSP certificate AS-IS copied from the vault to AAIS node owner to add them in their environment as secrets. This would be used during blockchain network steps

2.15. Connecting to AWS Secrets Manager

This section describes how to connect to AWS secrets manager to retrieve/write secrets like

#Orderer TLS certificate on Analytics or Carrier node

#Org MSP of analytics or carrier node on AAIS node

2.15.1. Storing Orderer TLS certificate on Analytics/Carrier Node

  1. Login to AWS console and go to secrets manager

  2. Click on store new secret

_images/image701.png
  1. Select “Other type of secrets” and use “Plaintext”

_images/image71.png
  1. Set a name to the secret as “<env>-orderer-tls”. Example: dev-orderer-tls

_images/image72.png
  1. Disable automatic rotation and complete creating the secret

2.15.2. Storing Org MSP certificate on AAIS node

  1. Login to AWS console and go to secrets manager

  2. Click on store new secret

_images/image701.png
  1. Select “Other type of secrets” and use “Plaintext”

_images/image71.png
  1. Set a name to the secret as “<env>-<orgname>-msp”. Example: dev-analytics-msp | dev-trv-msp | dev-carrier-msp (depends on orgname used)

  2. Disable automatic rotation and complete creating the secret

2.16. Managing MongoDB

The below are the steps to perform to manage MongoDB instance.

  1. Setup AWS CLI and set AWS_PROFILE to the relevant IAM credentials that has access to EKS application cluster

  2. Set the context to application cluster

    Example: aws eks update-kubeconfig –region <region> –name <app-cluster-name>

  3. Set port forward using below command

    #kubectl port-forward -n database svc/${ORG-NAME}-mongodb-headless 27017:27017

note org-name refers to organisation name set during node preparation (AWS resources/blockchain)

note If you are running mongodb locally, you should use another port like 28017:27017 in port-forward command

  1. Connect to MongoDB using Compass client with following URL

# mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@localhost:27017 /openidl-offchain-db?authSource=openidl-offchain-db

note The mongodb_username and mongodb_password are put into the aws secrets manager at

<org_name>-<env>-mongodb-user for the username and <org_name>-<env>-mongodb-user-token for the password

note use “tf_automation” role to access the tokens as they have rights to read the credentials.

  1. Command to retrieve secrets

    #aws secretsmanager get-secret-value –region <region> –secret-id <orgname>-<env>-mongodb-user #aws secretsmanager get-secret-value –region <region> –secret-id <orgname>-<env>-mongodb-user-token

2.17. Deploy OpenIDL Application

This section briefs the procedure to deploy backend database mongodb, application APIs and configuration steps to bring the OpenIDL platform up and running for use.

The below are the steps involved

  1. Deploy MongoDB

  2. Prepare application API configuration files

  3. Add application API configuration files to vault

  1. Deploy API configuration files as secrets object in EKS cluster

  2. Deploy application APIs as deployment objects in EKS cluster

  3. Create admin user in AWS Cognito

  4. Create application users using Utilities Service API

2.17.1. Deploy MongoDB

checkbox deploy mongodb instance

  1. Go to Jenkins and click on relevant MongoDB job

  2. Click on Build with parameters and key in organization name and environment type

  3. Choose deploy_action as “mongodb-deploy”

Note: First run after configuring the job is dummy run as the option shows as “Build Now”. This will fail and will update your job with relevant parameters required for the job to run. Further runs will show an option Build with Parameters which will be right run.

_images/image68.png

note In case mongodb deployment ran to issues, bug fix the issues and perform mongodb_cleaup before rerun deployment. The deploy_action “mongodb_cleanup” helps in Jenkins job to perform cleanup.

2.17.2. Preparing application API configuration files

checkbox preparing application config json files

  1. Get to the repository openidl-aais-gitops and to the directory “openidl-config/”

  2. This has config-templates directory under which the set of template files are available individually for each node type (aais | analytics | carrier)

  3. Update the relevant set of template config files with all correct values

  4. Run #make copy_config_files to generate correct config files in to the config directory

note Refer to below table that describes the details of each field and the value expected from the environment provisioned

API Configuration Fields Description

Variable

Description

Example

AAIS_ORGNAME

Organization name used in setting up infra/blockchain network

aais

AAIS_ORGNAME_SHORT

Organization short name used by automation in setting up resources (first 4 chars)

aais

ANALYTICS_ORGNAME

Organization name used in setting up infra/blockchain network

analytics

ANALYTICS_ORGNAME_SHORT

Organization short name used by automation (first 4 chars)

anal

CARRIER_ORGNAME

Organization name used in setting up infra/blockchain network

travelers or hig or cnd

CARRIER_ORGNAME_SHORT

Organization short name used by automation (upto first 4 chars)

trav or hig or cnd

ENV

environment name dev or test or prod

dev

DOMAIN

DNS domain name set

thetech.digital

SUBDOMAIN

DNS sub domain if used (optional: otherwise remove this)

openidl

TLS_CERT

Refer to section CREATING CA TLS CERT for connection profile

go to particular section to understand

AWS_COGNITO_ACCESS_KEY_ID

AWS access key of application user provisioned by terraform

refer to IAM

AWS_COGNITO_SECRET_ACCESS_KEY

AWS secret key of application user provisioned by terraform

refer to IAM

AWS_COGNITO_REGION

AWS region

us-east-2

AWS_COGNITO_USERPOOLID

Cognito userpool ID

refer to cognito to identify the ID

AWS_COGNITO_CLIENTID

Cognito application client ID

refer to cognito to identify application ID

AWS_COGNITO_REGION

AWS region

us-east-2

MONGO_DB_USERNAME

Get the username from AWS secrets manager <orgname>-<dev>-mongodb-user

aais-dev-mongodb-user

MONGO_DB_PASSWORD

Get the password from AWS secrets manager <orgname>-<dev>-mongodb-user-token

aais-dev-mongodb-user-token

AWS_SECRET_MANAGER_ACCESS_KEY_ID

AWS access key of application user provisioned by terraform

refer to IAM

AWS_SECRET_MANAGER_SECRET_ACCESS_KEY

AWS secret key of application user provisioned by terraform

refer to IAM

AWS_SECRET_MANAGER_REGION

aws region

us-east-2

VAULT_SECRET_NAME

Name of the secret that gets the valut secret for application <orgname>-<dev>-kvs-vault

aais-dev-kvs-vault

AWS_S3_ACCESS_KEY_ID

AWS access key of application user provisioned by terraform

refer to IAM

AWS_S3_SECRET_ACCESS_KEY

AWS secret key of application user provisioned by terraform

refer to IAM

AWS_S3_REGION

aws region

us-east-2

S3_BUCKET_NAME

Name of the S3 bucket provisioned for HDS datastore

refer to S3

S3_BUCKET_NAME_LOGOS

Name of S3 bucket provisioned for icons

refer to S3

2.17.2.1. Retrieving CA TLS Certificate

  1. Go to command line

  2. Set AWS_PROFILE to the relevant profile that has access to vault root token secret in AWS secret manager

    #set AWS_PROFILE=tf-automation-role (or)

    #export AWS_PROFILE=tf-automation-role

  3. Retrieve vault root token from AWS secret manager

    #aws secretsmanager get-secret-value –region <region> –secret-id <orgname>-<env>-vault-unseal-key

    #example: aws secretsmanager get-secret-value –region us-east-2 –secret-id aais-dev-vault-unseal-key

  4. Now set the AWS_PROFILE to the relevant profile that has access to blockchain EKS cluster

    #set AWS_PROFILE=eks-admin-role (or)

    #export AWS_PROFILE=eks-admin-role

    note IAM user or assume IAM role that has access to the EKS cluster

  1. Set the cluster context to blockchain cluster

    #aws eks update-kubeconfig –region <region> –name <blockchain-cluster-name>

  2. Perform port-forward for vault service

    #kubectl port-forward -n vault svc/vault 8200:8200

  3. Vault should be available at http://localhost:8200

  4. Login to vault using root token retrieved from AWS secrets manager

  5. The CA TLS certificate should be available at below path. Replace <orgname> with actual orgnaization name

    PATH: http://localhost:8200/ui/vault/secrets/<orgname>/show/crypto/peerOrganizations/<orgname>-net/ca

  6. Name of the key to retrieve value from “ca.<orgname>-net-cert.pem”

    Example: ca.aais-net-cert.pem

  7. Now copy this CA TLS certificate pem content into editor like “VS CODE”

  8. Use replace all values, select use regular expressions (title ‘.*’ icon on search) and replace “n” with “\n”

_images/image73.png
  1. After replacing al, final output would look like below.

_images/image74.png

2.17.3. Add application API configuration files to vault

checkbox Add application configuration json files as secrets into vault

  1. Go to command line and set AWS_PROFILE to the relevant profile that has access to EKS cluster

  2. Set the cluster context to blockchain cluster

    #aws eks update-kubeconfig –region <region> –name <blockchain-cluster-name>

3. Create a local file ubuntu.yml and paste the following content in the file (this file is available in the repository under openidl-config)

apiVersion: v1 kind: Pod metadata:

name: ubuntu

spec:
containers:
  • name: ubuntu image: ubuntu:latest # Just spin & wait forever command: [‘/bin/bash’, ‘-c’, ‘–‘] args: [‘while true; do sleep 30; done;’]

  1. Create a new pod in the default namespace using the above definition

    #kubectl apply -f ./ubuntu.yml

  2. Copy the config files prepared from openidl-aais-gitops/openidl-config/config/config-<env>-<node>/ directory to the pod

    #cd openidl-aais-gitops/openidl-config/

    #kubectl cp config/<config-<dev>-<node-type>/ default/ubuntu:config

    Example: kubectl cp config/config-dev-aais/ default/ubuntu:config

  3. Copy add-vault-config script to the pod

    #cd openidl-aais-gitops/vault-scripts

    #kubectl cp add-vault-config.sh default/ubuntu:add-vault-config.sh

  4. Exec into the pod #kubectl exec -it ubuntu - /bin/bash

  5. Update the pod and install utilties vim, curl, dos2unix, jq

    #apt-get update #apt-get install vim jq curl dos2unix -y

9. Check whether the files are copied correctly into the pod. You should see the file “add-vault-config.sh” under “/” directory and application config files under “/config” directory

  1. Allow execute permission to add-vault-config.sh #chmod +x add-vault-config.sh

  2. In case due to copying from windows to linux has file formatting issue, run this command #dos2unix add-vault-config.sh

  3. Now get the vault user login credentials from AWS secret manager that has access to config files located in vault path

  4. Get onto AWS CLI, set the AWS_PROFILE to “tf-automation-role” that has access to secrets

14 Retrieve the credential using below command.

#aws secretsmanager get-secret-value –region <region> –secret-id <orgname>-<dev>-config-vault

Example: aws secretsmanager get-secret-value –region us-east-2 –secret-id aais-dev-config-vault

  1. Now get onto the ubuntu pod and run the add-vault-script.sh with the retrieved credentials to upload config files as secrets into vault

    #./add-vault-config.sh -V <url> -U <username> -P <password> -a <vaultPath> -o <orgName> -c ./config

    #All the values for the parameters are retrieved from the secret <orgname>-<dev>-config-vault

  2. After successful upload of config files as secrets in vault, delete the pod safely

    #kubectl delete pod ubuntu -n default

2.17.4. Prepare application API deployment value files

checkbox Prepare application api deployment value files

  1. Go to openidl-aais-gitops/openidl-k8s directory

  2. Update the deployment definition file according the node type (aais | analytics | carrier)

    #gloabl-values-dev-<node-type>.yaml

    Examples:

    global-values-dev-aais.yaml

    global-values-dev-analytics.yaml

    global-values-dev-carrier.yaml

  3. Once the relevant file is prepared for the node, push it to github repository before executing deployment pipeline job

note Work with AAIS in updating this file as they have most of the information especially image repository, image and tags.

However the below table describes brief information that benefits to some extend.

Key Field |Description

ingresshostname | <service>.<env>.<subdomain>.internal.<domain>

publicingresshostname | <service>.<env>.<subdomain>.<domain>

image.repository | Get the repository and image from AAIS

image.tag | Get the image tag from AAIS

2.17.5. Deploy Deploy application APIs and its secrets

checkbox deploy secret object & application apis

note First run after configuring the job is dummy run as the option shows as “Build Now”. This will fail and will update your job with relevant parameters required for the job to run. Further runs will show an option Build with Parameters which will be right run.

This step involves two actions as the APIs needs to the config files which are set as secret object. Hence deploy secrets and then APIs.

To deploy application secrets and OpenIDL application, run the job configured for OpenIDL applications. Go to Jenkins and select the relevant job and use Build with Parameters.

  1. Perform deploy-secrets action in the pipeline to get the config files from vault to K8s as secrets

  2. Perform deploy-apps action in the pipeline to get the openIDL apis to be deployed as deployment objects in K8s

_images/image70.png

2.18. Setting up application users

checkbox creating cognito admin user and application users

After deploying application the next step is setting up the below

  1. Creating Cognito admin user

  2. Creating application users

2.18.1. Creating Admin user in Cognito

checkbox setting up cognito admin user

  1. Log into AWS Console and select the Cognito User Pool. Click on ‘Users and Groups’

_images/image75.png
  1. Select ‘Create User’ and provide the required information. See screenshot below

_images/image76.png
  1. Once the user gets created, password will need to be changed. Go to ‘App Client Settings’ and ‘Launch Hosted UI’

_images/image77.png
  1. Log-in using the credentials of the admin user which was just created

_images/image78.png
  1. Change the password

note note down the credentials

2.18.2. Creating application users

checkbox setting up application users for API endpoint access

  1. Launch the Utilities Service Swagger at http://utilities-service ${ENV}.${ORGNAME}.${DOMAIN}.com/api-docs

_images/image79.png
  1. Select ‘app-user-login’ and provide the cognito user admin credentials. Get the ‘userToken’ from response and ‘Authorize’ the user

  2. Select ‘app-user-creation’ and provide the necessary information for creating the user. Following are the examples for creating users for different organizations

AAIS Organization

{
“users”: [
{

“username”: “liz@lazarus.com”, “password”: “<password>”, “familyName”: “liz”, “givenName”: “blockchain”, “email”: “liz@lazarus.com”, “attributes”: {

“custom:stateName”: “Colorado”, “custom:stateCode”: “05”, “custom:role”: “stat-agent”, “custom:organizationId”: “12345”

}

}

]

}

ANALYTICS Organization

{
“users”: [
{

“username”: “liz@lazarus.com”, “password”: “<password>”, “familyName”: “liz”, “givenName”: “blockchain”, “email”: “liz@lazarus.com”, “attributes”: {

“custom:stateName”: “Colorado”, “custom:stateCode”: “05”, “custom:role”: “regulator”, “custom:organizationId”: “12345”

}

}

]

}

CARRIER Organization

{
“users”: [
{

“username”: “liz@lazarus.com”, “password”: “<password>”, “familyName”: “liz”, “givenName”: “blockchain”, “email”: “liz@lazarus.com”, “attributes”: {

“custom:stateName”: “Colorado”, “custom:stateCode”: “05”, “custom:role”: “carrier”, “custom:organizationId”: “12345”

}

}

]

}