0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

s3エンドポイントgatewayを作ってみました。

0
Posted at

S3アクセスのポリシー作成

ポリシー名:ec2s3policy2

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:ListBucket",
            "Resource": [
                "arn:aws:s3:::ec2s3aaaabbbbcccczzz"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::ec2s3aaaabbbbcccczzz*"
            ]
        }
    ]
}

S3用アクセス用ロールの作成(サービス EC2)

ロール名:

サービス:ec2
指定された条件でこのロールを引き受けることができるエンティティ。は誰っていうことでEC2なのかな

信頼関係にいかのようになる

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "ec2.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}


s3エンドポイントゲートウェイ作成

ルートテーブルに紐づけること

s3バケット作成

s3のバケットポリシー設定

s3のバケットポリシーでS3ゲートウェイのみ許可

ここでVPC経由のみアクセスにしぼっています。

当然マネコンからのアクセスができません。

{
    "Version": "2012-10-17",
    "Id": "VPCe",
    "Statement": [
        {
            "Sid": "VPCe",
            "Effect": "Deny",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::ec2s3aaaabbbbccccddddzzz",
            "Condition": {
                "StringNotEquals": {
                    "aws:SourceVpce": "vpce-037453833e412bf1f"
                }
            }
        }
    ]
}

ec2からファイルをアップできればOK

aws s3 ls s3://ec2s3aaaabbbbcccczzz
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?