Skip to content

alltom/mirror2s3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mirror2s3

A Go library for mirroring files from a Git repository to an AWS S3 bucket. It uses Git HEAD and ignores changes in the working copy.

Installation

go get github.com/alltom/mirror2s3

Usage

package main

import (
    "context"
    "log"

    "github.com/alltom/mirror2s3"
)

func main() {
    m := mirror2s3.New(
        mirror2s3.WithGitRepoRoot("/path/to/git/repo"),
        mirror2s3.WithAwsProfile("my-profile"),
        mirror2s3.WithAwsRegion("us-east-1"),
        mirror2s3.WithBucketURL("s3://my-website-bucket"),
    )

    ctx := context.Background()
    if err := m.Run(ctx); err != nil {
        log.Fatal(err)
    }
}

Configuration Options

  • WithGitRepoRoot(path) - Path to the Git repository to mirror
  • WithAwsProfile(name) - AWS profile name for authentication
  • WithAwsRegion(region) - AWS region where the S3 bucket is located
  • WithBucketURL(url) - S3 bucket URL (e.g., "s3://bucket-name" or "s3://bucket-name/prefix/")

AWS Credentials

The library uses standard AWS credential resolution:

  • Environment variables (AWS_PROFILE, AWS_REGION)
  • AWS credentials file (~/.aws/credentials)
  • IAM role (when running on EC2/ECS/Lambda)

Ignored Files

By default, .gitignore files are not uploaded. You can modify the IgnoredFiles variable to customize this behavior:

mirror2s3.IgnoredFiles[".env"] = struct{}{}  // Also ignore .env files

Requirements

  • Go 1.24 or later
  • Git executable available in PATH (or at /usr/bin/git)
  • AWS credentials with S3 read/write permissions

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages