gpt4 book ai didi

amazon-s3 - S3 存储桶的 ListObjectsV2 操作的 AccessDenied

转载 作者:行者123 更新时间:2023-12-03 09:54:46 25 4
gpt4 key购买 nike

在 GitlabCi 期间,我得到:
“ fatal error :调用 ListObjectsV2 操作时发生错误 (AccessDenied):访问被拒绝”

我的存储桶政策:

{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::BUCKET-NAME/*"
}
]

}

在 gitlabCI 设置集中:
  • AWS_ACCESS_KEY_ID:您的 AWS-ACCESS-KEY-ID
  • AWS_SECRET_ACCESS_KEY:您的 AWS-SECRET-ACCESS-KEY
  • S3_BUCKET_NAME:您的-S3-BUCKET-NAME
  • DISTRIBUTION_ID:CLOUDFRONT-DISTRIBUTION-ID

  • 我的 .gitlab-ci.yml
    image: docker:latest

    stages:
    - build
    - deploy

    build:
    stage: build
    image: node:8.11.3
    script:
    - export API_URL="d144iew37xsh40.cloudfront.net"
    - npm install
    - npm run build
    - echo "BUILD SUCCESSFULLY"
    artifacts:
    paths:
    - public/
    expire_in: 20 mins
    environment:
    name: production
    only:
    - master
    deploy:
    stage: deploy
    image: python:3.5
    dependencies:
    - build
    script:
    - export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
    - export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
    - export S3_BUCKET_NAME=$S3_BUCKET_NAME
    - export DISTRIBUTION_ID=$DISTRIBUTION_ID
    - pip install awscli --upgrade --user
    - export PATH=~/.local/bin:$PATH
    - aws s3 sync --acl public-read --delete public $S3_BUCKET_NAME
    - aws cloudfront create-invalidation --distribution-id
    $DISTRIBUTION_ID --paths '/*'
    - echo "DEPLOYED SUCCESSFULLY"

    environment:
    name: production
    only:
    - master

    最佳答案

    我不确定接受的答案实际上是否可以接受,因为它只允许对存储桶进行所有操作。 Sid 也具有误导性…… ;-)

    This AWS article提到 aws s3 sync 所需的权限.

    相应的策略如下所示:

    {
    "Version": "version_id",
    "Statement": [
    {
    "Sid": "AllowBucketSync",
    "Effect": "Allow",
    "Action": [
    "s3:GetObject",
    "s3:PutObject",
    "s3:ListBucket"
    ],
    "Resource": [
    "arn:aws:s3:::BUCKET-NAME",
    "arn:aws:s3:::BUCKET-NAME/*"
    ]
    }
    ] }

    关于amazon-s3 - S3 存储桶的 ListObjectsV2 操作的 AccessDenied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56327291/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com