S3cmd
1# install
2sudo pip install s3cmd
3
4# config
5s3cmd --configure
6
7# Create if does not already exist
8s3cmd info s3://terraform-backend-test || s3cmd mb s3://terraform-backend-test -v -d
9
10# Delete bucket
11s3cmd rb s3://terraform-backend-github-test --recursive
12
13# Get size of the bucket
14s3cmd du s3://terraform-backend-test
S3cmd github action
1jobs:
2 backend:
3 name: Backend
4 runs-on: ubuntu-latest
5
6 steps:
7 - name: Set up S3cmd cli tool
8 uses: s3-actions/s3cmd@main
9 with:
10 provider: digitalocean
11 region: FRA1
12 access_key: ${{secrets.DIGITALOCEAN_SPACES_ACCESS_TOKEN}}
13 secret_key: ${{secrets.DIGITALOCEAN_SPACES_SECRET_KEY}}
14
15 - name: Create Space Bucket
16 run: |
17 sed -i -e 's/signature_v2.*$/signature_v2 = True/' ~/.s3cfg
18 buck="github-action-${{ github.run_id }}"
19 s3cmd mb s3://$buck
20 sleep 10
21 continue-on-error: true
Mount S3 bucket as a FS
1# conf epel repo on RHEL8
2cat < EOF > /etc/yum.repos.d/epel.repo
3name = "Extra Packages for Enterprise Linux 8 - Release"
4baseurl = "http://download.fedoraproject.org/pub/epel/8/Everything/$basearch"
5enabled = true
6failovermethod = "priority"
7gpgcheck = true
8gpgkey = "http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8"
9EOF
10
11# install packages
12dnf install epel-release s3fs-fuse
13
14# Create passwd file
15echo "${spaces_access_key_id}:${spaces_access_key_secret}" > /etc/passwd-s3fs
16chown root:root /etc/passwd-s3fs
17chmod 0600 /etc/passwd-s3fs
18
19# Mount
20mkdir /mnt/point
21s3fs ${bucket_name} ${mount_point} -o url=https://${region}.digitaloceanspaces.com",
Comments