Skip to content

Github Actions

To automate the migration process using GitHub Actions, follow these steps:

Grant necessary permissions to the Workflow

Go to your repository settings on GitHub. Click on Actions in the left sidebar. Under Workflow permissions, select Read and write permissions. Click on Save to apply the changes.

Setup authentication between AWS and GitHub Actions

The provided Workflow uses OpenID Connect (OIDC) to authenticate with AWS. Follow the below guide to setup the OIDC on both source and target Amazon Connect instance.

Configuring OpenID Connect in Amazon Web Services

Setup GitHub Actions Variables

Once the OIDC setup is complete, we need to create a few variables in the GitHub repository to store the AWS credentials and instance ARNs.

  1. Go to your repository on GitHub.
  2. Click on Settings and then Secrets and variables, and then Actions.
  3. Click on the "Variables" tab.
  4. Add the following Repository variables:
    • SOURCE_REGION: AWS region of the source Connect instance.
    • SOURCE_ROLE_ARN: Role ARN to assume in the source AWS account.
    • SOURCE_INSTANCE_ARN: ARN of the source Connect instance.
    • TARGET_REGION: AWS region of the target Connect instance.
    • TARGET_ROLE_ARN: Role ARN to assume in the target AWS account.
    • TARGET_INSTANCE_ARN: ARN of the target Connect instance.

Run Workflow

Finally, you can run the workflow manually under the Actions tab.

Workflow Inputs The following input can be provided to the Workflow:

  • migrate-lex-bots: Boolean value to migrate Lex Bots
  • export-lex-bots: Boolean value to export Lex Bots
  • migrate-users: Boolean value to migrate Users

TIP

If you want to migrate between multiple instances, you have to create a new workflow or add more jobs to the existing workflow.

Sample Workflow

Place the below in a .github/workflows/migrate.yml file.

yaml
name: Run Migration Tool
permissions:
  id-token: write
  contents: read
on:
  workflow_dispatch:
    inputs:
      profile:
        description: "Profile name from env.json (optional)"
        required: false
        default: ""
      migrate-lex-bots:
        description: "Migrate Lex bots"
        required: false
        default: true
        type: boolean
      export-lex-bots:
        description: "Export Lex bots"
        required: false
        default: false
        type: boolean
      migrate-users:
        description: "Migrate users"
        required: false
        default: true
        type: boolean
jobs:
  export-lab:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: "npm"
          cache-dependency-path: ./package-lock.json

      - name: Configure Source AWS Credentials
        id: source_creds
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-region: ${{ vars.SOURCE_REGION }}
          role-to-assume: ${{ vars.SOURCE_ROLE_ARN }}
          output-credentials: true

      - name: Configure Target AWS Credentials
        id: target_creds
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-region: ${{ vars.TARGET_REGION }}
          role-to-assume: ${{ vars.TARGET_ROLE_ARN }}
          output-credentials: true

      - name: Install dependencies
        run: npm ci

      - name: Update Connect data
        run: |
          if [ -n "${{ github.event.inputs.profile }}" ]; then
            npm run generate -- \
              --profile=${{ github.event.inputs.profile }} \
              --export-lex-bots=${{ github.event.inputs.export-lex-bots }} \
          else
            npm run generate -- \
              --export-lex-bots=${{ github.event.inputs.export-lex-bots }} \
        env:
          SOURCE_AWS_ACCESS_KEY_ID: ${{ steps.source_creds.outputs.aws-access-key-id }}
          SOURCE_AWS_SECRET_ACCESS_KEY: ${{ steps.source_creds.outputs.aws-secret-access-key }}
          SOURCE_AWS_SESSION_TOKEN: ${{ steps.source_creds.outputs.aws-session-token }}
          SOURCE_AWS_REGION: ${{ vars.SOURCE_REGION }}
          SOURCE_INSTANCE_ARN: ${{ vars.SOURCE_INSTANCE_ARN }}
          DEST_AWS_ACCESS_KEY_ID: ${{ steps.target_creds.outputs.aws-access-key-id }}
          DEST_AWS_SECRET_ACCESS_KEY: ${{ steps.target_creds.outputs.aws-secret-access-key }}
          DEST_AWS_SESSION_TOKEN: ${{ steps.target_creds.outputs.aws-session-token }}
          DEST_AWS_REGION: ${{ vars.TARGET_REGION }}
          DEST_INSTANCE_ARN: ${{ vars.TARGET_INSTANCE_ARN }}

      - name: Upload Connect data
        uses: actions/upload-artifact@v4
        with:
          name: connect-data
          path: output/
          if-no-files-found: error
          retention-days: 30
          overwrite: true
  migrate-to-dev:
    runs-on: ubuntu-latest
    needs: export-lab
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: "npm"
          cache-dependency-path: ./package-lock.json

      - name: Configure Source AWS Credentials
        id: source_creds
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-region: ${{ vars.SOURCE_REGION }}
          role-to-assume: ${{ vars.SOURCE_ROLE_ARN }}
          output-credentials: true

      - name: Configure Target AWS Credentials
        id: target_creds
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-region: ${{ vars.TARGET_REGION }}
          role-to-assume: ${{ vars.TARGET_ROLE_ARN }}
          output-credentials: true

      - name: Install dependencies
        run: npm ci

      # - name: Commit updated data
      #   run: |
      #     git config --global user.email "github-actions[bot]@users.noreply.github.com"
      #     git config --global user.name "github-actions[bot]"
      #     git add .
      #     git commit -m "Update Connect data" || echo "No changes to commit"
      #     git push

      - name: Pull data
        uses: actions/download-artifact@v4
        with:
          name: connect-data
          path: output/

      - name: Run migration script
        run: |
          if [ -n "${{ github.event.inputs.profile }}" ]; then
            npm run migrate -- \
              --profile=${{ github.event.inputs.profile }} \
          else
            npm run migrate
          fi
        env:
          SOURCE_AWS_ACCESS_KEY_ID: ${{ steps.source_creds.outputs.aws-access-key-id }}
          SOURCE_AWS_SECRET_ACCESS_KEY: ${{ steps.source_creds.outputs.aws-secret-access-key }}
          SOURCE_AWS_SESSION_TOKEN: ${{ steps.source_creds.outputs.aws-session-token }}
          SOURCE_AWS_REGION: ${{ vars.SOURCE_REGION }}
          SOURCE_INSTANCE_ARN: ${{ vars.SOURCE_INSTANCE_ARN }}
          DEST_AWS_ACCESS_KEY_ID: ${{ steps.target_creds.outputs.aws-access-key-id }}
          DEST_AWS_SECRET_ACCESS_KEY: ${{ steps.target_creds.outputs.aws-secret-access-key }}
          DEST_AWS_SESSION_TOKEN: ${{ steps.target_creds.outputs.aws-session-token }}
          DEST_AWS_REGION: ${{ vars.TARGET_REGION }}
          DEST_INSTANCE_ARN: ${{ vars.TARGET_INSTANCE_ARN }}