Applies to
- Liquibase Pro
Conditions
- GitHub Actions using Liquibase GitHub Actions
- AWS S3 Extension
Issue Summary
The below error occurs when running a GitHub Action to execute a Liquibase command, and the output or file is sent to an S3 bucket. This issue prevents the file from being saved to S3.
Error Message
ERROR: The AWS s3 extension JAR is not available on the classpath.
Root Cause
The Liquibase GitHub Actions do not include the Liquibase AWS S3 extension by default, which is required to save files to S3 using Liquibase. As a result, the action fails because the S3 extension JAR is missing from the classpath.
Resolution
Use a Docker Container with LPM to Install the S3 Extension
To resolve this issue, modify your GitHub Action workflow to use a Docker container and Liquibase Package Manager (LPM) to install the AWS S3 extension. Below are the steps to implement this workaround.
-
Update the GitHub Action Workflow:
Modify the GitHub Action to run the job within a Liquibase Docker container and install the S3 extension using LPM. This ensures the extension is available during execution. -
Add a Docker Container:
In your GitHub Action workflow file, specify the Liquibase Docker container to use:-
container:
image: liquibase/liquibase:latest
options: --user root
-
-
Install AWS S3 Extension Using LPM:
Add steps to install the necessary S3 extension using Liquibase Package Manager (LPM):-
- name: Install Extensions Using LPM
run: |
lpm update
lpm add liquibase-s3-extension
-
-
Run Liquibase Command:
After installing the extension, run your Liquibase command to save the output to S3. Example workflow snippet using the snapshot command:-
- name: Run Liquibase Snapshot Command
run: |
liquibase snapshot --snapshot-format=json --output-file=s3://$AWS_S3_BUCKET/gh-snapshots/${{ secrets.ENV }}-snapshot.json
-
Example using Liquibase Flow
liquibase_pro_snapshot_action.yml
####################################################################
# GitHub Action to take snapshot for use in Drift Detection
# database changes using Liquibase Pro and S3.
#####################################################################
name: 'Liquibase Pro Snapshot'
run-name: ${{ inputs.environment}} snapshot by ${{ github.actor }}
on:
workflow_dispatch:
# Following are the inputs received via the GitHubActions Run workflow dialog
inputs:
# The type 'environment' will automatically pull in the environments created in GitHub
environment:
description: 'Environment to snapshot'
type: environment
required: true
####################################################################
# Set up the environment
#####################################################################
env:
# AWS S3 bucket is the host part of the S3 bucket
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
# AWS Access credentials use by the Liquibase Pro S3 Extension
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# Default AWS region
AWS_REGION: us-east-1
# Pro License key
# See https://docs.liquibase.com/workflows/liquibase-pro/how-to-apply-your-liquibase-pro-license-key.html
LIQUIBASE_LICENSE_KEY: ${{ secrets.LIQUIBASE_PRO_LICENSE_KEY }}
# JDBC URL of the database per environment
# See https://docs.liquibase.com/workflows/liquibase-community/using-jdbc-url-in-liquibase.html
LIQUIBASE_COMMAND_URL: ${{ secrets.LIQUIBASE_URL }}
# Credentials for the environment's database https://docs.liquibase.com/parameters/command-parameters.html
LIQUIBASE_COMMAND_USERNAME: ${{ secrets.LIQUIBASE_USERNAME }}
LIQUIBASE_COMMAND_PASSWORD: ${{ secrets.LIQUIBASE_PASSWORD }}
# Liquibase schema: Specified to allow flexibility in storage of Liquibase Change Tracking Tables
# See https://docs.liquibase.com/parameters/liquibase-schema-name.html
LIQUIBASE_LIQUIBASE_SCHEMA_NAME: gh
# Default schema: Specify schema for all changes
LIQUIBASE_COMMAND_DEFAULT_SCHEMA_NAME: gh
# Search path (See https://docs.liquibase.com/concepts/changelogs/how-liquibase-finds-files.html)
LIQUIBASE_SEARCH_PATH: flows
ENVIRONMENT: ${{ inputs.environment }}
jobs:
#########################################################################
# Snapshot
#########################################################################
snapshot:
runs-on: [self-hosted]
environment: ${{ inputs.environment }}
# Specify the Docker container to use for the job
container:
image: liquibase/liquibase:latest
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Extensions Using LPM
run: |
lpm update
lpm add liquibase-s3-extension
- name: Flows
uses: liquibase-github-actions/flow@v4.26.0
with:
flowFile: "liquibase-snapshot.flowfile.yaml"
Comments
0 comments
Article is closed for comments.