AWS S3 데이터 이전

3462 단어 S3awsS3

S3 migration

기존 AWS 계정에서 다른 AWS 계정으로 서버를 옮기게 되면서 S3 Bucket내의 데이터도 옮기게 되었다.

1. target IAM policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::<source bucket name>", 
                "arn:aws:s3:::<source bucket name>/*" 
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:PutObject",
                "s3:PutObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::<target bucket name>", 
                "arn:aws:s3:::<target bucket name>/*"
            ]
        }
    ]
}

2. source bucket policy

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "DelegateS3Access",
			"Effect": "Allow",
			"Principal": {
				"AWS": "<target IAM arn>"
			},
			"Action": [
				"s3:ListBucket",
				"s3:GetObject"
			],
			"Resource": [
				"arn:aws:s3:::<source bucket name>/*",
				"arn:aws:s3:::<source bucket name>"
			]
		}
	]
}

3. AWS-CLI

설치: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

$ aws s3 cp s3://<source bucket name> s3://<target bucket name> \ 
  --acl bucket-owner-full-control \
  --recursive

좋은 웹페이지 즐겨찾기