gpt4 book ai didi

amazon-web-services - 为什么我的 sqs 访问策略语句被覆盖而不是添加另一个策略?

转载 作者:行者123 更新时间:2023-12-03 07:16:24 27 4
gpt4 key购买 nike

我有一个 sqs 队列,它有一个现有的 sqs 访问策略。

我尝试在现有策略中添加另一个策略声明,但运行我的 cloudformation 模板会导致新策略覆盖现有策略。

 DlqSqsQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: !Sub name
KmsMasterKeyId: alias/aws/sqs
KmsDataKeyReusePeriodSeconds: 86400
UpdateReplacePolicy: Delete
DeletionPolicy: Delete

DlqSqsQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Statement:
- Action: sqs:SendMessage
Condition:
ArnEquals:
aws:SourceArn:
Fn::GetAtt:
- rulenamev1
- Arn

Effect: Allow
Principal:
Service: events.amazonaws.com
Resource:
Fn::GetAtt:
- DlqSqsQueue
- Arn
Sid: v1
Version: '2012-10-17'
Queues:
- Ref: DlqSqsQueue

DlqSqsQueuePolicyV2:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Statement:
- Action: sqs:SendMessage
Condition:
ArnEquals:
aws:SourceArn:
Fn::GetAtt:
- rulenamev2
- Arn
Effect: Allow
Principal:
Service: events.amazonaws.com
Resource:
Fn::GetAtt:
- DlqSqsQueue
- Arn
Sid: v2
Version: '2012-10-17'
Queues:
- Ref: DlqSqsQueue

最佳答案

一个 SQS 队列只能有一个 AWS::SQS::QueuePolicy。您必须从 DlqSqsQueuePolicyV2 获取 Statement 并将其添加到 DlqSqsQueuePolicy:

 DlqSqsQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: !Sub name
KmsMasterKeyId: alias/aws/sqs
KmsDataKeyReusePeriodSeconds: 86400
UpdateReplacePolicy: Delete
DeletionPolicy: Delete

DlqSqsQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Statement:
- Action: sqs:SendMessage
Condition:
ArnEquals:
aws:SourceArn:
Fn::GetAtt:
- rulenamev1
- Arn

Effect: Allow
Principal:
Service: events.amazonaws.com
Resource:
Fn::GetAtt:
- DlqSqsQueue
- Arn
Sid: v1
- Action: sqs:SendMessage
Condition:
ArnEquals:
aws:SourceArn:
Fn::GetAtt:
- rulenamev2
- Arn
Effect: Allow
Principal:
Service: events.amazonaws.com
Resource:
Fn::GetAtt:
- DlqSqsQueue
- Arn
Sid: v2
Version: '2012-10-17'
Queues:
- Ref: DlqSqsQueue

关于amazon-web-services - 为什么我的 sqs 访问策略语句被覆盖而不是添加另一个策略?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75455408/

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