gpt4 book ai didi

amazon-web-services - 使用 AWS CLI 创建 CloudFront 失效时访问被拒绝

转载 作者:行者123 更新时间:2023-12-04 08:00:55 31 4
gpt4 key购买 nike

我正在使用 AWS CLI 在脚本中创建 CloudFront 分配:

aws configure set preview.cloudfront true
aws cloudfront create-invalidation --distribution-id ABCD1234 --paths '/*'

我用这个语句设置了一个策略:
{
"Sid": "xxx",
"Effect": "Allow",
"Action": [
"cloudfront:CreateInvalidation"
],
"Resource": [
"arn:aws:cloudfront::xxx:distribution/ABCD1234"
]
}

该策略附加到运行命令的用户。但是,我仍然收到此错误:

A client error (AccessDenied) occurred when calling the CreateInvalidation operation: User: arn:aws:iam::xxx:user/yyy is not authorized to perform: cloudfront:CreateInvalidation

最佳答案

问题是 CloudFront 无法使用指定资源的策略。 “扩大”政策修复了错误。

This support thread状态:

CloudFront does not support Resource-Level permissions for IAM.



它也被埋在 documentation for CloudFront :
Operation:             POST Invalidation (CreateInvalidation)
Required Permissions: cloudfront:CreateInvalidation
Resources: *

这意味着政策需要是:
{
"Sid": "xxx",
"Effect": "Allow",
"Action": [
"cloudfront:CreateInvalidation"
],
"Resource": [
"*" <-- must be a wildcard
]
}

关于amazon-web-services - 使用 AWS CLI 创建 CloudFront 失效时访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44830990/

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