【问题标题】:How can I allow cognito users to access their own S3 folders如何允许 cognito 用户访问他们自己的 S3 文件夹
【发布时间】:2019-04-05 16:04:58
【问题描述】:

我想要的是让 aws cognito 用户组(家庭)读取/写入 S3 存储桶,这些存储桶应该仅供这些用户家庭使用。

我用 boto3 python 库创建了一个用户。现在我需要授予该用户访问他们在存储桶中的文件夹的权限。

我发现一些帖子建议创建这样的存储桶策略:

policy = {
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "Grant user access to his folder",
        "Effect": "Allow",
        "Principal": "*",
        "Action": ["s3:PutObject"],
        "Resource": "arn:aws:s3:::BUCKET/users/${cognito-identity.amazonaws.com:sub}",
        "Condition": {
            "StringLike": {
                "cognito-identity.amazonaws.com:sub": [
                    "us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
                    "us-east-1:yyyyyyyy-xxxx-xxxx-xxxx-xxxxxxxxxx"
                ]
            }
        }
    }
]}

但事实证明,我们无法在存储桶的策略条件中指定“cognito-identity.amazonaws.com:sub”。

非常感谢任何帮助。

【问题讨论】:

  • 我现在也在为此苦苦挣扎。你找到解决问题的方法了吗?不应该将此策略附加到 cognito 用户而不是存储桶吗?
  • @Lonergan6275 不,我没有。

标签: amazon-web-services amazon-s3 boto3 amazon-cognito amazon-iam


【解决方案1】:

我认为您上面的策略需要是经过身份验证的用户的 IAM 角色,而不是存储桶策略的一部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-30
    • 2020-12-18
    • 2017-06-13
    • 2017-10-29
    • 1970-01-01
    • 2016-07-29
    • 2017-12-19
    • 2016-11-27
    相关资源
    最近更新 更多