首页 文章

如何在不使用IAM角色或IAM用户访问权限的情况下访问AWS资源

提问于
浏览
2

假设我们有Ec2实例,并且有两个应用程序 . 只有一个应用程序 should 能够访问S3存储桶和其他应用程序 shouldn't 能够访问S3存储桶 .

1)我难以管理 . 不建议这样做 . (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html

2)但我不能使用IAM角色 . 因为它与Ec2实例相关联,它将允许访问Ec2中的每个应用程序 .

1 回答

  • 0

    您可以应用存储桶策略来限制对HTTP标头请求的访问 . 使用aws:referer键允许s3:GetObject权限,条件是get请求必须来自特定网页 . 以下策略使用aws:Referer条件键指定StringLike条件 .

    "Version": "2012-10-17",
    "Id": "http referer policy example",
    "Statement": [
    {
    "Sid": "Allow get requests referred by www.example.com and example.com.",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::examplebucket/*",
    "Condition": {
    "StringLike": {"aws:Referer": ["http://www.example.com/*","http://example.com/*"]}
    }
    },
    {
    "Sid": "Explicit deny to ensure requests are allowed only from specific referer.",
    "Effect": "Deny",
    "Principal": "*",
    "Action": "s3:*",
    "Resource": "arn:aws:s3:::examplebucket/*",
    "Condition": {
    "StringNotLike": {"aws:Referer": ["http://www.example.com/*","http://example.com/*"]}
    }
    }
    ]
    }
    

    AWS Reference Link

相关问题