Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon cloudformation SQSPolicy在堆栈创建期间失败_Amazon Cloudformation_Amazon Sqs - Fatal编程技术网

Amazon cloudformation SQSPolicy在堆栈创建期间失败

Amazon cloudformation SQSPolicy在堆栈创建期间失败,amazon-cloudformation,amazon-sqs,Amazon Cloudformation,Amazon Sqs,我似乎不知道是什么导致了这次失败。我提到了一个。谁能告诉我是什么导致了这个错误 AllowSNS2SQSPolicy: Type: AWS::SQS::QueuePolicy Properties: Queues: [ !Ref SQSQueue ] PolicyDocument: Version: "2012-10-17" Id: SQSPolicy Statement: - Sid: A

我似乎不知道是什么导致了这次失败。我提到了一个。谁能告诉我是什么导致了这个错误

AllowSNS2SQSPolicy:
    Type: AWS::SQS::QueuePolicy
    Properties:
      Queues: [ !Ref SQSQueue ]
      PolicyDocument:
        Version: "2012-10-17"
        Id: SQSPolicy
        Statement: 
        - Sid: Allow-SNS-SendMessage    
          Effect: Allow 
          Principal:    
            AWS:
            - 'arn:aws:ecs:${AWS::Region}:${AWS::AccountId:}:cluster/foo'
          Action:   
          - 'sqs:SendMessage'
          - 'sqs:ReceiveMessage' 
          Resource: !GetAtt [SQSQueue, Arn]
错误消息:

Invalid value for parameter Policy. (Service: AmazonSQS; Status Code: 400, Error Code: InvalidAttributeValue...

这应该解决这个问题:

AllowSNS2SQSPolicy:
  Type: AWS::SQS::QueuePolicy
  Properties:
    Queues: [ !Ref SQSQueue ]
    PolicyDocument:
      Version: "2012-10-17"
      Id: SQSPolicy
      Statement: 
      - Sid: Allow-SNS-SendMessage    
        Effect: Allow 
        Principal:    
          AWS:'arn:aws:ecs:${AWS::Region}:${AWS::AccountId:}:cluster/foo'
        Action:   
        - 'sqs:SendMessage'
        - 'sqs:ReceiveMessage' 
        Resource: !GetAtt [SQSQueue, Arn]  

不确定你是否解决了这个问题,但也许这会帮助其他人

我遇到了这个问题,并通过允许任何用户访问资源解决了这个问题。我不知道为什么,但当指定了
主体时,我无法使Json策略工作?我也没有发现任何示例会使用除了
主体:“*”

即使您允许所有人访问资源,您仍然可以使用
条件
限制对资源的访问

AllowSNS2SQSPolicy:
    Type: AWS::SQS::QueuePolicy
    Properties:
      Queues: [ !Ref SQSQueue ]
      PolicyDocument:
        Version: "2012-10-17"
        Id: SQSPolicy
        Statement: 
        - Sid: Allow-SNS-SendMessage    
          Effect: Allow 
          Principal: '*'
          Action:   
          - 'sqs:SendMessage'
          - 'sqs:ReceiveMessage' 
          Resource: !GetAtt [SQSQueue, Arn]
          Condition:
            ArnEquals:
              aws:SourceArn: !GetAtt YourEcsClusterResource.Arn

以下是一些帮助我的文档:

我的第一个愚蠢错误:我写了

“委托人”:

而不是

"Principal": {
   "AWS": <my ARN>
}
“委托人”:{
“AWS”:
}

第二个错误,不是那么愚蠢:我试图使用lambda arn作为主体,但不得不使用lambda角色。因此,对于最初的问题,我建议不要使用ecs arn,而是使用ecs角色arn。

您的ecs群集作为主体想要实现什么?我正在尝试让ecs群集能够访问Sqs队列这对我来说很有效(抱歉,评论中没有代码):主体:服务:“events.amazonaws.com”