How to change permission recursively to folder with AWS s3 or AWS s3api

后端 未结 7 1391
情歌与酒
情歌与酒 2020-12-06 02:28

I am trying to grant permissions to an existing account in s3.

The bucket is owned by the account, but the data was copied from another account\'s bucket.

Wh

7条回答
  •  孤街浪徒
    2020-12-06 02:44

    THE MAIN COMMAND IS THIS.

    WHERE bucketname_example_3636 IS YOUR BUCKET NAME.

    aws s3api put-object-acl --bucket bucketname_example_3636 --key bigdirectories2_noglacier/bkpy_workspace_sda4.tar --acl bucket-owner-full-control

    MY IDEA IS TO CREATE A SCRIPT WITH SED, EASLY.

    1. GET THE LIST OF THE KEYS;

    aws s3 ls s3://bucketname_example_3636 --recursive > listoffile.txt

    2. SAY YOU HAVE 1000 FILES, SO 1000 KEYS;

    WITH SED CREATE AUTOMATICALLY 1000 COMMANDS;

    THE STRING \1 IS YOUR KEY;

    sed 's/^(.*)$/aws s3api put-object-acl --bucket bucketname_example_3636 --key \1 --acl bucket-owner-full-control/g' listoffile.txt > listoffile_v2.txt;

    3. ADD THE SHEBANG LINE NECESSARY TO CONVERT A TEXTUAL FILE TO BASH SCRIPT;

    sed '1 i\#!/bin/bash' listoffile_v2.txt > listoffile_v3.txt;

    4. NOW JUST CHANGE THE FILE EXTENTION;

    cp listoffile_v3.txt listoffile_v3.sh;

    NOW YOU HAVE A SCRIPT;

    MAKE THE SCRIPT EXECUTABLE;

    chmod u+x listoffile_v3.sh;

    RUN THE SCRIPT

    listoffile_v3.sh;

提交回复
热议问题