github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/examples/hooks/s3_branch_head_exporter.lua (about) 1 --[[ 2 S3 Branch HEAD exporter 3 This script exports lakeFS commit IDs to an external location on S3 4 For each branch, the latest commit ID will be written under: 5 s3://<export_bucket>/<export_path>/repositories/<repository_id>/heads/<branch_id> 6 the content of the file is the commit ID string. 7 8 Example configuration to export the heads of all branches: 9 10 name: export_all_heads 11 on: 12 post-commit: 13 branches: 14 post-merge: 15 branches: 16 hooks: 17 - id: export_branch_head 18 type: lua 19 properties: 20 script_path: scripts/s3_branch_head_exporter.lua 21 args: 22 aws_access_key_id: "AKIA.." 23 aws_secret_access_key: "..." 24 aws_region: us-east-1 25 export_bucket: my-external-bucket 26 export_path: lakefs-exported-heads 27 ]] 28 29 aws = require("aws") 30 strings = require("strings") 31 32 s3 = aws.s3_client(args.aws_access_key_id, args.aws_secret_access_key, args.aws_region) 33 34 export_path = args.export_path 35 if not strings.has_suffix(export_path, "/") then export_path = export_path .. "/" end 36 37 s3.put_object(args.export_bucket, export_path .. "repositories/" .. action.repository_id .. "/heads/" .. action.branch_id, action.commit_id)