0
1

AWSアカウント間でS3バケットへのアクセス権限のみを共有する方法

Posted at

Amazon S3(Simple Storage Service)は、データの保存と管理のためのスケーラブルなオブジェクトストレージサービスです。異なるAWSアカウント間でS3バケットを共有する方法を紹介します。

バケットポリシー編集

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowListAndGet",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::{ACCOUNT_ID}:user/{USER_NAME}"
            },
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": "arn:aws:s3:::{YOUR_BUCKET_NAME}"
        },
        {
            "Sid": "AllowGetObject",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::{ACCOUNT_ID}:user/{USER_NAME}"
            },
            "Action": [
                "s3:GetObject"
            ],
            "Resource": "arn:aws:s3:::{YOUR_BUCKET_NAME}/*"
        }
    ]
}

このポリシーは、アカウント{ACCOUNT_ID}に対して特定のS3バケットのオブジェクトをリストし、取得する権限を付与します。{YOUR_BUCKET_NAME}を実際のバケット名に、{ACCOUNT_ID}をAWSアカウントIDに置き換えてください。

アクセス確認

  1. バケットの内容をリスト:
aws s3 ls s3://{YOUR_BUCKET_NAME} --profile {ACCOUNT_ID}-profile
  1. オブジェクトを取得:
aws s3 cp s3://{YOUR_BUCKET_NAME}/your-object-key ./{local-directory} --profile {ACCOUNT_ID}-profile

AWSアカウント間でS3バケットを共有する際、LISTとGETの権限を適切に設定することで、安全かつ効率的にデータを共有することができます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1